Commit ae905980 authored by Robert Griesemer's avatar Robert Griesemer

- fixed bug in parser.go

- added more tests

SVN=126784
parent bb9d53e5
...@@ -592,12 +592,16 @@ func (P *Parser) ParseIfStat() { ...@@ -592,12 +592,16 @@ func (P *Parser) ParseIfStat() {
P.Trace("IfStat"); P.Trace("IfStat");
P.Expect(Scanner.IF); P.Expect(Scanner.IF);
if P.tok != Scanner.LBRACE { if P.tok != Scanner.LBRACE {
if P.tok != Scanner.SEMICOLON {
P.ParseSimpleStat(); P.ParseSimpleStat();
}
if P.tok == Scanner.SEMICOLON { if P.tok == Scanner.SEMICOLON {
P.Next(); P.Next();
if P.tok != Scanner.LBRACE {
P.ParseExpression(); P.ParseExpression();
} }
} }
}
P.ParseBlock(); P.ParseBlock();
if P.tok == Scanner.ELSE { if P.tok == Scanner.ELSE {
P.Next(); P.Next();
...@@ -677,12 +681,16 @@ func (P *Parser) ParseSwitchStat() { ...@@ -677,12 +681,16 @@ func (P *Parser) ParseSwitchStat() {
P.Trace("SwitchStat"); P.Trace("SwitchStat");
P.Expect(Scanner.SWITCH); P.Expect(Scanner.SWITCH);
if P.tok != Scanner.LBRACE { if P.tok != Scanner.LBRACE {
if P.tok != Scanner.SEMICOLON {
P.ParseSimpleStat(); P.ParseSimpleStat();
}
if P.tok == Scanner.SEMICOLON { if P.tok == Scanner.SEMICOLON {
P.Next(); P.Next();
if P.tok != Scanner.LBRACE {
P.ParseExpression(); P.ParseExpression();
} }
} }
}
P.Expect(Scanner.LBRACE); P.Expect(Scanner.LBRACE);
for P.tok != Scanner.RBRACE { for P.tok != Scanner.RBRACE {
P.ParseCaseClause(); P.ParseCaseClause();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment