From 7e3bbd6ac9896666e26d7a634242ee77b58db331 Mon Sep 17 00:00:00 2001 From: Joshua Wise Date: Tue, 11 Sep 2007 01:47:43 -0400 Subject: [PATCH] update grammar a bit --- examples/easytest.c | 20 ++++++++++---------- examples/fib.c | 2 +- grammar.txt | 5 +++-- lib/parser/default.lua | 2 +- lib/parser/{parser.lua => oldstyle.lua} | 0 5 files changed, 15 insertions(+), 14 deletions(-) rename lib/parser/{parser.lua => oldstyle.lua} (100%) diff --git a/examples/easytest.c b/examples/easytest.c index fa78c17..6e650ff 100644 --- a/examples/easytest.c +++ b/examples/easytest.c @@ -1,12 +1,12 @@ int main() { - int iters = 0; - printint(1); - printint(2); - printint(3); - printint(iters); - printint(iters+1); - while (iters < 5) - iters = iters + 1; - return iters; -} \ No newline at end of file + int iters = 0; + printint(1); + printint(2); + printint(3); + printint(iters); + printint(iters+1); + while (iters < 5) + iters = iters + 1; + return iters; +} diff --git a/examples/fib.c b/examples/fib.c index 70479da..da6daea 100644 --- a/examples/fib.c +++ b/examples/fib.c @@ -15,4 +15,4 @@ int main() iters = iters + 1; } return iters; -} \ No newline at end of file +} diff --git a/grammar.txt b/grammar.txt index f8e78d2..ecf0dd1 100644 --- a/grammar.txt +++ b/grammar.txt @@ -2,7 +2,7 @@ GLOBAL := ( FUNCTION | VARIABLE )* FUNCTION := TYPE MODIFIERS _IDENTIFIER ARGSLIST ( ';' | STMTLIST ) TYPE := 'int' MODIFIERS := '*'* -ARGSLIST := '(' [ TYPE _IDENTIFIER ( ',' TYPE _IDENTIFIER)]* ] ')' +ARGSLIST := '(' [ TYPE MODIFIERS _IDENTIFIER ( ',' TYPE MODIFIERS _IDENTIFIER )* ] ')' STMTLIST := '{' ( VARIABLE | STATEMENT | STMTLIST )* '}' VARIABLE := TYPE MODIFIERS _IDENTIFIER [ = EXPRESSION ] ';' STATEMENT := ( ';' | EXPRESSION ';' | WHILE | IF | RETURN ) @@ -15,4 +15,5 @@ P13EXPR := P6EXPR ( '=' P6EXPR )* P6EXPR := P5EXPR ( '==' P5EXPR )* P5EXPR := P3EXPR ( ( '<' | '>' ) P3EXPR )* P3EXPR := P2EXPR ( ( '+' | '-' ) P2EXPR )* -P2EXPR := _NUMBER ( ( '*' | '/' ) _NUMBER )* \ No newline at end of file +P2EXPR := SUBEXPR ( ( '*' | '/' ) SUBEXPR )* +SUBEXPR := ( '(' EXPRESSION ')' | _NUMBER | _IDENTIFIER ) diff --git a/lib/parser/default.lua b/lib/parser/default.lua index 6652ac0..e88747e 120000 --- a/lib/parser/default.lua +++ b/lib/parser/default.lua @@ -1 +1 @@ -parser.lua \ No newline at end of file +recdesc.lua \ No newline at end of file diff --git a/lib/parser/parser.lua b/lib/parser/oldstyle.lua similarity index 100% rename from lib/parser/parser.lua rename to lib/parser/oldstyle.lua -- 2.39.2