From: Joshua Wise Date: Tue, 11 Sep 2007 05:47:43 +0000 (-0400) Subject: update grammar a bit X-Git-Url: http://git.joshuawise.com/jwcc.git/commitdiff_plain/7e3bbd6ac9896666e26d7a634242ee77b58db331?hp=933e60e38a9fe9d3770ab93b494d967361eef5b8 update grammar a bit --- 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