Commit c40be3b1 authored by Robert Griesemer's avatar Robert Griesemer

- go parser parses itself

SVN=126408
parent 6def94ad
This diff is collapsed.
...@@ -18,7 +18,7 @@ export ...@@ -18,7 +18,7 @@ export
AND_ASSIGN, OR_ASSIGN, XOR_ASSIGN, SHL_ASSIGN, SHR_ASSIGN, AND_ASSIGN, OR_ASSIGN, XOR_ASSIGN, SHL_ASSIGN, SHR_ASSIGN,
CAND, COR, CAND, COR,
BREAK, CASE, CHAN, CONST, CONTINUE, DEFAULT, ELSE, EXPORT, FALLTHROUGH, FALSE, BREAK, CASE, CHAN, CONST, CONTINUE, DEFAULT, ELSE, EXPORT, FALLTHROUGH, FALSE,
FOR, FUNC, GO, GOTO, IF, IMPORT, INTERFACE, MAP, NEW, NIL, PACKAGE, RANGE, FOR, FUNC, GO, GOTO, IF, IMPORT, INTERFACE, IOTA, MAP, NEW, NIL, PACKAGE, RANGE,
RETURN, SELECT, STRUCT, SWITCH, TRUE, TYPE, VAR RETURN, SELECT, STRUCT, SWITCH, TRUE, TYPE, VAR
...@@ -103,6 +103,7 @@ const ( ...@@ -103,6 +103,7 @@ const (
IF; IF;
IMPORT; IMPORT;
INTERFACE; INTERFACE;
IOTA;
MAP; MAP;
NEW; NEW;
NIL; NIL;
...@@ -140,8 +141,8 @@ func TokenName(tok int) string { ...@@ -140,8 +141,8 @@ func TokenName(tok int) string {
case RPAREN: return ")"; case RPAREN: return ")";
case LBRACK: return "["; case LBRACK: return "[";
case RBRACK: return "]"; case RBRACK: return "]";
case LBRACE: return "{"; case LBRACE: return "LBRACE";
case RBRACE: return "}"; case RBRACE: return "RBRACE";
case ASSIGN: return "="; case ASSIGN: return "=";
case DEFINE: return ":="; case DEFINE: return ":=";
...@@ -203,6 +204,7 @@ func TokenName(tok int) string { ...@@ -203,6 +204,7 @@ func TokenName(tok int) string {
case IF: return "if"; case IF: return "if";
case IMPORT: return "import"; case IMPORT: return "import";
case INTERFACE: return "interface"; case INTERFACE: return "interface";
case IOTA: return "iota";
case MAP: return "map"; case MAP: return "map";
case NEW: return "new"; case NEW: return "new";
case NIL: return "nil"; case NIL: return "nil";
......
...@@ -8,7 +8,7 @@ import Scanner "scanner" ...@@ -8,7 +8,7 @@ import Scanner "scanner"
import Parser "parser" import Parser "parser"
func Parse(src string, verbose bool) { func Parse(src string, verbose int) {
S := new(Scanner.Scanner); S := new(Scanner.Scanner);
S.Open(src); S.Open(src);
...@@ -20,10 +20,14 @@ func Parse(src string, verbose bool) { ...@@ -20,10 +20,14 @@ func Parse(src string, verbose bool) {
func main() { func main() {
verbose := false; verbose := 0;
for i := 1; i < sys.argc(); i++ { for i := 1; i < sys.argc(); i++ {
if sys.argv(i) == "-v" { switch sys.argv(i) {
verbose = true; case "-v":
verbose = 1;
continue;
case "-vv":
verbose = 2;
continue; continue;
} }
......
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