1 /* Copyright (c) 2013-2019 Mahmoud Fayed <msfclipper@yahoo.com> */
5 typedef struct Parser {
10 const char *TokenText ;
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 */
21 /* Lists of Lists, Functions in Program or in Class */
23 /* Lists of Lists, Classes in Program or in Class */
25 /* List of Lists, Packages in the program */
27 /* Mark to class label to be used by Private */
31 /* Counter to know if we are inside { } or not */
33 /* required for For-Step , insert instructions */
36 /* required for using { } after using new object to avoid assignment */
38 /* Object Init() Uses mixer for one purpose only( function call) - don't continue to get braces { } */
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 ;
47 ** required in loops (for|while) for loop and exit commands
48 ** To Know if the commands (Loop or Exit) are used
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 */
56 RingState *pRingState ;
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"
89 int ring_parser_start ( List *pTokens,RingState *pRingState ) ;
91 Parser * ring_parser_new ( List *pTokens,RingState *pRingState ) ;
93 Parser * ring_parser_delete ( Parser *pParser ) ;
95 void ring_parser_printtokens ( Parser *pParser ) ;
98 int ring_parser_class ( Parser *pParser ) ;
100 int ring_parser_stmt ( Parser *pParser ) ;
102 int ring_parser_step ( Parser *pParser,int *nMark1 ) ;
104 int ring_parser_paralist ( Parser *pParser ) ;
106 int ring_parser_expr ( Parser *pParser ) ;
108 int ring_parser_logicnot ( Parser *pParser ) ;
110 int ring_parser_equalornot ( Parser *pParser ) ;
112 int ring_parser_compare ( Parser *pParser ) ;
114 int ring_parser_bitorxor ( Parser *pParser ) ;
116 int ring_parser_bitand ( Parser *pParser ) ;
118 int ring_parser_bitshift ( Parser *pParser ) ;
120 int ring_parser_arithmetic ( Parser *pParser ) ;
122 int ring_parser_term ( Parser *pParser ) ;
124 int ring_parser_range ( Parser *pParser ) ;
126 int ring_parser_factor ( Parser *pParser,int *nFlag ) ;
128 int ring_parser_mixer ( Parser *pParser ) ;
130 int ring_parser_list ( Parser *pParser ) ;
132 int ring_parser_epslion ( Parser *pParser ) ;
134 int ring_parser_passepslion ( Parser *pParser ) ;
136 int ring_parser_namedotname ( Parser *pParser ) ;
138 int ring_parser_ppmm ( Parser *pParser ) ;
140 int ring_parser_csexpr ( Parser *pParser ) ;
142 int ring_parser_csbraceend ( Parser *pParser ) ;
144 int ring_parser_objattributes ( Parser *pParser ) ;
146 int ring_parser_bracesandend ( Parser *pParser,int lClass,SCANNER_KEYWORD nKeyword ) ;
149 void ring_parser_loadtoken ( Parser *pParser ) ;
151 int ring_parser_nexttoken ( Parser *pParser ) ;
153 int ring_parser_iskeyword ( Parser *pParser,SCANNER_KEYWORD x ) ;
155 int ring_parser_isoperator ( Parser *pParser,const char *cStr ) ;
157 int ring_parser_isliteral ( Parser *pParser ) ;
159 int ring_parser_isidentifier ( Parser *pParser ) ;
161 int ring_parser_isnumber ( Parser *pParser ) ;
163 int ring_parser_isendline ( Parser *pParser ) ;
165 int ring_parser_settoken ( Parser *pParser,int x ) ;
167 int ring_parser_isanykeyword ( Parser *pParser ) ;
169 int ring_parser_isoperator2 ( Parser *pParser,SCANNER_OPERATOR nType ) ;
172 void ring_parser_error ( Parser *pParser,const char *cStr ) ;
175 void ring_parser_gencall ( Parser *pParser,int nCallMethod ) ;
177 void ring_parser_gencallbracemethod ( Parser *pParser,const char *cMethod ) ;
179 int ring_parser_gencallringvmsee ( Parser *pParser ) ;
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)