Commit ae905980 authored by Robert Griesemer's avatar Robert Griesemer

- fixed bug in parser.go

- added more tests

SVN=126784
parent bb9d53e5
...@@ -592,10 +592,14 @@ func (P *Parser) ParseIfStat() { ...@@ -592,10 +592,14 @@ 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 {
P.ParseSimpleStat(); if P.tok != Scanner.SEMICOLON {
P.ParseSimpleStat();
}
if P.tok == Scanner.SEMICOLON { if P.tok == Scanner.SEMICOLON {
P.Next(); P.Next();
P.ParseExpression(); if P.tok != Scanner.LBRACE {
P.ParseExpression();
}
} }
} }
P.ParseBlock(); P.ParseBlock();
...@@ -677,10 +681,14 @@ func (P *Parser) ParseSwitchStat() { ...@@ -677,10 +681,14 @@ 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 {
P.ParseSimpleStat(); if P.tok != Scanner.SEMICOLON {
P.ParseSimpleStat();
}
if P.tok == Scanner.SEMICOLON { if P.tok == Scanner.SEMICOLON {
P.Next(); P.Next();
P.ParseExpression(); if P.tok != Scanner.LBRACE {
P.ParseExpression();
}
} }
} }
P.Expect(Scanner.LBRACE); P.Expect(Scanner.LBRACE);
......
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