From eff5c1326afaaabc9ba55ebd17908541e5d25242 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 6 Apr 2018 20:27:13 -0700 Subject: [PATCH] Don't use infinite loop and use correct file for test Gamelan currently playing: And The Darkest Hour Is Just Before The Dawn co-authored-by: Connor Walsh co-authored-by: Octavia --- lexer.go | 1 + lexer_test.go | 2 +- parser.go | 6 ------ 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lexer.go b/lexer.go index 5b7b2a9..61510fa 100644 --- a/lexer.go +++ b/lexer.go @@ -54,6 +54,7 @@ func (c *Compterpreter) GetNextToken() (Token, error) { case c.IsIdentifierFirstSymbol(c.CurrentChar): // is it a keyword? // is it a function/variable identifier? + err = c.TokenizeIdentifier(c.CurrentChar) case c.IsPunctuation(c.CurrentChar): err = c.TokenizePunctuation(c.CurrentChar) default: diff --git a/lexer_test.go b/lexer_test.go index a925252..3770b08 100644 --- a/lexer_test.go +++ b/lexer_test.go @@ -116,7 +116,7 @@ func (s *LexerSuite) TestTokenizeIdentifier() { // advance ptr to first character for _, op := range []string{"myVariable"} { compt.CurrentToken = Token{} - compt.TokenizeOperator(compt.CurrentChar) + compt.TokenizeIdentifier(compt.CurrentChar) if string(compt.CurrentChar) == "EOF" { break } diff --git a/parser.go b/parser.go index 61b2111..687638c 100644 --- a/parser.go +++ b/parser.go @@ -1,7 +1,5 @@ package dockerlang -import "fmt" - type Stack struct { Elements []AST } @@ -64,7 +62,6 @@ func (c *Compterpreter) Parse() error { for i := 0; i < opsExpr.Arity; i++ { // make sure we're not popping nil into exprs if exprStack.Peek() == nil { - fmt.Println("1") return DockerlangSyntaxError } opsExpr.Operands = append([]AST{exprStack.Pop()}, opsExpr.Operands...) @@ -83,13 +80,10 @@ func (c *Compterpreter) Parse() error { return DockerlangSyntaxError } if opsStack.Peek() != nil { - fmt.Println(opsStack.Peek()) // oh noooo! return DockerlangSyntaxError } - fmt.Println(exprStack) - c.StackTree.Operands = []AST{exprStack.Pop().(*Expr)} return nil