forked from totalspectrum/spin2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spinc.h
72 lines (50 loc) · 1.67 KB
/
spinc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Spin to C/C++ converter
* Copyright 2011-2021 Total Spectrum Software Inc.
* main header file
*/
#ifndef SPINC_H
#define SPINC_H
#include <stdint.h>
#include "ast.h"
#include "frontends/common.h"
#include "frontends/lexer.h"
// definition for the Spin parser
#define SPINYYSTYPE AST*
#define BASICYYSTYPE AST*
#define CGRAMYYSTYPE AST*
extern Module *allparse;
/* printing functions */
extern int IsReservedWord(const char *str);
/* function to canonicalize an identifier */
void CanonicalizeIdentifier(char *idstr);
/* perform useful Spin specific transformations */
void SpinTransform(Function *f);
/* ditto for BASIC */
void BasicTransform(Function *f);
/* and C */
void CTransform(Function *f);
/* check and possibly convert types */
AST *CheckTypes(AST *);
/* helper */
void InitGlobalFuncs(void);
/* do some optimizations on a counting repeat loop */
AST *TransformCountRepeat(AST *);
// process a module after parsing it
void ProcessModule(Module *P);
// top level functions
// parse a spin file; params is optional list of overriden constants
Module *ParseFile(const char *name, AST *params);
// parse top level spin files (resets global state)
// outputBin is nonzero if we are outputting binary code
Module *ParseTopFiles(const char *argv[], int argc, int outputBin);
// calculate number of expression items that may be placed on the stack
int NumExprItemsOnStack(AST *param);
// find the "main" function in a module, if any
Function *GetMainFunction(Module *P);
// construct an AST corresponding to a DEBUG() statement
// see (frontends/printdebug.c)
AST *BuildDebugList(AST *exprlist);
// convert AST debug list into printf
AST *CreatePrintfDebug(AST *exprlist);
#endif