143 " ident : /[a-zA-Z_][a-zA-Z0-9_]*/ ; \n"
144 " number : /[0-9]+/ ; \n"
145 " character : /'.'/ ; \n"
146 " string : /\"(\\\\.|[^\"])*\"/ ; \n"
148 " factor : '(' <lexp> ')' \n"
152 " | <ident> '(' <lexp>? (',' <lexp>)* ')' \n"
155 " term : <factor> (('*' | '/' | '%') <factor>)* ; \n"
156 " lexp : <term> (('+' | '-') <term>)* ; \n"
158 " stmt : '{' <stmt>* '}' \n"
159 " | \"while\" '(' <exp> ')' <stmt> \n"
160 " | \"if\" '(' <exp> ')' <stmt> \n"
161 " | <ident> '=' <lexp> ';' \n"
162 " | \"print\" '(' <lexp>? ')' ';' \n"
163 " | \"return\" <lexp>? ';' \n"
164 " | <ident> '(' (<number>|<ident>|<string>)? (',' (<string>|<number>|<ident>))* ')' ';' ; \n"
166 " exp : <lexp> '>' <lexp> \n"
167 " | <lexp> '<' <lexp> \n"
168 " | <lexp> \">=\" <lexp> \n"
169 " | <lexp> \"<=\" <lexp> \n"
170 " | <lexp> \"!=\" <lexp> \n"
171 " | <lexp> \"==\" <lexp> ; \n"
173 " vartype : (\"int\" | \"char\") ; \n"
174 " typeident : <vartype> <ident> ; \n"
175 " decls : (<typeident> ';')* ; \n"
176 " args : <typeident>? (',' <typeident>)* ; \n"
177 " body : '{' <decls> <stmt>* '}' ; \n"
178 " comment : /\\/\\*([^\\*])*\\*\\// ; \n"
179 " linecomment : /\\/\\/([^\\n])*/ ; \n"
180 " asm : /\\:([^\\n])*/ ; \n"
181 " procedure : <ident> '@' \"global\" '(' <number>? ')' <body> ; \n"
182 " cprocedure : <vartype> <ident> '(' <args> ')' <body> ; \n"
183 " sigdef : <ident> '@' <ident> '(' <number> ')' ';' ; \n"
184 " sigbody : '@' <ident> '(' <number> ')' ';' ; \n"
185 " includes : (\"#include\" <string>)* ; \n"
186 " smallc : /^/ (<comment>|<asm>|<linecomment>|<sigdef>|<sigbody>|<procedure>|<cprocedure>)* <includes> <decls> /$/ ; \n",
187 Ident, Number, Character,
String, Factor, Term, Lexp, Stmt, Exp,
188 Vartype, Typeident, Decls, Args, Body, Comment, Linecomment, Asm, Procedure, CProcedure,
189 Sigdef, Sigbody, Includes, Smallc,
NULL);
206 for (
i = 0;
i <
root->children_num;
i++) {
231 mpc_cleanup(17, Ident, Number, Character,
String, Factor, Term, Lexp, Stmt, Exp,
232 Vartype, Typeident, Decls, Args, Body, Comment, Procedure, CProcedure,
233 Sigdef, Includes, Smallc);
static static fork const void static count static fd const char const char static newpath char char argv
mpc_err_t * mpca_lang(int flags, const char *language,...)
void mpc_ast_delete(mpc_ast_t *a)
int mpc_parse_pipe(const char *filename, FILE *pipe, mpc_parser_t *p, mpc_result_t *r)
void mpc_err_print(mpc_err_t *x)
void mpc_ast_print(mpc_ast_t *a)
int mpc_parse_contents(const char *filename, mpc_parser_t *p, mpc_result_t *r)
mpc_parser_t * mpc_new(const char *name)
void mpc_ast_print_to(mpc_ast_t *a, FILE *fp)
void mpc_cleanup(int n,...)
void mpc_err_delete(mpc_err_t *x)
static void processNode(mpc_ast_t *node)