OSDN Git Service

こっそり、気持ち程度の日本語化しました (UTF-8 / Windows 環境用)。
[ring-lang-081/annotated-ring-with-OmegaT.git] / source / include / ring_parser.h
1 /* Copyright (c) 2013-2019 Mahmoud Fayed <msfclipper@yahoo.com> */
2 #ifndef ring_parser_h
3 #define ring_parser_h
4 /* Data */
5 typedef struct Parser {
6         List *Tokens  ;
7         int ActiveToken  ;
8         int TokensCount  ;
9         char TokenType  ;
10         const char *TokenText  ;
11         int nTokenIndex  ;
12         int nLineNumber  ;
13         int nErrorLine  ;
14         int nErrorsCount  ;
15         List *GenCode  ;
16         List *ActiveGenCodeList  ;
17         /* Variable to select between = and == while using = only in the code */
18         char nAssignmentFlag  ;
19         /* Variable to determine the start of the class definition */
20         char nClassStart  ;
21         /* Lists of Lists, Functions in Program or in Class */
22         List *FunctionsMap  ;
23         /* Lists of Lists, Classes in Program or in Class */
24         List *ClassesMap  ;
25         /* List of Lists, Packages in the program */
26         List *PackagesMap  ;
27         /* Mark to class label to be used by Private */
28         int nClassMark  ;
29         /* Private Flag */
30         char nPrivateFlag  ;
31         /* Counter to know if we are inside { } or not */
32         int nBraceFlag  ;
33         /* required for For-Step , insert instructions */
34         char nInsertFlag  ;
35         int nInsertCounter  ;
36         /* required for using { } after using new object to avoid assignment */
37         char nNewObject  ;
38         /* Object Init() Uses mixer for one purpose only( function call)  - don't continue to get braces { } */
39         char nFuncCallOnly  ;
40         /* Flag to tell { } that we are inside control structure (if/for/while/...) expression */
41         int nControlStructureExpr  ;
42         /* Flag - We started using braces {} in control structure - we have { */
43         int nControlStructureBrace  ;
44         /* Using Self or This with LoadAddress */
45         char nThisOrSelfLoadA  ;
46         /*
47         **  required in loops (for|while) for loop and exit commands 
48         **  To Know if the commands (Loop or Exit) are used 
49         */
50         char nLoopOrExitCommand  ;
51         /* Enable|Disable checking Loop & Exit commands before storing Loop & Exit marks */
52         char nCheckLoopAndExit  ;
53         /* Counter to know if we are inside a loop or not */
54         int nLoopFlag  ;
55         /* Ring State */
56         RingState *pRingState  ;
57 } Parser ;
58 /* Error Messages */
59 #define RING_PARSER_ERROR_PARALIST "Error (C1) : Error in parameters list, expected identifier"
60 #define RING_PARSER_ERROR_CLASSNAME "Error (C2) : Error in class name"
61 #define RING_PARSER_ERROR_OK "Error (C3) : Unclosed control strucutre, 'ok' is missing"
62 #define RING_PARSER_ERROR_END "Error (C4) : Unclosed control strucutre, 'end' is missing"
63 #define RING_PARSER_ERROR_NEXT "Error (C5) : Unclosed control strucutre, next is missing"
64 #define RING_PARSER_ERROR_FUNCNAME "Error (C6) : Error in function name"
65 #define RING_PARSER_ERROR_LISTITEM "Error (C7) : Error in list items"
66 #define RING_PARSER_ERROR_MISSPARENTHESES "Error (C8) : Parentheses ')' is missing "
67 #define RING_PARSER_ERROR_MISSBRACKETS "Error (C9) : Brackets ']' is missing "
68 #define RING_PARSER_ERROR_PRENTCLASSNAME "Error (C10) : Error in parent class name"
69 #define RING_PARSER_ERROR_EXPROPERATOR "Error (C11) : Error in expression operator"
70 #define RING_PARSER_ERROR_NOCLASSDEFINED "Error (C12) :No class definition"
71 #define RING_PARSER_ERROR_VARNAME "Error (C13) : Error in variable name"
72 #define RING_PARSER_ERROR_NOCATCH "Error (C14) : Try/Catch miss the Catch keyword!"
73 #define RING_PARSER_ERROR_NODONE "Error (C15) : Try/Catch miss the Done keyword!"
74 #define RING_PARSER_ERROR_SWITCHEXPR "Error (C16) : Error in Switch statement expression!"
75 #define RING_PARSER_ERROR_SWITCHOFF "Error (C17) : Switch statement without OFF"
76 #define RING_PARSER_ERROR_BRACESNOTCLOSED "Error (C18) : Missing closing brace for the block opened!"
77 #define RING_PARSER_ERROR_NUMERICOVERFLOW "Error (C19) : Numeric Overflow!"
78 #define RING_PARSER_ERROR_PACKAGENAME "Error (C20) : Error in package name"
79 #define RING_PARSER_ERROR_AGAIN "Error (C21) : Unclosed control strucutre, 'again' is missing"
80 #define RING_PARSER_ERROR_FUNCREDEFINE "Error (C22) : Function redefinition, function is already defined!"
81 #define RING_PARSER_ERROR_USINGBRACTAFTERNUM "Error (C23) : Using '(' after number!"
82 #define RING_PARSER_ERROR_PARENTLIKESUBCLASS "Error (C24) : The parent class name is identical to the subclass name"
83 #define RING_PARSER_ERROR_ACCESSSELFREF "Error (C25) : Trying to access the self reference after the object name"
84 #define RING_PARSER_ERROR_CLASSREDEFINE "Error (C26) : Class redefinition, class is already defined!"
85 #define RING_PARSER_WARNING_EXITOUTSIDELOOP "Warning (W6) : Using the EXIT command outside loop!"
86 #define RING_PARSER_WARNING_LOOPOUTSIDELOOP "Warning (W7) : Using the LOOP command outside loop"
87 /* Functions */
88
89 int ring_parser_start ( List *pTokens,RingState *pRingState ) ;
90
91 Parser * ring_parser_new ( List *pTokens,RingState *pRingState ) ;
92
93 Parser * ring_parser_delete ( Parser *pParser ) ;
94
95 void ring_parser_printtokens ( Parser *pParser ) ;
96 /* Grammar */
97
98 int ring_parser_class ( Parser *pParser ) ;
99
100 int ring_parser_stmt ( Parser *pParser ) ;
101
102 int ring_parser_step ( Parser *pParser,int *nMark1 ) ;
103
104 int ring_parser_paralist ( Parser *pParser ) ;
105
106 int ring_parser_expr ( Parser *pParser ) ;
107
108 int ring_parser_logicnot ( Parser *pParser ) ;
109
110 int ring_parser_equalornot ( Parser *pParser ) ;
111
112 int ring_parser_compare ( Parser *pParser ) ;
113
114 int ring_parser_bitorxor ( Parser *pParser ) ;
115
116 int ring_parser_bitand ( Parser *pParser ) ;
117
118 int ring_parser_bitshift ( Parser *pParser ) ;
119
120 int ring_parser_arithmetic ( Parser *pParser ) ;
121
122 int ring_parser_term ( Parser *pParser ) ;
123
124 int ring_parser_range ( Parser *pParser ) ;
125
126 int ring_parser_factor ( Parser *pParser,int *nFlag ) ;
127
128 int ring_parser_mixer ( Parser *pParser ) ;
129
130 int ring_parser_list ( Parser *pParser ) ;
131
132 int ring_parser_epslion ( Parser *pParser ) ;
133
134 int ring_parser_passepslion ( Parser *pParser ) ;
135
136 int ring_parser_namedotname ( Parser *pParser ) ;
137
138 int ring_parser_ppmm ( Parser *pParser ) ;
139
140 int ring_parser_csexpr ( Parser *pParser ) ;
141
142 int ring_parser_csbraceend ( Parser *pParser ) ;
143
144 int ring_parser_objattributes ( Parser *pParser ) ;
145
146 int ring_parser_bracesandend ( Parser *pParser,int lClass,SCANNER_KEYWORD nKeyword ) ;
147 /* Check Token */
148
149 void ring_parser_loadtoken ( Parser *pParser ) ;
150
151 int ring_parser_nexttoken ( Parser *pParser ) ;
152
153 int ring_parser_iskeyword ( Parser *pParser,SCANNER_KEYWORD x ) ;
154
155 int ring_parser_isoperator ( Parser *pParser,const char *cStr ) ;
156
157 int ring_parser_isliteral ( Parser *pParser ) ;
158
159 int ring_parser_isidentifier ( Parser *pParser ) ;
160
161 int ring_parser_isnumber ( Parser *pParser ) ;
162
163 int ring_parser_isendline ( Parser *pParser ) ;
164
165 int ring_parser_settoken ( Parser *pParser,int x ) ;
166
167 int ring_parser_isanykeyword ( Parser *pParser ) ;
168
169 int ring_parser_isoperator2 ( Parser *pParser,SCANNER_OPERATOR nType ) ;
170 /* Display Errors */
171
172 void ring_parser_error ( Parser *pParser,const char *cStr ) ;
173 /* Generate Code */
174
175 void ring_parser_gencall ( Parser *pParser,int nCallMethod ) ;
176
177 void ring_parser_gencallbracemethod ( Parser *pParser,const char *cMethod ) ;
178
179 int ring_parser_gencallringvmsee ( Parser *pParser ) ;
180 /* MACRO */
181 #define RING_PARSER_IGNORENEWLINE while(ring_parser_epslion(pParser));
182 #define RING_PARSER_PASSNEWLINE while(ring_parser_passepslion(pParser));
183 #define RING_PARSER_CURRENTTOKEN pParser->ActiveToken
184 #define RING_PARSER_OPERATIONID ring_list_getsize(pParser->GenCode)
185 #endif