Skip to content

Commit

Permalink
compiler/libec: (#1059) Added support for 123.identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
jerstlouis committed Feb 6, 2014
1 parent 92c3391 commit 7f3496d
Show file tree
Hide file tree
Showing 15 changed files with 18,701 additions and 18,319 deletions.
760 changes: 397 additions & 363 deletions compiler/bootstrap/libec/bootstrap/expression.c

Large diffs are not rendered by default.

2,074 changes: 1,048 additions & 1,026 deletions compiler/bootstrap/libec/bootstrap/grammar.c

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions compiler/bootstrap/libec/bootstrap/lexer.c

Large diffs are not rendered by default.

864 changes: 449 additions & 415 deletions compiler/bootstrap/libec/bootstrap/type.c

Large diffs are not rendered by default.

760 changes: 397 additions & 363 deletions compiler/libec/precompiled/expression.c

Large diffs are not rendered by default.

2,074 changes: 1,048 additions & 1,026 deletions compiler/libec/precompiled/grammar.c

Large diffs are not rendered by default.

864 changes: 449 additions & 415 deletions compiler/libec/precompiled/type.c

Large diffs are not rendered by default.

4,837 changes: 2,438 additions & 2,399 deletions compiler/libec/src/expression.ec

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions compiler/libec/src/expression.y
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@ postfix_expression:
| postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
| postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
| postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
| postfix_expression identifier
{
char * constant = $1.type == constantExp ? $1.constant : null;
int len = constant ? strlen(constant) : 0;
if(constant && constant[len-1] == '.')
{
constant[len-1] = 0;
$$ = MkExpMember($1, $2);
$$.loc = @$;
}
else
yyerror();
}
| postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
| postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
| postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
Expand All @@ -265,6 +278,19 @@ simple_postfix_expression:
| simple_postfix_expression '(' ')' { $$ = MkExpCall($1, MkList()); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; }
| simple_postfix_expression '(' argument_expression_list ')' { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.loc = @$; }
| simple_postfix_expression '.' identifier { $$ = MkExpMember($1, $3); $$.loc = @$; }
| simple_postfix_expression identifier
{
char * constant = $1.type == constantExp ? $1.constant : null;
int len = constant ? strlen(constant) : 0;
if(constant && constant[len-1] == '.')
{
constant[len-1] = 0;
$$ = MkExpMember($1, $2);
$$.loc = @$;
}
else
yyerror();
}
| simple_postfix_expression PTR_OP identifier { $$ = MkExpPointer($1, $3); $$.loc = @$; }
| simple_postfix_expression INC_OP { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
| simple_postfix_expression DEC_OP { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
Expand Down
17,947 changes: 9,000 additions & 8,947 deletions compiler/libec/src/grammar.ec

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions compiler/libec/src/grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ default:
relational_expression_error equality_expression_error and_expression_error
exclusive_or_expression_error inclusive_or_expression_error logical_and_expression_error
logical_or_expression_error conditional_expression_error assignment_expression_error
simple_primary_expression
simple_primary_expression constant
simple_postfix_expression simple_postfix_expression_error
common_unary_expression common_unary_expression_error
simple_unary_expression simple_unary_expression_error
Expand Down Expand Up @@ -1446,14 +1446,31 @@ i18n_string:
| '$' string_literal '.' string_literal { $$ = MkExpIntlString($4, $2); delete $2; delete $4; $$.loc = @$; }
;

constant:
CONSTANT { $$ = MkExpConstant(yytext); $$.loc = @$; }
;

simple_primary_expression:
identifier { $$ = MkExpIdentifier($1); $$.loc = @$; }
| instantiation_unnamed { $$ = MkExpInstance($1); $$.loc = @$; }
| EXTENSION '(' compound_statement ')' { $$ = MkExpExtensionCompound($3); $$.loc = @$; }
| EXTENSION '(' expression ')' { $$ = MkExpExtensionExpression($3); $$.loc = @$; }
| EXTENSION '(' type_name ')' initializer { $$ = MkExpExtensionInitializer($3, $5); $$.loc = @$; }
| EXTENSION '(' type_name ')' '(' type_name ')' initializer { $$ = MkExpExtensionInitializer($3, MkInitializerAssignment(MkExpExtensionInitializer($6, $8))); $$.loc = @$; }
| CONSTANT { $$ = MkExpConstant(yytext); $$.loc = @$; }
| constant identifier
{
char * constant = $1.constant;
int len = strlen(constant);
if(constant[len-1] == '.')
{
constant[len-1] = 0;
$$ = MkExpMember($1, $2);
$$.loc = @$;
}
else
yyerror();
}
| constant { $$ = $1; }
| i18n_string
| '(' ')' { Expression exp = MkExpDummy(); exp.loc.start = @1.end; exp.loc.end = @2.start; $$ = MkExpBrackets(MkListOne(exp)); $$.loc = @$; yyerror(); }
| NEWOP new_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,$3), $5); $$.loc = @$; }
Expand Down
1,218 changes: 608 additions & 610 deletions compiler/libec/src/lexer.ec

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiler/libec/src/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E [Ee][+-]?{D}+
FS (f|F|l|L|i|j)*
IS (u|U|l|L|i|j)*
FS (f|F|l|L|i|I|j|J)*
IS (u|U|l|L|i|I|j|J)*
IDENT {L}({L}|{D})*

%{
Expand Down
Loading

0 comments on commit 7f3496d

Please sign in to comment.