Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- #include <cstdio>
- #include <string>
- #include <iostream>
- #include <stack>
- extern FILE* yyin;
- %}
- %token identifier CLASS DEF COLON LBRACE RBRACE
- %%
- class_def: CLASS classname COLON stuff
- {
- int indent = @1.last_column;
- newclass new_class($2, indent);
- }
- ;
- classname: identifier
- {
- $$ = $1;
- }
- ;
- func_def: DEF funcname LBRACE [parameter_list] RBRACE COLON stuff
- {
- int ident = @1.last_column
- newfunc new_func($2, indent)
- }
- ;
- funcname: identifier
- {
- $$ = $1;
- }
- parameter_list: parameter //care
- {
- $$ = $1;
- }
- |
- {
- $$ = "";
- }
- ;
- parameter: parameter COMMA
- {
- $$ += $2;
- }
- ;
- stuff:
- ;
- int main()
- {
- return yyparse();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement