diff options
author | Robert Griesemer <gri@golang.org> | 2008-07-09 10:16:33 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2008-07-09 10:16:33 -0700 |
commit | c7640baf67fd6885368ec17dc51d75650222cce2 (patch) | |
tree | 7debed6c03c0a7d56ee073d0cbebcabefa506a72 /usr/gri/src/parser.go | |
parent | 7a74340f6c31db36b4f04b71407db9a137c1f36e (diff) | |
download | golang-c7640baf67fd6885368ec17dc51d75650222cce2.tar.gz |
- fixed scanner and parser issues to be able to parse math lib
SVN=126501
Diffstat (limited to 'usr/gri/src/parser.go')
-rw-r--r-- | usr/gri/src/parser.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/usr/gri/src/parser.go b/usr/gri/src/parser.go index d54937eba..82aca39c2 100644 --- a/usr/gri/src/parser.go +++ b/usr/gri/src/parser.go @@ -262,12 +262,12 @@ func (P *Parser) ParseImportDecl() { P.Trace("ImportDecl"); P.Expect(Scanner.IMPORT); if P.tok == Scanner.LPAREN { - P.ParseImportSpec(); - for P.tok == Scanner.SEMICOLON { - P.Next(); + P.Next(); + for P.tok != Scanner.RPAREN { P.ParseImportSpec(); + P.Optional(Scanner.SEMICOLON); // TODO this seems wrong } - P.Optional(Scanner.SEMICOLON); + P.Next(); } else { P.ParseImportSpec(); } @@ -738,12 +738,20 @@ func (P *Parser) ParseFuncDecl() { func (P *Parser) ParseExportDecl() { P.Trace("ExportDecl"); P.Expect(Scanner.EXPORT); - P.ParseIdent(); - for P.tok == Scanner.COMMA { + if P.tok == Scanner.LPAREN { + P.Next(); + for P.tok != Scanner.RPAREN { + P.ParseIdent(); + P.Optional(Scanner.COMMA); // TODO this seems wrong + } P.Next(); + } else { P.ParseIdent(); + for P.tok == Scanner.COMMA { + P.Next(); + P.ParseIdent(); + } } - P.Optional(Scanner.COMMA); P.Ecart(); } @@ -787,14 +795,12 @@ func (P *Parser) ParseOperand() { switch P.tok { case Scanner.IDENT: P.ParseQualifiedIdent(); - case Scanner.STRING: - fallthrough; - case Scanner.NUMBER: - P.Next(); case Scanner.LPAREN: P.Next(); P.ParseExpression(); P.Expect(Scanner.RPAREN); + case Scanner.STRING: fallthrough; + case Scanner.NUMBER: fallthrough; case Scanner.NIL: fallthrough; case Scanner.IOTA: fallthrough; case Scanner.TRUE: fallthrough; |