CT for now parses properly.

This commit is contained in:
Christoffer Lerno
2019-09-13 00:38:52 +02:00
parent b7c64a46ea
commit f6c07d86d0
9 changed files with 96 additions and 37 deletions

View File

@@ -62,7 +62,15 @@ void comment(void);
"throws" { count(); return(THROWS); }
"func" { count(); return(FUNC); }
"nil" { count(); return(NIL); }
"next" { count(); return(NEXT);
"next" { count(); return(NEXT); }
"in" { count(); return(IN); }
"$for" { count(); return(CTFOR); }
"$case" { count(); return(CTCASE); }
"$switch" { count(); return(CTSWITCH); }
"$default" { count(); return(CTDEFAULT); }
"$if" { count(); return(CTIF); }
"$elif" { count(); return(CTELIF); }
"$else" { count(); return(CTELSE); }
[_]*[A-Z]{UA}* { count(); return(CONST_IDENT); }
[_]*[A-Z]{UA}*[a-z]{AN}* { count(); return(TYPE_IDENT); }

View File

@@ -21,8 +21,8 @@ void yyerror(char *s);
%token STRUCT UNION ENUM ELLIPSIS AS LOCAL
%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
%token TYPE FUNC ERROR MACRO GENERIC CTIF CTELIF CTENDIF CTELSE CTSWITCH CTCASE CTDEFAULT CTEACH
%token THROWS THROW TRY CATCH SCOPE PUBLIC DEFER ATTRIBUTE
%token TYPE FUNC ERROR MACRO GENERIC CTIF CTELIF CTENDIF CTELSE CTSWITCH CTCASE CTDEFAULT CTFOR
%token THROWS THROW TRY CATCH SCOPE PUBLIC DEFER ATTRIBUTE IN
%start translation_unit
%%
@@ -32,6 +32,7 @@ path
| path IDENT SCOPE
;
ident_expression
: CONST_IDENT
| IDENT
@@ -298,11 +299,16 @@ ct_switch_body
| ct_switch_body ct_case_statement
;
ct_for_stmt
: CTFOR '(' CT_IDENT IN expression ')' statement
| CTFOR '(' CT_IDENT ',' CT_IDENT IN expression ')' statement
;
ct_statement
: ct_if compound_statement
| ct_if compound_statement ct_else_body
| ct_switch '{' ct_switch_body '}'
| CTEACH '(' expression AS CT_IDENT ')' statement
| ct_for_stmt
;
throw_statement