Fixed: grammar still allowed for some statements to be in a nested scope.

This commit is contained in:
arookas 2015-12-07 11:19:29 -05:00
parent cd8f699656
commit 9553a93622
2 changed files with 7 additions and 4 deletions

View file

@ -1,5 +1,4 @@
using PerCederberg.Grammatica.Runtime; using PerCederberg.Grammatica.Runtime;
using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -52,6 +51,7 @@ namespace arookas
{ {
switch (GetId(node)) switch (GetId(node))
{ {
case __sunConstants.ROOT_STATEMENT:
case __sunConstants.STATEMENT: case __sunConstants.STATEMENT:
case __sunConstants.COMPOUND_STATEMENT: case __sunConstants.COMPOUND_STATEMENT:
case __sunConstants.COMPOUND_STATEMENT_ITEM: case __sunConstants.COMPOUND_STATEMENT_ITEM:
@ -82,6 +82,7 @@ namespace arookas
switch (GetId(node)) switch (GetId(node))
{ {
case __sunConstants.SCRIPT: return new sunNode(location); case __sunConstants.SCRIPT: return new sunNode(location);
case __sunConstants.ROOT_STATEMENT: return new sunNode(location);
case __sunConstants.STATEMENT: return new sunNode(location); case __sunConstants.STATEMENT: return new sunNode(location);
case __sunConstants.STATEMENT_BLOCK: return new sunStatementBlock(location); case __sunConstants.STATEMENT_BLOCK: return new sunStatementBlock(location);
case __sunConstants.COMPOUND_STATEMENT: return new sunNode(location); case __sunConstants.COMPOUND_STATEMENT: return new sunNode(location);

View file

@ -109,14 +109,16 @@ STRING = <<"(\\.|[^"])*">>
%productions% %productions%
script = statement+; script = root_statement+;
// statements // statements
statement = root_statement =
import_statement SEMICOLON | import_statement SEMICOLON |
compound_statement SEMICOLON |
function_definition | function_definition |
builtin_declaration SEMICOLON | builtin_declaration SEMICOLON |
statement;
statement =
compound_statement SEMICOLON |
if_statement | if_statement |
while_statement | while_statement |
do_statement SEMICOLON | do_statement SEMICOLON |