diff --git a/src/gutscript/ast/assignment.go b/src/gutscript/ast/assignment.go index b0ca975..280cec8 100644 --- a/src/gutscript/ast/assignment.go +++ b/src/gutscript/ast/assignment.go @@ -3,14 +3,14 @@ package ast /* */ -type AssignStatement struct { +type Assignment struct { Variable Node Expr Node Statement } -func CreateAssignStatement(variable Node, expr Node) Node { - return AssignStatement{ +func CreateAssignment(variable Node, expr Node) Node { + return Assignment{ Variable: variable, Expr: expr, } diff --git a/src/gutscript/ast/class.go b/src/gutscript/ast/class.go index f1ead90..b5d4a87 100644 --- a/src/gutscript/ast/class.go +++ b/src/gutscript/ast/class.go @@ -1,21 +1,26 @@ package ast -type ClassStatement struct { - Name string - Properties []Node - Methods []Node +type Class struct { + Name string + // Properties []Node + // Methods []Node Super *string Interfaces []string + Body *StatementList } -func CreateClassStatement(className string) Node { - return ClassStatement{className, nil, nil, nil, []string{}} +func CreateClass(className string) Node { + return Class{className, nil, []string{}, nil} } -func (self ClassStatement) SetSuperClass(className string) { +func (self *Class) SetSuper(className string) { self.Super = &className } -func (self ClassStatement) AddInterface(intf string) { - self.Interfaces = append(self.Interfaces, intf) +func (self *Class) AddInterface(inf string) { + self.Interfaces = append(self.Interfaces, inf) +} + +func (self *Class) SetInterfaces(infs []string) { + self.Interfaces = infs } diff --git a/src/gutscript/ast/class_member.go b/src/gutscript/ast/class_member.go new file mode 100644 index 0000000..3114553 --- /dev/null +++ b/src/gutscript/ast/class_member.go @@ -0,0 +1,14 @@ +package ast + +type ClassMember struct { + Name string + Value Node +} + +func CreateClassMember(name string) ClassMember { + return ClassMember{name, nil} +} + +func (self *ClassMember) SetValue(val Node) { + self.Value = val +} diff --git a/src/gutscript/ast/expr.go b/src/gutscript/ast/expr.go index 4b9ef12..e3dc597 100644 --- a/src/gutscript/ast/expr.go +++ b/src/gutscript/ast/expr.go @@ -12,7 +12,11 @@ type Expr struct { Parenthesis bool } -func CreateExpr(op int, left, right Node) Node { +func CreateUnaryExpr(op int, val Node) UnaryExpr { + return UnaryExpr{op, val} +} + +func CreateExpr(op int, left, right Node) Expr { return Expr{ Op: op, Left: left, diff --git a/src/gutscript/ast/function.go b/src/gutscript/ast/function.go index 219b71c..c1a8da2 100644 --- a/src/gutscript/ast/function.go +++ b/src/gutscript/ast/function.go @@ -12,6 +12,6 @@ type FunctionParam struct { Default Node } -func CreateFunction(name string, params []FunctionParam, stmts *StatementList) Node { +func CreateFunction(name string, params []FunctionParam, stmts *StatementList) Function { return Function{name, params, stmts} } diff --git a/src/gutscript/ast/function_call.go b/src/gutscript/ast/function_call.go index 8bb77d7..44b39a2 100644 --- a/src/gutscript/ast/function_call.go +++ b/src/gutscript/ast/function_call.go @@ -5,6 +5,6 @@ type FunctionCall struct { Params []Node } -func CreateFunctionCall(name string, params []Node) Node { +func CreateFunctionCall(name string, params []Node) FunctionCall { return FunctionCall{name, params} } diff --git a/src/gutscript/codegen/php/visitor.go b/src/gutscript/codegen/php/visitor.go index 4f2f40e..78d79d6 100644 --- a/src/gutscript/codegen/php/visitor.go +++ b/src/gutscript/codegen/php/visitor.go @@ -16,14 +16,18 @@ func (self *Visitor) IndentSpace() string { return strings.Repeat(" ", self.indent) } -func (self *Visitor) Visit(n ast.Node) string { +func (self *Visitor) Visit(n ast.Node) (out string) { // fmt.Printf("visit %#v\n", n) if stmts, ok := n.(*ast.StatementList); ok { - var output string - for _, stmt := range *stmts { - output += self.IndentSpace() + self.Visit(stmt) + var stmtlen = len(*stmts) + for i, stmt := range *stmts { + if _, ok := stmt.(ast.ExprStatement); ok && i+1 == stmtlen { + out += self.IndentSpace() + "return " + self.Visit(stmt) + } else { + out += self.IndentSpace() + self.Visit(stmt) + } } - return output + return out } if variable, ok := n.(ast.Variable); ok { return "$" + variable.Identifier @@ -48,11 +52,41 @@ func (self *Visitor) Visit(n ast.Node) string { } return fmt.Sprintf("%s %c %s", self.Visit(expr.Left), expr.Op, self.Visit(expr.Right)) } - if stmt, ok := n.(ast.AssignStatement); ok { - return self.Visit(stmt.Variable) + " = " + self.Visit(stmt.Expr) + ";\n" + + if stmt, ok := n.(ast.Assignment); ok { + return self.IndentSpace() + self.Visit(stmt.Variable) + " = " + self.Visit(stmt.Expr) + ";\n" + } + + if cls, ok := n.(ast.Class); ok { + out = "class " + cls.Name + + if cls.Super != nil { + out += " extends " + *cls.Super + } + + if len(cls.Interfaces) > 0 { + out += " implements " + out += strings.Join(cls.Interfaces, ", ") + } + + out += " {\n" + if cls.Body != nil { + self.indent++ + out += self.Visit(cls.Body) + self.indent-- + } + out += "}\n" + return out + } + if member, ok := n.(ast.ClassMember); ok { + out += self.IndentSpace() + "public $" + member.Name + if member.Value != nil { + out += " = " + self.Visit(member.Value) + } + out += ";\n" + return out } if stmt, ok := n.(*ast.IfStatement); ok { - var out string = "" out += self.IndentSpace() + "if ( " + self.Visit(stmt.Expr) + " ) {\n" self.indent++ out += self.Visit(stmt.Body) @@ -75,7 +109,6 @@ func (self *Visitor) Visit(n ast.Node) string { return out } if stmt, ok := n.(ast.ElseIfStatement); ok { - var out string = "" out += self.IndentSpace() + " elseif ( " + self.Visit(stmt.Expr) + " ) {\n" self.indent++ out += self.Visit(stmt.Body) @@ -84,13 +117,12 @@ func (self *Visitor) Visit(n ast.Node) string { return out } if stmt, ok := n.(ast.ReturnStatement); ok { - return "return " + self.Visit(stmt.Expr) + ";\n" + return self.IndentSpace() + "return " + self.Visit(stmt.Expr) + ";\n" } if stmt, ok := n.(ast.ExprStatement); ok { - return self.Visit(stmt.Expr) + ";\n" + return self.IndentSpace() + self.Visit(stmt.Expr) + ";\n" } if fnc, ok := n.(ast.FunctionCall); ok { - var out string out = fnc.Name + "(" fields := []string{} for _, param := range fnc.Params { @@ -101,7 +133,6 @@ func (self *Visitor) Visit(n ast.Node) string { return out } if fn, ok := n.(ast.Function); ok { - var out string = "" out += self.IndentSpace() + "function " + fn.Name + "(" if len(fn.Params) > 0 { fields := []string{} diff --git a/src/gutscript/lexer.go b/src/gutscript/lexer.go index 8a28171..41255c9 100644 --- a/src/gutscript/lexer.go +++ b/src/gutscript/lexer.go @@ -10,11 +10,12 @@ type stateFn func(*GutsLex) stateFn type GutsLex struct { // the line - Input string - Line int - Start int - Pos int - state stateFn + Input string + Line int + Start int + Pos int + IndentLevel int + state stateFn // rollback position rollbackPos int diff --git a/src/gutscript/lexer_states.go b/src/gutscript/lexer_states.go index 9caa2b9..3892374 100644 --- a/src/gutscript/lexer_states.go +++ b/src/gutscript/lexer_states.go @@ -17,6 +17,8 @@ var LexKeywords = map[string]int{ "return": T_RETURN, "extends": T_EXTENDS, "does": T_DOES, + "new": T_NEW, + "clone": T_CLONE, } func (l *GutsLex) emitIfKeywordMatches() bool { @@ -89,19 +91,9 @@ func lexStart(l *GutsLex) stateFn { } l.backup() - // emit a newline (can be the end of block) - // l.emit(T_NEWLINE) - // c = l.peek() if c == eof { - // if we're in an indent block, and it's the end of file. - // we should treat the newline as a block end. - if l.space > 0 { - l.emit(T_OUTDENT) - } else { - l.ignore() - } - return nil + return lexStart } // reset space info @@ -119,8 +111,10 @@ func lexStart(l *GutsLex) stateFn { l.emit(T_NEWLINE) } else if l.space < l.lastSpace { l.emit(T_OUTDENT) - l.emit(T_NEWLINE) + l.emit(T_NEWLINE) // means end of statement + l.IndentLevel-- } else if l.space > l.lastSpace { + l.IndentLevel++ l.emit(T_INDENT) } return lexStart @@ -128,23 +122,24 @@ func lexStart(l *GutsLex) stateFn { return lexStart } else if l.emitIfMatch("==", T_EQUAL) || l.emitIfMatch(">=", T_GT_EQUAL) || l.emitIfMatch("<=", T_LT_EQUAL) { return lexStart - } else if c == '=' && l.peekMore(2) != '=' { - l.next() - l.emit(TokenType(c)) + } else if l.emitIfKeywordMatches() { return lexStart - } else if l.accept("+-*|&[]{}()<>,") { + } else if l.accept("+-*|&[]{}()<>,=@") { l.emit(TokenType(c)) return lexStart } else if l.lastTokenType == T_NUMBER && l.emitIfMatch("..", T_RANGE_OPERATOR) { return lexStart } else if c == '"' || c == '\'' { return lexString - } else if l.emitIfKeywordMatches() { - return lexStart } else if unicode.IsLetter(c) { return lexIdentifier } else if c == eof { - // l.emit(T_EOF) + if l.IndentLevel > 0 { + for i := 0; i < l.IndentLevel; i++ { + l.emit(T_OUTDENT) + l.emit(T_NEWLINE) + } + } return nil } else { panic(fmt.Errorf("unknown token %c\n", c)) @@ -230,7 +225,7 @@ func lexIgnoreSpaces(l *GutsLex) stateFn { c = l.next() if c == eof { l.ignore() - return nil + return lexStart } if c != ' ' { break @@ -257,8 +252,10 @@ func lexIndentSpaces(l *GutsLex) stateFn { } else if l.space < l.lastSpace { l.emit(T_OUTDENT) l.emit(T_NEWLINE) + l.IndentLevel-- } else if l.space > l.lastSpace { l.emit(T_INDENT) + l.IndentLevel++ } return lexStart } diff --git a/src/gutscript/parser.go b/src/gutscript/parser.go index 6071d26..2d5e7c7 100644 --- a/src/gutscript/parser.go +++ b/src/gutscript/parser.go @@ -146,7 +146,7 @@ const GutsEofCode = 1 const GutsErrCode = 2 const GutsMaxDepth = 200 -//line src/gutscript/parser.y:438 +//line src/gutscript/parser.y:502 /* start of programs */ //line yacctab:1 @@ -156,113 +156,119 @@ var GutsExca = []int{ -2, 0, } -const GutsNprod = 67 +const GutsNprod = 76 const GutsPrivate = 57344 var GutsTokenNames []string var GutsStates []string -const GutsLast = 257 +const GutsLast = 266 var GutsAct = []int{ - 7, 83, 72, 3, 6, 110, 111, 91, 70, 80, - 96, 86, 47, 4, 40, 76, 43, 44, 42, 36, - 37, 38, 48, 36, 37, 38, 95, 85, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 51, 98, 88, 46, 112, 77, 68, 39, 73, 101, - 41, 25, 24, 74, 64, 65, 47, 33, 84, 32, - 27, 28, 29, 30, 31, 78, 36, 37, 38, 14, - 79, 14, 45, 34, 35, 113, 26, 34, 35, 66, - 26, 26, 105, 92, 114, 93, 73, 84, 99, 36, - 37, 38, 106, 15, 94, 103, 89, 107, 108, 16, - 97, 50, 82, 49, 33, 109, 32, 27, 28, 29, - 30, 31, 90, 115, 36, 37, 38, 1, 2, 12, - 34, 35, 36, 37, 38, 10, 67, 33, 8, 32, - 27, 28, 29, 30, 31, 100, 102, 36, 37, 38, - 36, 37, 38, 34, 35, 87, 75, 41, 25, 24, - 11, 17, 33, 71, 32, 27, 28, 29, 30, 31, - 81, 69, 32, 27, 28, 29, 30, 31, 34, 35, - 9, 20, 19, 0, 0, 0, 34, 35, 27, 28, - 29, 30, 31, 29, 30, 31, 0, 18, 25, 24, - 15, 34, 35, 0, 34, 35, 16, 14, 0, 5, - 0, 0, 21, 0, 0, 104, 23, 18, 25, 24, - 0, 0, 0, 22, 0, 0, 0, 14, 0, 0, - 0, 13, 21, 0, 0, 0, 23, 0, 0, 0, - 15, 0, 0, 22, 0, 0, 16, 0, 0, 0, - 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 0, 0, 16, + 6, 8, 111, 84, 73, 98, 118, 5, 87, 128, + 117, 119, 93, 41, 4, 71, 44, 45, 48, 81, + 100, 97, 49, 47, 86, 36, 37, 38, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 52, 85, 77, 90, 47, 78, 69, 66, 74, + 120, 39, 40, 122, 36, 37, 38, 75, 48, 121, + 122, 67, 26, 33, 126, 32, 27, 28, 29, 30, + 31, 115, 94, 79, 46, 36, 37, 38, 14, 99, + 34, 35, 88, 80, 26, 103, 83, 74, 14, 95, + 107, 101, 124, 123, 108, 85, 96, 36, 37, 38, + 110, 109, 105, 91, 51, 116, 36, 37, 38, 34, + 35, 50, 92, 33, 114, 32, 27, 28, 29, 30, + 31, 125, 113, 1, 116, 127, 36, 37, 38, 129, + 34, 35, 2, 11, 68, 33, 9, 32, 27, 28, + 29, 30, 31, 7, 33, 3, 32, 27, 28, 29, + 30, 31, 34, 35, 36, 37, 38, 36, 37, 38, + 43, 34, 35, 112, 102, 104, 32, 27, 28, 29, + 30, 31, 42, 25, 24, 89, 42, 25, 24, 76, + 10, 34, 35, 17, 72, 82, 70, 20, 19, 0, + 0, 0, 0, 0, 0, 27, 28, 29, 30, 31, + 29, 30, 31, 0, 0, 0, 0, 0, 0, 34, + 35, 0, 34, 35, 0, 15, 18, 25, 24, 15, + 0, 16, 0, 0, 0, 16, 14, 0, 13, 0, + 106, 21, 0, 0, 0, 23, 0, 0, 0, 0, + 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 0, 0, 0, 0, 0, 15, + 0, 0, 0, 0, 0, 16, } var GutsPact = []int{ - 182, -1000, -1000, 64, -1000, -1000, -1000, 102, -1000, -1000, - 30, -1000, -1000, 45, 182, 45, 45, -1000, 8, -1000, - -1000, 45, 98, 96, -1000, -1000, 202, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 32, - 102, -36, 63, 77, 11, 45, -40, 45, 54, -19, - 24, -1000, 128, 128, 11, 11, 11, 125, 110, 102, - 102, 102, 102, 102, 45, 56, -1000, -1000, 102, -27, - 53, -38, -1000, 102, -1000, 9, 91, -55, 54, -1000, - 202, -39, -1000, -1000, 36, 45, -1000, 34, 90, -1000, - -1000, 142, -1000, -1000, -1000, 82, -1000, 45, -1000, -1000, - -1000, 182, -60, -1000, -1000, -57, 7, -1000, 102, 59, - 79, -1000, 45, -1000, -1000, 102, + 211, -1000, -1000, 67, -1000, -1000, 94, -1000, -1000, 29, + -1000, -1000, 171, -1000, 211, 171, 171, -1000, 10, -1000, + -1000, 171, 106, 99, -1000, -1000, 211, 171, 171, 171, + 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, + 73, 94, -30, 45, 85, 42, 171, -33, 171, 63, + 9, 25, -1000, 145, 145, 42, 42, 42, 142, 114, + 94, 94, 94, 94, 94, 63, 66, -1000, -1000, 94, + -17, 37, -41, -1000, 94, 65, 11, 98, -50, 55, + -1000, 211, -44, -1000, -1000, 15, 171, -1000, -1000, 70, + 97, -1000, -1000, 167, -1000, -1000, -1000, 90, -1000, 171, + -1000, -1000, -1000, 5, -59, -1000, -1000, -52, 13, -1000, + 94, 43, -1000, -1000, -1000, 88, -1000, -12, 87, -1000, + 171, 47, 5, -55, -1000, 94, -1000, 36, 171, 94, } var GutsPgo = []int{ - 0, 0, 172, 171, 13, 170, 161, 160, 1, 2, - 153, 151, 3, 150, 146, 145, 136, 135, 128, 125, - 119, 4, 118, 117, 112, 82, + 0, 0, 188, 187, 14, 1, 186, 185, 3, 4, + 184, 183, 145, 180, 179, 175, 165, 164, 163, 143, + 136, 133, 7, 132, 123, 122, 114, 2, 112, 90, } var GutsR1 = []int{ - 0, 23, 22, 21, 12, 12, 12, 4, 4, 4, - 4, 4, 4, 4, 4, 24, 24, 20, 19, 19, - 19, 18, 8, 8, 8, 7, 7, 6, 6, 6, - 5, 5, 13, 17, 17, 14, 14, 15, 15, 16, - 16, 25, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 3, 2, 9, 10, 10, 10, 11, + 0, 24, 23, 22, 12, 12, 12, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 28, 28, 21, 20, + 20, 20, 19, 8, 8, 8, 7, 7, 6, 6, + 6, 5, 5, 13, 17, 17, 14, 14, 15, 15, + 16, 16, 27, 27, 27, 18, 18, 25, 25, 26, + 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 2, 9, 10, 10, 10, 11, } var GutsR2 = []int{ - 0, 1, 1, 3, 3, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 2, 3, 4, 3, 5, - 4, 3, 3, 2, 1, 3, 1, 3, 2, 0, - 5, 5, 5, 3, 0, 2, 0, 2, 0, 3, - 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, - 1, 1, 1, 3, 1, 0, 4, + 0, 1, 1, 3, 3, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 1, 2, 3, 4, 4, + 5, 4, 3, 3, 2, 1, 3, 1, 3, 2, + 0, 5, 5, 5, 4, 0, 2, 0, 2, 0, + 3, 1, 3, 2, 1, 1, 1, 4, 2, 1, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, + 1, 1, 3, 1, 0, 4, } var GutsChk = []int{ - -1000, -23, -22, -12, -4, 17, -21, -1, -18, -5, - -19, -13, -20, 39, 15, 48, 54, -11, 5, -2, + -1000, -24, -23, -12, -4, -22, -1, -19, -5, -20, + -13, -21, 39, 17, 15, 48, 54, -11, 5, -2, -3, 20, 31, 24, 7, 6, 17, 53, 54, 55, - 56, 57, 52, 50, 66, 67, 12, 13, 14, 17, - -1, 5, -12, -1, -1, 64, 35, 48, -1, 5, - 5, -4, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 22, 23, 16, 49, -1, -6, - 48, -10, -9, -1, -21, -14, 34, 21, -1, -21, - 36, -7, 49, -8, 5, 65, 49, -15, 33, 5, - -24, 62, -21, -21, -4, 65, 49, 64, 5, -9, - -17, 15, -16, 5, 63, -25, -1, -8, -1, -12, - 65, 63, 37, 16, 5, -1, + 56, 57, 52, 50, 67, 68, 12, 13, 14, 22, + 23, -1, 5, -12, -1, -1, 64, 35, 48, -1, + 5, 5, -4, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -22, 16, 49, -1, + -6, 48, -10, -9, -1, -22, -14, 34, 21, -22, + 17, 36, -7, 49, -8, 5, 65, 49, 17, -15, + 33, 5, -28, 62, 17, -22, -4, 65, 49, 64, + 5, -9, -17, 15, -16, 5, 63, -29, -1, -8, + -1, -27, -18, -25, -26, 66, -5, 5, 65, 63, + 37, 16, 17, 5, 5, -1, 17, -27, 64, -1, } var GutsDef = []int{ - 0, -2, 1, 2, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 0, 0, 0, 0, 56, 57, 58, - 59, 0, 0, 0, 61, 60, 0, 0, 0, 0, + 0, -2, 1, 2, 6, 7, 8, 9, 10, 11, + 12, 13, 0, 15, 0, 0, 0, 65, 66, 67, + 68, 0, 0, 0, 70, 69, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14, 57, 0, 0, 55, 0, 29, 65, 0, 36, - 0, 4, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 0, 0, 3, 42, 21, 0, - 0, 0, 64, 62, 18, 38, 0, 0, 0, 20, - 0, 0, 28, 26, 24, 0, 66, 34, 0, 35, - 17, 0, 19, 7, 31, 0, 27, 0, 23, 63, - 32, 0, 37, 40, 15, 0, 0, 25, 22, 0, - 0, 16, 0, 33, 39, 41, + 0, 14, 66, 0, 0, 64, 0, 30, 74, 0, + 37, 0, 4, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 0, 0, 3, 51, 22, + 0, 0, 0, 73, 71, 0, 39, 0, 0, 0, + 21, 0, 0, 29, 27, 25, 0, 75, 19, 35, + 0, 36, 18, 0, 20, 7, 32, 0, 28, 0, + 24, 72, 33, 0, 38, 41, 16, 0, 0, 26, + 23, 0, 44, 45, 46, 0, 49, 0, 0, 17, + 0, 0, 43, 48, 40, 50, 34, 42, 0, 47, } var GutsTok1 = []int{ @@ -272,7 +278,7 @@ var GutsTok1 = []int{ 3, 3, 3, 58, 3, 3, 3, 57, 52, 3, 48, 49, 55, 53, 65, 54, 3, 56, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 67, 64, 66, 3, 3, 3, 3, 3, 3, 3, + 68, 64, 67, 3, 66, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 62, 3, 63, 51, 3, 3, 3, 3, 3, @@ -456,6 +462,7 @@ Gutsdefault: if GutsDebug >= 1 { __yyfmt__.Printf("%s", GutsStatname(Gutsstate)) __yyfmt__.Printf(" saw %s\n", GutsTokname(Gutschar)) + __yyfmt__.Printf(" Sym: %#v\n",GutsVAL) } fallthrough @@ -524,21 +531,21 @@ Gutsdefault: switch Gutsnt { case 1: - //line src/gutscript/parser.y:148 + //line src/gutscript/parser.y:150 { debug("end compilation", GutsS[Gutspt-0].val) GutsVAL.val = GutsS[Gutspt-0].val } case 2: - //line src/gutscript/parser.y:155 + //line src/gutscript/parser.y:157 { GutsVAL.val = GutsS[Gutspt-0].val } case 3: - //line src/gutscript/parser.y:161 + //line src/gutscript/parser.y:163 { GutsVAL.val = GutsS[Gutspt-1].val } case 4: - //line src/gutscript/parser.y:165 + //line src/gutscript/parser.y:167 { if stmts, ok := GutsS[Gutspt-2].val.(*ast.StatementList) ; ok { stmts.Append(GutsS[Gutspt-0].val) @@ -546,161 +553,227 @@ Gutsdefault: } } case 5: - //line src/gutscript/parser.y:172 + //line src/gutscript/parser.y:173 + { GutsVAL.val = GutsS[Gutspt-1].val } + case 6: + //line src/gutscript/parser.y:175 { stmts := ast.CreateStatementList() stmts.Append(GutsS[Gutspt-0].val) GutsVAL.val = stmts } - case 6: - //line src/gutscript/parser.y:177 - { } case 7: - //line src/gutscript/parser.y:181 + //line src/gutscript/parser.y:183 { GutsVAL.val = GutsS[Gutspt-0].val } case 8: - //line src/gutscript/parser.y:182 + //line src/gutscript/parser.y:184 { GutsVAL.val = ast.CreateExprStatement(GutsS[Gutspt-0].val) } case 9: - //line src/gutscript/parser.y:183 + //line src/gutscript/parser.y:185 { GutsVAL.val = GutsS[Gutspt-0].val } case 10: - //line src/gutscript/parser.y:184 + //line src/gutscript/parser.y:186 { GutsVAL.val = GutsS[Gutspt-0].val } case 11: - //line src/gutscript/parser.y:185 + //line src/gutscript/parser.y:187 { GutsVAL.val = GutsS[Gutspt-0].val } case 12: - //line src/gutscript/parser.y:186 + //line src/gutscript/parser.y:188 { GutsVAL.val = GutsS[Gutspt-0].val } case 13: - //line src/gutscript/parser.y:187 + //line src/gutscript/parser.y:189 { GutsVAL.val = GutsS[Gutspt-0].val } case 14: - //line src/gutscript/parser.y:188 + //line src/gutscript/parser.y:190 { GutsVAL.val = ast.CreateReturnStatement(GutsS[Gutspt-0].val) } - case 17: - //line src/gutscript/parser.y:197 + case 15: + //line src/gutscript/parser.y:191 { } case 18: - //line src/gutscript/parser.y:203 + //line src/gutscript/parser.y:200 + { } + case 19: + //line src/gutscript/parser.y:206 { - GutsVAL.val = ast.CreateIfStatement(GutsS[Gutspt-1].val.(ast.Expr), GutsS[Gutspt-0].val.(*ast.StatementList)) + GutsVAL.val = ast.CreateIfStatement(GutsS[Gutspt-2].val.(ast.Expr), GutsS[Gutspt-1].val.(*ast.StatementList)) } - case 19: - //line src/gutscript/parser.y:208 + case 20: + //line src/gutscript/parser.y:211 { - GutsS[Gutspt-4].val.(*ast.IfStatement).AddElseIf(GutsS[Gutspt-1].val.(ast.Expr),GutsS[Gutspt-0].val.(*ast.StatementList)) + GutsS[Gutspt-4].val.(*ast.IfStatement).AddElseIf(GutsS[Gutspt-2].val.(ast.Expr),GutsS[Gutspt-1].val.(*ast.StatementList)) GutsVAL.val = GutsS[Gutspt-4].val } - case 20: - //line src/gutscript/parser.y:214 + case 21: + //line src/gutscript/parser.y:217 { - GutsS[Gutspt-3].val.(*ast.IfStatement).SetElse(GutsS[Gutspt-0].val.(*ast.StatementList)) + GutsS[Gutspt-3].val.(*ast.IfStatement).SetElse(GutsS[Gutspt-1].val.(*ast.StatementList)) GutsVAL.val = GutsS[Gutspt-3].val } - case 21: - //line src/gutscript/parser.y:222 + case 22: + //line src/gutscript/parser.y:225 { debug("assignment", GutsS[Gutspt-2].val , "=" , GutsS[Gutspt-0].val) - GutsVAL.val = ast.CreateAssignStatement(ast.CreateVariable(GutsS[Gutspt-2].val.(string)), GutsS[Gutspt-0].val) + GutsVAL.val = ast.CreateAssignment(ast.CreateVariable(GutsS[Gutspt-2].val.(string)), GutsS[Gutspt-0].val) } - case 22: - //line src/gutscript/parser.y:230 + case 23: + //line src/gutscript/parser.y:233 { GutsVAL.val = ast.FunctionParam{GutsS[Gutspt-2].val.(string), "", GutsS[Gutspt-0].val} } - case 23: - //line src/gutscript/parser.y:234 + case 24: + //line src/gutscript/parser.y:237 { GutsVAL.val = ast.FunctionParam{GutsS[Gutspt-0].val.(string), GutsS[Gutspt-1].val.(string), nil} } - case 24: - //line src/gutscript/parser.y:238 + case 25: + //line src/gutscript/parser.y:241 { GutsVAL.val = ast.FunctionParam{GutsS[Gutspt-0].val.(string), "", nil} } - case 25: - //line src/gutscript/parser.y:244 + case 26: + //line src/gutscript/parser.y:247 { if params, ok := GutsS[Gutspt-2].val.([]ast.FunctionParam) ; ok { params = append(params, GutsS[Gutspt-0].val.(ast.FunctionParam)) GutsVAL.val = params } } - case 26: - //line src/gutscript/parser.y:250 + case 27: + //line src/gutscript/parser.y:253 { GutsVAL.val = []ast.FunctionParam{GutsS[Gutspt-0].val.(ast.FunctionParam)} } - case 27: - //line src/gutscript/parser.y:256 - { - GutsVAL.val = GutsS[Gutspt-1].val - } case 28: //line src/gutscript/parser.y:259 { - GutsVAL.val = []ast.FunctionParam{} + GutsVAL.val = GutsS[Gutspt-1].val } case 29: //line src/gutscript/parser.y:262 - { + { GutsVAL.val = []ast.FunctionParam{} } case 30: - //line src/gutscript/parser.y:269 + //line src/gutscript/parser.y:265 + { + GutsVAL.val = []ast.FunctionParam{} + } + case 31: + //line src/gutscript/parser.y:272 { debug("function declaration", GutsS[Gutspt-4].val, GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) GutsVAL.val = ast.CreateFunction(GutsS[Gutspt-4].val.(string), GutsS[Gutspt-2].val.([]ast.FunctionParam), GutsS[Gutspt-0].val.(*ast.StatementList)) } - case 31: - //line src/gutscript/parser.y:275 + case 32: + //line src/gutscript/parser.y:278 { var stmts = ast.StatementList{} stmts.Append(GutsS[Gutspt-0].val) GutsVAL.val = ast.CreateFunction(GutsS[Gutspt-4].val.(string), GutsS[Gutspt-2].val.([]ast.FunctionParam), &stmts) } - case 32: - //line src/gutscript/parser.y:284 - { - GutsVAL.val = ast.CreateClassStatement(GutsS[Gutspt-3].val.(string)) - // $2.(string) $3 (extend list) $4 (interface list) - } case 33: - //line src/gutscript/parser.y:292 - { - GutsVAL.val = GutsS[Gutspt-1].val + //line src/gutscript/parser.y:287 + { + // debug("class", $2, $3, $4) + var cls = ast.CreateClass(GutsS[Gutspt-3].val.(string)).(ast.Class) + + // decl extends + if GutsS[Gutspt-2].val != nil { + // debug("extends", $3) + cls.SetSuper(GutsS[Gutspt-2].val.(string)) + } + + // decl does + if GutsS[Gutspt-1].val != nil { + if infs, ok := GutsS[Gutspt-1].val.([]string) ; ok { + cls.SetInterfaces(infs) + } else { + panic(fmt.Errorf("Can not cast interface")) + } + } + + // class body + if GutsS[Gutspt-0].val != nil { + cls.Body = GutsS[Gutspt-0].val.(*ast.StatementList) + } + GutsVAL.val = cls + debug("class",GutsVAL.val) } case 34: - //line src/gutscript/parser.y:295 - { GutsVAL.val = nil } + //line src/gutscript/parser.y:317 + { + GutsVAL.val = GutsS[Gutspt-2].val + } case 35: - //line src/gutscript/parser.y:299 - { GutsVAL.val = GutsS[Gutspt-0].val } - case 36: - //line src/gutscript/parser.y:300 + //line src/gutscript/parser.y:320 { GutsVAL.val = nil } - case 37: - //line src/gutscript/parser.y:304 + case 36: + //line src/gutscript/parser.y:324 { GutsVAL.val = GutsS[Gutspt-0].val } - case 38: - //line src/gutscript/parser.y:305 + case 37: + //line src/gutscript/parser.y:325 { GutsVAL.val = nil } + case 38: + //line src/gutscript/parser.y:329 + { GutsVAL.val = GutsS[Gutspt-0].val } case 39: - //line src/gutscript/parser.y:310 + //line src/gutscript/parser.y:330 + { GutsVAL.val = nil } + case 40: + //line src/gutscript/parser.y:335 { var interfaceList = GutsS[Gutspt-2].val.([]string) interfaceList = append(interfaceList, GutsS[Gutspt-0].val.(string)) GutsVAL.val = interfaceList } - case 40: - //line src/gutscript/parser.y:316 + case 41: + //line src/gutscript/parser.y:341 { GutsVAL.val = []string{ GutsS[Gutspt-0].val.(string) } } case 42: - //line src/gutscript/parser.y:326 + //line src/gutscript/parser.y:348 + { + if stmts, ok := GutsS[Gutspt-2].val.(*ast.StatementList) ; ok { + stmts.Append(GutsS[Gutspt-0].val) + GutsVAL.val = GutsS[Gutspt-2].val + } + } + case 43: + //line src/gutscript/parser.y:355 + { + GutsVAL.val = GutsS[Gutspt-1].val + } + case 44: + //line src/gutscript/parser.y:359 + { + stmts := ast.CreateStatementList() + stmts.Append(GutsS[Gutspt-0].val) + GutsVAL.val = stmts + } + case 45: + //line src/gutscript/parser.y:367 + { GutsVAL.val = GutsS[Gutspt-0].val } + case 46: + //line src/gutscript/parser.y:368 + { GutsVAL.val = GutsS[Gutspt-0].val } + case 47: + //line src/gutscript/parser.y:373 + { + member := ast.CreateClassMember(GutsS[Gutspt-2].val.(string)) + member.SetValue(GutsS[Gutspt-0].val) + GutsVAL.val = member + } + case 48: + //line src/gutscript/parser.y:378 + { + GutsVAL.val = ast.CreateClassMember(GutsS[Gutspt-0].val.(string)) + } + case 49: + //line src/gutscript/parser.y:384 + { GutsVAL.val = GutsS[Gutspt-0].val } + case 51: + //line src/gutscript/parser.y:390 { if node, ok := GutsS[Gutspt-1].val.(ast.Expr) ; ok { node.Parenthesis = true @@ -710,128 +783,128 @@ Gutsdefault: } // $$ = $2 } - case 43: - //line src/gutscript/parser.y:336 + case 52: + //line src/gutscript/parser.y:400 { GutsVAL.val = ast.CreateExpr('+', GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 44: - //line src/gutscript/parser.y:340 + case 53: + //line src/gutscript/parser.y:404 { GutsVAL.val = ast.CreateExpr('-', GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 45: - //line src/gutscript/parser.y:344 + case 54: + //line src/gutscript/parser.y:408 { GutsVAL.val = ast.CreateExpr('*', GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 46: - //line src/gutscript/parser.y:348 + case 55: + //line src/gutscript/parser.y:412 { GutsVAL.val = ast.CreateExpr('/', GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 47: - //line src/gutscript/parser.y:352 + case 56: + //line src/gutscript/parser.y:416 { GutsVAL.val = ast.CreateExpr('%', GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 48: - //line src/gutscript/parser.y:356 + case 57: + //line src/gutscript/parser.y:420 { GutsVAL.val = ast.CreateExpr('&', GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 49: - //line src/gutscript/parser.y:360 + case 58: + //line src/gutscript/parser.y:424 { GutsVAL.val = ast.CreateExpr('|', GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 50: - //line src/gutscript/parser.y:364 + case 59: + //line src/gutscript/parser.y:428 { GutsVAL.val = ast.CreateExpr('>', GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 51: - //line src/gutscript/parser.y:368 + case 60: + //line src/gutscript/parser.y:432 { GutsVAL.val = ast.CreateExpr('<', GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 52: - //line src/gutscript/parser.y:372 + case 61: + //line src/gutscript/parser.y:436 { GutsVAL.val = ast.CreateExpr(T_EQUAL, GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 53: - //line src/gutscript/parser.y:376 + case 62: + //line src/gutscript/parser.y:440 { GutsVAL.val = ast.CreateExpr(T_LT_EQUAL, GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 54: - //line src/gutscript/parser.y:380 + case 63: + //line src/gutscript/parser.y:444 { GutsVAL.val = ast.CreateExpr(T_GT_EQUAL, GutsS[Gutspt-2].val, GutsS[Gutspt-0].val) } - case 55: - //line src/gutscript/parser.y:384 + case 64: + //line src/gutscript/parser.y:448 { GutsVAL.val = ast.UnaryExpr{'-', GutsS[Gutspt-0].val} } - case 56: - //line src/gutscript/parser.y:387 + case 65: + //line src/gutscript/parser.y:451 { GutsVAL.val = ast.UnaryExpr{0, GutsS[Gutspt-0].val} } - case 57: - //line src/gutscript/parser.y:390 + case 66: + //line src/gutscript/parser.y:454 { // $$ = ast.UnaryExpr{0, $1} GutsVAL.val = ast.CreateVariable(GutsS[Gutspt-0].val.(string)) } - case 58: - //line src/gutscript/parser.y:394 + case 67: + //line src/gutscript/parser.y:458 { GutsVAL.val = ast.UnaryExpr{0, GutsS[Gutspt-0].val} } - case 59: - //line src/gutscript/parser.y:397 + case 68: + //line src/gutscript/parser.y:461 { GutsVAL.val = ast.UnaryExpr{0, GutsS[Gutspt-0].val} } - case 60: - //line src/gutscript/parser.y:402 + case 69: + //line src/gutscript/parser.y:466 { GutsVAL.val = ast.CreateFloatingNumber(GutsS[Gutspt-0].val.(string)) } - case 61: - //line src/gutscript/parser.y:406 + case 70: + //line src/gutscript/parser.y:470 { GutsVAL.val = ast.CreateNumber(GutsS[Gutspt-0].val.(string)) } - case 62: - //line src/gutscript/parser.y:410 + case 71: + //line src/gutscript/parser.y:474 { GutsVAL.val = ast.UnaryExpr{0, GutsS[Gutspt-0].val} } - case 63: - //line src/gutscript/parser.y:415 + case 72: + //line src/gutscript/parser.y:479 { if params, ok := GutsS[Gutspt-2].val.([]ast.Node) ; ok { params = append(params, GutsS[Gutspt-0].val.(ast.Node)) GutsVAL.val = params } } - case 64: - //line src/gutscript/parser.y:422 + case 73: + //line src/gutscript/parser.y:486 { // create the expr list GutsVAL.val = []ast.Node{GutsS[Gutspt-0].val} } - case 65: - //line src/gutscript/parser.y:427 + case 74: + //line src/gutscript/parser.y:491 { GutsVAL.val = []ast.Node{} } - case 66: - //line src/gutscript/parser.y:433 + case 75: + //line src/gutscript/parser.y:497 { GutsVAL.val = ast.CreateFunctionCall(GutsS[Gutspt-3].val.(string), GutsS[Gutspt-1].val.([]ast.Node)) } diff --git a/src/gutscript/parser.y b/src/gutscript/parser.y index c17d2fb..88b4ec1 100644 --- a/src/gutscript/parser.y +++ b/src/gutscript/parser.y @@ -43,20 +43,23 @@ func debug(msg string, vals ...interface{}) { %type function_call %type statement_list -%type class_decl_statement +%type class %type class_decl_extends %type class_decl_does %type class_decl_does_list %type class_decl_block +%type class_decl_statement %type assignment -%type if_statement -%type class_decl_statement +%type if %type for_statement %type block %type top_statement_list %type start +%type class_decl_member +%type class_decl_method +%type class_decl_statement_list // same for terminals %token T_DOT T_IDENTIFIER T_FLOATING T_NUMBER T_STRING @@ -71,7 +74,6 @@ func debug(msg string, vals ...interface{}) { %token T_INDENT T_OUTDENT %token T_NEWLINE - %token T_NEW %token T_CLONE @@ -157,7 +159,7 @@ top_statement_list: statement_list } ; -// block is contains one or more statement +// block contains one or more statement block: T_INDENT statement_list T_OUTDENT { $$ = $2 } statement_list: @@ -168,13 +170,13 @@ statement_list: $$ = $1 } } + | statement_list T_NEWLINE { $$ = $1 } | statement { stmts := ast.CreateStatementList() stmts.Append($1) $$ = stmts } - | T_NEWLINE { } ; statement: @@ -182,10 +184,11 @@ statement: | expr { $$ = ast.CreateExprStatement($1) } | assignment { $$ = $1 } | function_decl_statement { $$ = $1 } - | if_statement { $$ = $1 } - | class_decl_statement { $$ = $1 } + | if { $$ = $1 } + | class { $$ = $1 } | for_statement { $$ = $1 } | T_RETURN expr { $$ = ast.CreateReturnStatement($2) } + | T_NEWLINE { } ; listop: @@ -198,21 +201,21 @@ for_statement: ; -if_statement: - T_IF expr block +if: + T_IF expr block T_NEWLINE { $$ = ast.CreateIfStatement($2.(ast.Expr), $3.(*ast.StatementList)) } | - if_statement T_NEWLINE T_ELSEIF expr block + if T_ELSEIF expr block T_NEWLINE { - $1.(*ast.IfStatement).AddElseIf($4.(ast.Expr),$5.(*ast.StatementList)) + $1.(*ast.IfStatement).AddElseIf($3.(ast.Expr),$4.(*ast.StatementList)) $$ = $1 } | - if_statement T_NEWLINE T_ELSE block + if T_ELSE block T_NEWLINE { - $1.(*ast.IfStatement).SetElse($4.(*ast.StatementList)) + $1.(*ast.IfStatement).SetElse($3.(*ast.StatementList)) $$ = $1 } ; @@ -221,7 +224,7 @@ assignment: T_IDENTIFIER '=' expr { debug("assignment", $1 , "=" , $3) - $$ = ast.CreateAssignStatement(ast.CreateVariable($1.(string)), $3) + $$ = ast.CreateAssignment(ast.CreateVariable($1.(string)), $3) } ; @@ -271,7 +274,7 @@ function_decl_statement: $$ = ast.CreateFunction($1.(string), $3.([]ast.FunctionParam), $5.(*ast.StatementList)) } - | T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH statement + | T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH statement { var stmts = ast.StatementList{} stmts.Append($5) @@ -279,21 +282,43 @@ function_decl_statement: } ; -class_decl_statement: +class: T_CLASS T_IDENTIFIER class_decl_extends class_decl_does class_decl_block - { - $$ = ast.CreateClassStatement($2.(string)) - // $2.(string) $3 (extend list) $4 (interface list) - } + { + // debug("class", $2, $3, $4) + var cls = ast.CreateClass($2.(string)).(ast.Class) + + // decl extends + if $3 != nil { + // debug("extends", $3) + cls.SetSuper($3.(string)) + } + + // decl does + if $4 != nil { + if infs, ok := $4.([]string) ; ok { + cls.SetInterfaces(infs) + } else { + panic(fmt.Errorf("Can not cast interface")) + } + } + + // class body + if $5 != nil { + cls.Body = $5.(*ast.StatementList) + } + $$ = cls + debug("class",$$) + } ; class_decl_block: - T_INDENT statement_list T_OUTDENT + T_INDENT class_decl_statement_list T_OUTDENT T_NEWLINE { $$ = $2 } | /* empty */ { $$ = nil } - + ; class_decl_extends: T_EXTENDS T_IDENTIFIER { $$ = $2 } @@ -318,7 +343,46 @@ class_decl_does_list: } ; +class_decl_statement_list: + class_decl_statement_list T_NEWLINE class_decl_statement_list + { + if stmts, ok := $1.(*ast.StatementList) ; ok { + stmts.Append($3) + $$ = $1 + } + } + | class_decl_statement_list T_NEWLINE + { + $$ = $1 + } + | class_decl_statement + { + stmts := ast.CreateStatementList() + stmts.Append($1) + $$ = stmts + } + ; + +class_decl_statement: + class_decl_member { $$ = $1 } + | class_decl_method { $$ = $1 } + ; + +class_decl_member: + '@' T_IDENTIFIER '=' expr + { + member := ast.CreateClassMember($2.(string)) + member.SetValue($4) + $$ = member + } + | '@' T_IDENTIFIER { + $$ = ast.CreateClassMember($2.(string)) + } + ; +class_decl_method: + function_decl_statement { $$ = $1 } + ; range: expr T_RANGE_OPERATOR expr ; diff --git a/src/gutscript/parser_test.go b/src/gutscript/parser_test.go index 88e564f..36a5988 100644 --- a/src/gutscript/parser_test.go +++ b/src/gutscript/parser_test.go @@ -15,44 +15,6 @@ b = a`, // XXX: need trailing line `x = 3 * -2`, - `if a > 10 - a = 10 -`, - `if a > 10 - a = 10 -else - a = 0 -`, - `if a > 10 - a = 10 - b = 20 -else - a = 0 - b = 0 -`, - // test if && single else if - `if a > 10 - a = 10 - b = 20 -elseif b > 10 - a = 1 - b = 1 -`, - // test if, elseif && else - `if a > 10 - a = 10 - b = 20 -elseif b > 10 - a = 1 - b = 1 -else - a = 0 - b = 0 -`, - `foo :: -> - a = 10 - return a -`, } func LexFile(srcFile string) (chan *GutsSymType, error) { @@ -85,15 +47,9 @@ func TestCompileFile(t *testing.T) { func TestParser(t *testing.T) { for i, input := range parserInputs { t.Logf("Testing test case %d: %s", i, input) - lexer := GutsLex{ - Input: input, - Start: 0, - Pos: 0, - Items: make(chan *GutsSymType, 100), - } - go lexer.run() + lexer := CreateLexer(input, 100) parser := GutsParser{} - if parser.Parse(&lexer) == 1 { + if parser.Parse(lexer) == 1 { t.Fatalf("syntax error: %s", input) } lexer.close() diff --git a/src/gutscript/tests/09_class_empty.guts b/src/gutscript/tests/09_class_empty.guts new file mode 100644 index 0000000..c389887 --- /dev/null +++ b/src/gutscript/tests/09_class_empty.guts @@ -0,0 +1 @@ +class Foo diff --git a/src/gutscript/tests/09_class_extends_does_empty.guts b/src/gutscript/tests/09_class_extends_does_empty.guts new file mode 100644 index 0000000..b8dc606 --- /dev/null +++ b/src/gutscript/tests/09_class_extends_does_empty.guts @@ -0,0 +1 @@ +class Foo extends Bar does Door, ArrayIterator diff --git a/src/gutscript/tests/09_class_emtpy.guts b/src/gutscript/tests/09_class_extends_empty.guts similarity index 100% rename from src/gutscript/tests/09_class_emtpy.guts rename to src/gutscript/tests/09_class_extends_empty.guts diff --git a/src/gutscript/tests/09_class_methods.guts b/src/gutscript/tests/09_class_methods.guts new file mode 100644 index 0000000..9a1e0e0 --- /dev/null +++ b/src/gutscript/tests/09_class_methods.guts @@ -0,0 +1,5 @@ +class Foo extends Bar + @a = 1 + @b = 2 + bar :: (a) -> + a * a diff --git a/src/gutscript/tests/09_class_properties.guts b/src/gutscript/tests/09_class_properties.guts index 1e0fb39..ae12f21 100644 --- a/src/gutscript/tests/09_class_properties.guts +++ b/src/gutscript/tests/09_class_properties.guts @@ -1,3 +1,3 @@ class Foo extends Bar - a = 1 - b = 2 + @a = 1 + @b = 2 diff --git a/src/yacc/yacc.go b/src/yacc/yacc.go index e92af25..8e84535 100644 --- a/src/yacc/yacc.go +++ b/src/yacc/yacc.go @@ -3388,6 +3388,7 @@ $$default: if $$Debug >= 1 { __yyfmt__.Printf("%s", $$Statname($$state)) __yyfmt__.Printf(" saw %s\n", $$Tokname($$char)) + __yyfmt__.Printf(" Sym: %#v\n",$$VAL) } fallthrough diff --git a/y.output b/y.output index 7f60119..f261dae 100644 --- a/y.output +++ b/y.output @@ -6,27 +6,27 @@ state 0 T_FLOATING shift 25 T_NUMBER shift 24 T_INDENT shift 14 - T_NEWLINE shift 5 + T_NEWLINE shift 13 T_IF shift 21 T_FOR shift 23 T_CLASS shift 22 - T_RETURN shift 13 + T_RETURN shift 12 ( shift 15 - shift 16 . error - expr goto 7 + expr goto 6 number goto 19 floating_number goto 20 statement goto 4 - function_decl_statement goto 9 + function_decl_statement goto 8 function_call goto 17 statement_list goto 3 - class_decl_statement goto 11 - assignment goto 8 - if_statement goto 10 - for_statement goto 12 - block goto 6 + class goto 10 + assignment goto 7 + if goto 9 + for_statement goto 11 + block goto 5 top_statement_list goto 2 start goto 1 @@ -40,36 +40,31 @@ state 1 state 2 start: top_statement_list. (1) - . reduce 1 (src line 148) + . reduce 1 (src line 150) state 3 top_statement_list: statement_list. (2) statement_list: statement_list.T_NEWLINE statement + statement_list: statement_list.T_NEWLINE T_NEWLINE shift 26 - . reduce 2 (src line 154) + . reduce 2 (src line 156) state 4 - statement_list: statement. (5) + statement_list: statement. (6) - . reduce 5 (src line 171) + . reduce 6 (src line 174) state 5 - statement_list: T_NEWLINE. (6) - - . reduce 6 (src line 177) - - -state 6 statement: block. (7) - . reduce 7 (src line 180) + . reduce 7 (src line 182) -state 7 +state 6 statement: expr. (8) expr: expr.+ expr expr: expr.- expr @@ -96,58 +91,64 @@ state 7 % shift 31 > shift 34 < shift 35 - . reduce 8 (src line 182) + . reduce 8 (src line 184) -state 8 +state 7 statement: assignment. (9) - . reduce 9 (src line 183) + . reduce 9 (src line 185) -state 9 +state 8 statement: function_decl_statement. (10) - . reduce 10 (src line 184) + . reduce 10 (src line 186) -10: shift/reduce conflict (shift 39(0), red'n 11(0)) on T_NEWLINE -state 10 - statement: if_statement. (11) - if_statement: if_statement.T_NEWLINE T_ELSEIF expr block - if_statement: if_statement.T_NEWLINE T_ELSE block +state 9 + statement: if. (11) + if: if.T_ELSEIF expr block T_NEWLINE + if: if.T_ELSE block T_NEWLINE - T_NEWLINE shift 39 - . reduce 11 (src line 185) + T_ELSEIF shift 39 + T_ELSE shift 40 + . reduce 11 (src line 187) -state 11 - statement: class_decl_statement. (12) +state 10 + statement: class. (12) - . reduce 12 (src line 186) + . reduce 12 (src line 188) -state 12 +state 11 statement: for_statement. (13) - . reduce 13 (src line 187) + . reduce 13 (src line 189) -state 13 +state 12 statement: T_RETURN.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 40 + expr goto 41 number goto 19 floating_number goto 20 function_call goto 17 +state 13 + statement: T_NEWLINE. (15) + + . reduce 15 (src line 191) + + state 14 block: T_INDENT.statement_list T_OUTDENT @@ -155,39 +156,39 @@ state 14 T_FLOATING shift 25 T_NUMBER shift 24 T_INDENT shift 14 - T_NEWLINE shift 5 + T_NEWLINE shift 13 T_IF shift 21 T_FOR shift 23 T_CLASS shift 22 - T_RETURN shift 13 + T_RETURN shift 12 ( shift 15 - shift 16 . error - expr goto 7 + expr goto 6 number goto 19 floating_number goto 20 statement goto 4 - function_decl_statement goto 9 + function_decl_statement goto 8 function_call goto 17 - statement_list goto 42 - class_decl_statement goto 11 - assignment goto 8 - if_statement goto 10 - for_statement goto 12 - block goto 6 + statement_list goto 43 + class goto 10 + assignment goto 7 + if goto 9 + for_statement goto 11 + block goto 5 state 15 expr: (.expr ) - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 43 + expr goto 44 number goto 19 floating_number goto 20 function_call goto 17 @@ -195,128 +196,131 @@ state 15 state 16 expr: -.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 44 + expr goto 45 number goto 19 floating_number goto 20 function_call goto 17 state 17 - expr: function_call. (56) + expr: function_call. (65) - . reduce 56 (src line 387) + . reduce 65 (src line 451) state 18 assignment: T_IDENTIFIER.= expr function_decl_statement: T_IDENTIFIER.T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH block function_decl_statement: T_IDENTIFIER.T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH statement - expr: T_IDENTIFIER. (57) + expr: T_IDENTIFIER. (66) function_call: T_IDENTIFIER.( function_call_parameter_list ) - T_FUNCTION_PROTOTYPE shift 46 - ( shift 47 - = shift 45 - . reduce 57 (src line 390) + T_FUNCTION_PROTOTYPE shift 47 + ( shift 48 + = shift 46 + . reduce 66 (src line 454) state 19 - expr: number. (58) + expr: number. (67) - . reduce 58 (src line 394) + . reduce 67 (src line 458) state 20 - expr: floating_number. (59) + expr: floating_number. (68) - . reduce 59 (src line 397) + . reduce 68 (src line 461) state 21 - if_statement: T_IF.expr block + if: T_IF.expr block T_NEWLINE - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 48 + expr goto 49 number goto 19 floating_number goto 20 function_call goto 17 state 22 - class_decl_statement: T_CLASS.T_IDENTIFIER class_decl_extends class_decl_does class_decl_block + class: T_CLASS.T_IDENTIFIER class_decl_extends class_decl_does class_decl_block - T_IDENTIFIER shift 49 + T_IDENTIFIER shift 50 . error state 23 for_statement: T_FOR.T_IDENTIFIER T_IN listop - T_IDENTIFIER shift 50 + T_IDENTIFIER shift 51 . error state 24 - number: T_NUMBER. (61) + number: T_NUMBER. (70) - . reduce 61 (src line 406) + . reduce 70 (src line 470) state 25 - floating_number: T_FLOATING. (60) + floating_number: T_FLOATING. (69) - . reduce 60 (src line 402) + . reduce 69 (src line 466) +26: shift/reduce conflict (shift 13(0), red'n 5(0)) on T_NEWLINE state 26 statement_list: statement_list T_NEWLINE.statement + statement_list: statement_list T_NEWLINE. (5) T_IDENTIFIER shift 18 T_FLOATING shift 25 T_NUMBER shift 24 T_INDENT shift 14 + T_NEWLINE shift 13 T_IF shift 21 T_FOR shift 23 T_CLASS shift 22 - T_RETURN shift 13 + T_RETURN shift 12 ( shift 15 - shift 16 - . error + . reduce 5 (src line 173) - expr goto 7 + expr goto 6 number goto 19 floating_number goto 20 - statement goto 51 - function_decl_statement goto 9 + statement goto 52 + function_decl_statement goto 8 function_call goto 17 - class_decl_statement goto 11 - assignment goto 8 - if_statement goto 10 - for_statement goto 12 - block goto 6 + class goto 10 + assignment goto 7 + if goto 9 + for_statement goto 11 + block goto 5 state 27 expr: expr +.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 52 + expr goto 53 number goto 19 floating_number goto 20 function_call goto 17 @@ -324,14 +328,14 @@ state 27 state 28 expr: expr -.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 53 + expr goto 54 number goto 19 floating_number goto 20 function_call goto 17 @@ -339,14 +343,14 @@ state 28 state 29 expr: expr *.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 54 + expr goto 55 number goto 19 floating_number goto 20 function_call goto 17 @@ -354,14 +358,14 @@ state 29 state 30 expr: expr /.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 55 + expr goto 56 number goto 19 floating_number goto 20 function_call goto 17 @@ -369,14 +373,14 @@ state 30 state 31 expr: expr %.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 56 + expr goto 57 number goto 19 floating_number goto 20 function_call goto 17 @@ -384,14 +388,14 @@ state 31 state 32 expr: expr &.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 57 + expr goto 58 number goto 19 floating_number goto 20 function_call goto 17 @@ -399,14 +403,14 @@ state 32 state 33 expr: expr |.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 58 + expr goto 59 number goto 19 floating_number goto 20 function_call goto 17 @@ -414,14 +418,14 @@ state 33 state 34 expr: expr >.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 59 + expr goto 60 number goto 19 floating_number goto 20 function_call goto 17 @@ -429,14 +433,14 @@ state 34 state 35 expr: expr <.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 60 + expr goto 61 number goto 19 floating_number goto 20 function_call goto 17 @@ -444,14 +448,14 @@ state 35 state 36 expr: expr T_EQUAL.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 61 + expr goto 62 number goto 19 floating_number goto 20 function_call goto 17 @@ -459,14 +463,14 @@ state 36 state 37 expr: expr T_LT_EQUAL.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 62 + expr goto 63 number goto 19 floating_number goto 20 function_call goto 17 @@ -474,28 +478,42 @@ state 37 state 38 expr: expr T_GT_EQUAL.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 63 + expr goto 64 number goto 19 floating_number goto 20 function_call goto 17 state 39 - if_statement: if_statement T_NEWLINE.T_ELSEIF expr block - if_statement: if_statement T_NEWLINE.T_ELSE block + if: if T_ELSEIF.expr block T_NEWLINE - T_ELSEIF shift 64 - T_ELSE shift 65 + T_IDENTIFIER shift 42 + T_FLOATING shift 25 + T_NUMBER shift 24 + ( shift 15 + - shift 16 . error + expr goto 65 + number goto 19 + floating_number goto 20 + function_call goto 17 state 40 + if: if T_ELSE.block T_NEWLINE + + T_INDENT shift 14 + . error + + block goto 66 + +state 41 statement: T_RETURN expr. (14) expr: expr.+ expr expr: expr.- expr @@ -522,27 +540,28 @@ state 40 % shift 31 > shift 34 < shift 35 - . reduce 14 (src line 188) + . reduce 14 (src line 190) -state 41 - expr: T_IDENTIFIER. (57) +state 42 + expr: T_IDENTIFIER. (66) function_call: T_IDENTIFIER.( function_call_parameter_list ) - ( shift 47 - . reduce 57 (src line 390) + ( shift 48 + . reduce 66 (src line 454) -state 42 +state 43 block: T_INDENT statement_list.T_OUTDENT statement_list: statement_list.T_NEWLINE statement + statement_list: statement_list.T_NEWLINE - T_OUTDENT shift 66 + T_OUTDENT shift 67 T_NEWLINE shift 26 . error -state 43 +state 44 expr: ( expr.) expr: expr.+ expr expr: expr.- expr @@ -560,7 +579,7 @@ state 43 T_EQUAL shift 36 T_LT_EQUAL shift 37 T_GT_EQUAL shift 38 - ) shift 67 + ) shift 68 | shift 33 & shift 32 + shift 27 @@ -573,12 +592,12 @@ state 43 . error -44: shift/reduce conflict (shift 36(0), red'n 55(11)) on T_EQUAL -44: shift/reduce conflict (shift 37(0), red'n 55(11)) on T_LT_EQUAL -44: shift/reduce conflict (shift 38(0), red'n 55(11)) on T_GT_EQUAL -44: shift/reduce conflict (shift 34(0), red'n 55(11)) on > -44: shift/reduce conflict (shift 35(0), red'n 55(11)) on < -state 44 +45: shift/reduce conflict (shift 36(0), red'n 64(11)) on T_EQUAL +45: shift/reduce conflict (shift 37(0), red'n 64(11)) on T_LT_EQUAL +45: shift/reduce conflict (shift 38(0), red'n 64(11)) on T_GT_EQUAL +45: shift/reduce conflict (shift 34(0), red'n 64(11)) on > +45: shift/reduce conflict (shift 35(0), red'n 64(11)) on < +state 45 expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -591,61 +610,61 @@ state 44 expr: expr.T_EQUAL expr expr: expr.T_LT_EQUAL expr expr: expr.T_GT_EQUAL expr - expr: - expr. (55) + expr: - expr. (64) T_EQUAL shift 36 T_LT_EQUAL shift 37 T_GT_EQUAL shift 38 > shift 34 < shift 35 - . reduce 55 (src line 383) + . reduce 64 (src line 447) -state 45 +state 46 assignment: T_IDENTIFIER =.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 68 + expr goto 69 number goto 19 floating_number goto 20 function_call goto 17 -state 46 +state 47 function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE.function_parameter_list T_FUNCTION_GLYPH block function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE.function_parameter_list T_FUNCTION_GLYPH statement - function_parameter_list: . (29) + function_parameter_list: . (30) - ( shift 70 - . reduce 29 (src line 262) + ( shift 71 + . reduce 30 (src line 265) - function_parameter_list goto 69 + function_parameter_list goto 70 -state 47 +state 48 function_call: T_IDENTIFIER (.function_call_parameter_list ) - function_call_parameter_list: . (65) + function_call_parameter_list: . (74) - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 - . reduce 65 (src line 426) + . reduce 74 (src line 490) - expr goto 73 + expr goto 74 number goto 19 floating_number goto 20 - function_call_parameter goto 72 - function_call_parameter_list goto 71 + function_call_parameter goto 73 + function_call_parameter_list goto 72 function_call goto 17 -state 48 - if_statement: T_IF expr.block +state 49 + if: T_IF expr.block T_NEWLINE expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -674,38 +693,38 @@ state 48 < shift 35 . error - block goto 74 + block goto 75 -state 49 - class_decl_statement: T_CLASS T_IDENTIFIER.class_decl_extends class_decl_does class_decl_block - class_decl_extends: . (36) +state 50 + class: T_CLASS T_IDENTIFIER.class_decl_extends class_decl_does class_decl_block + class_decl_extends: . (37) - T_EXTENDS shift 76 - . reduce 36 (src line 300) + T_EXTENDS shift 77 + . reduce 37 (src line 325) - class_decl_extends goto 75 + class_decl_extends goto 76 -state 50 +state 51 for_statement: T_FOR T_IDENTIFIER.T_IN listop - T_IN shift 77 + T_IN shift 78 . error -state 51 +state 52 statement_list: statement_list T_NEWLINE statement. (4) - . reduce 4 (src line 163) + . reduce 4 (src line 165) -52: shift/reduce conflict (shift 36(0), red'n 43(8)) on T_EQUAL -52: shift/reduce conflict (shift 37(0), red'n 43(8)) on T_LT_EQUAL -52: shift/reduce conflict (shift 38(0), red'n 43(8)) on T_GT_EQUAL -52: shift/reduce conflict (shift 34(0), red'n 43(8)) on > -52: shift/reduce conflict (shift 35(0), red'n 43(8)) on < -state 52 +53: shift/reduce conflict (shift 36(0), red'n 52(8)) on T_EQUAL +53: shift/reduce conflict (shift 37(0), red'n 52(8)) on T_LT_EQUAL +53: shift/reduce conflict (shift 38(0), red'n 52(8)) on T_GT_EQUAL +53: shift/reduce conflict (shift 34(0), red'n 52(8)) on > +53: shift/reduce conflict (shift 35(0), red'n 52(8)) on < +state 53 expr: expr.+ expr - expr: expr + expr. (43) + expr: expr + expr. (52) expr: expr.- expr expr: expr.* expr expr: expr./ expr @@ -726,18 +745,18 @@ state 52 % shift 31 > shift 34 < shift 35 - . reduce 43 (src line 335) + . reduce 52 (src line 399) -53: shift/reduce conflict (shift 36(0), red'n 44(8)) on T_EQUAL -53: shift/reduce conflict (shift 37(0), red'n 44(8)) on T_LT_EQUAL -53: shift/reduce conflict (shift 38(0), red'n 44(8)) on T_GT_EQUAL -53: shift/reduce conflict (shift 34(0), red'n 44(8)) on > -53: shift/reduce conflict (shift 35(0), red'n 44(8)) on < -state 53 +54: shift/reduce conflict (shift 36(0), red'n 53(8)) on T_EQUAL +54: shift/reduce conflict (shift 37(0), red'n 53(8)) on T_LT_EQUAL +54: shift/reduce conflict (shift 38(0), red'n 53(8)) on T_GT_EQUAL +54: shift/reduce conflict (shift 34(0), red'n 53(8)) on > +54: shift/reduce conflict (shift 35(0), red'n 53(8)) on < +state 54 expr: expr.+ expr expr: expr.- expr - expr: expr - expr. (44) + expr: expr - expr. (53) expr: expr.* expr expr: expr./ expr expr: expr.% expr @@ -757,19 +776,19 @@ state 53 % shift 31 > shift 34 < shift 35 - . reduce 44 (src line 339) + . reduce 53 (src line 403) -54: shift/reduce conflict (shift 36(0), red'n 45(9)) on T_EQUAL -54: shift/reduce conflict (shift 37(0), red'n 45(9)) on T_LT_EQUAL -54: shift/reduce conflict (shift 38(0), red'n 45(9)) on T_GT_EQUAL -54: shift/reduce conflict (shift 34(0), red'n 45(9)) on > -54: shift/reduce conflict (shift 35(0), red'n 45(9)) on < -state 54 +55: shift/reduce conflict (shift 36(0), red'n 54(9)) on T_EQUAL +55: shift/reduce conflict (shift 37(0), red'n 54(9)) on T_LT_EQUAL +55: shift/reduce conflict (shift 38(0), red'n 54(9)) on T_GT_EQUAL +55: shift/reduce conflict (shift 34(0), red'n 54(9)) on > +55: shift/reduce conflict (shift 35(0), red'n 54(9)) on < +state 55 expr: expr.+ expr expr: expr.- expr expr: expr.* expr - expr: expr * expr. (45) + expr: expr * expr. (54) expr: expr./ expr expr: expr.% expr expr: expr.& expr @@ -785,20 +804,20 @@ state 54 T_GT_EQUAL shift 38 > shift 34 < shift 35 - . reduce 45 (src line 343) + . reduce 54 (src line 407) -55: shift/reduce conflict (shift 36(0), red'n 46(9)) on T_EQUAL -55: shift/reduce conflict (shift 37(0), red'n 46(9)) on T_LT_EQUAL -55: shift/reduce conflict (shift 38(0), red'n 46(9)) on T_GT_EQUAL -55: shift/reduce conflict (shift 34(0), red'n 46(9)) on > -55: shift/reduce conflict (shift 35(0), red'n 46(9)) on < -state 55 +56: shift/reduce conflict (shift 36(0), red'n 55(9)) on T_EQUAL +56: shift/reduce conflict (shift 37(0), red'n 55(9)) on T_LT_EQUAL +56: shift/reduce conflict (shift 38(0), red'n 55(9)) on T_GT_EQUAL +56: shift/reduce conflict (shift 34(0), red'n 55(9)) on > +56: shift/reduce conflict (shift 35(0), red'n 55(9)) on < +state 56 expr: expr.+ expr expr: expr.- expr expr: expr.* expr expr: expr./ expr - expr: expr / expr. (46) + expr: expr / expr. (55) expr: expr.% expr expr: expr.& expr expr: expr.| expr @@ -813,21 +832,21 @@ state 55 T_GT_EQUAL shift 38 > shift 34 < shift 35 - . reduce 46 (src line 347) + . reduce 55 (src line 411) -56: shift/reduce conflict (shift 36(0), red'n 47(9)) on T_EQUAL -56: shift/reduce conflict (shift 37(0), red'n 47(9)) on T_LT_EQUAL -56: shift/reduce conflict (shift 38(0), red'n 47(9)) on T_GT_EQUAL -56: shift/reduce conflict (shift 34(0), red'n 47(9)) on > -56: shift/reduce conflict (shift 35(0), red'n 47(9)) on < -state 56 +57: shift/reduce conflict (shift 36(0), red'n 56(9)) on T_EQUAL +57: shift/reduce conflict (shift 37(0), red'n 56(9)) on T_LT_EQUAL +57: shift/reduce conflict (shift 38(0), red'n 56(9)) on T_GT_EQUAL +57: shift/reduce conflict (shift 34(0), red'n 56(9)) on > +57: shift/reduce conflict (shift 35(0), red'n 56(9)) on < +state 57 expr: expr.+ expr expr: expr.- expr expr: expr.* expr expr: expr./ expr expr: expr.% expr - expr: expr % expr. (47) + expr: expr % expr. (56) expr: expr.& expr expr: expr.| expr expr: expr.> expr @@ -841,22 +860,22 @@ state 56 T_GT_EQUAL shift 38 > shift 34 < shift 35 - . reduce 47 (src line 351) + . reduce 56 (src line 415) -57: shift/reduce conflict (shift 36(0), red'n 48(7)) on T_EQUAL -57: shift/reduce conflict (shift 37(0), red'n 48(7)) on T_LT_EQUAL -57: shift/reduce conflict (shift 38(0), red'n 48(7)) on T_GT_EQUAL -57: shift/reduce conflict (shift 34(0), red'n 48(7)) on > -57: shift/reduce conflict (shift 35(0), red'n 48(7)) on < -state 57 +58: shift/reduce conflict (shift 36(0), red'n 57(7)) on T_EQUAL +58: shift/reduce conflict (shift 37(0), red'n 57(7)) on T_LT_EQUAL +58: shift/reduce conflict (shift 38(0), red'n 57(7)) on T_GT_EQUAL +58: shift/reduce conflict (shift 34(0), red'n 57(7)) on > +58: shift/reduce conflict (shift 35(0), red'n 57(7)) on < +state 58 expr: expr.+ expr expr: expr.- expr expr: expr.* expr expr: expr./ expr expr: expr.% expr expr: expr.& expr - expr: expr & expr. (48) + expr: expr & expr. (57) expr: expr.| expr expr: expr.> expr expr: expr.< expr @@ -874,15 +893,15 @@ state 57 % shift 31 > shift 34 < shift 35 - . reduce 48 (src line 355) + . reduce 57 (src line 419) -58: shift/reduce conflict (shift 36(0), red'n 49(5)) on T_EQUAL -58: shift/reduce conflict (shift 37(0), red'n 49(5)) on T_LT_EQUAL -58: shift/reduce conflict (shift 38(0), red'n 49(5)) on T_GT_EQUAL -58: shift/reduce conflict (shift 34(0), red'n 49(5)) on > -58: shift/reduce conflict (shift 35(0), red'n 49(5)) on < -state 58 +59: shift/reduce conflict (shift 36(0), red'n 58(5)) on T_EQUAL +59: shift/reduce conflict (shift 37(0), red'n 58(5)) on T_LT_EQUAL +59: shift/reduce conflict (shift 38(0), red'n 58(5)) on T_GT_EQUAL +59: shift/reduce conflict (shift 34(0), red'n 58(5)) on > +59: shift/reduce conflict (shift 35(0), red'n 58(5)) on < +state 59 expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -890,7 +909,7 @@ state 58 expr: expr.% expr expr: expr.& expr expr: expr.| expr - expr: expr | expr. (49) + expr: expr | expr. (58) expr: expr.> expr expr: expr.< expr expr: expr.T_EQUAL expr @@ -908,22 +927,22 @@ state 58 % shift 31 > shift 34 < shift 35 - . reduce 49 (src line 359) - - -59: shift/reduce conflict (shift 36(0), red'n 50(0)) on T_EQUAL -59: shift/reduce conflict (shift 37(0), red'n 50(0)) on T_LT_EQUAL -59: shift/reduce conflict (shift 38(0), red'n 50(0)) on T_GT_EQUAL -59: shift/reduce conflict (shift 33(5), red'n 50(0)) on | -59: shift/reduce conflict (shift 32(7), red'n 50(0)) on & -59: shift/reduce conflict (shift 27(8), red'n 50(0)) on + -59: shift/reduce conflict (shift 28(8), red'n 50(0)) on - -59: shift/reduce conflict (shift 29(9), red'n 50(0)) on * -59: shift/reduce conflict (shift 30(9), red'n 50(0)) on / -59: shift/reduce conflict (shift 31(9), red'n 50(0)) on % -59: shift/reduce conflict (shift 34(0), red'n 50(0)) on > -59: shift/reduce conflict (shift 35(0), red'n 50(0)) on < -state 59 + . reduce 58 (src line 423) + + +60: shift/reduce conflict (shift 36(0), red'n 59(0)) on T_EQUAL +60: shift/reduce conflict (shift 37(0), red'n 59(0)) on T_LT_EQUAL +60: shift/reduce conflict (shift 38(0), red'n 59(0)) on T_GT_EQUAL +60: shift/reduce conflict (shift 33(5), red'n 59(0)) on | +60: shift/reduce conflict (shift 32(7), red'n 59(0)) on & +60: shift/reduce conflict (shift 27(8), red'n 59(0)) on + +60: shift/reduce conflict (shift 28(8), red'n 59(0)) on - +60: shift/reduce conflict (shift 29(9), red'n 59(0)) on * +60: shift/reduce conflict (shift 30(9), red'n 59(0)) on / +60: shift/reduce conflict (shift 31(9), red'n 59(0)) on % +60: shift/reduce conflict (shift 34(0), red'n 59(0)) on > +60: shift/reduce conflict (shift 35(0), red'n 59(0)) on < +state 60 expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -932,7 +951,7 @@ state 59 expr: expr.& expr expr: expr.| expr expr: expr.> expr - expr: expr > expr. (50) + expr: expr > expr. (59) expr: expr.< expr expr: expr.T_EQUAL expr expr: expr.T_LT_EQUAL expr @@ -950,22 +969,22 @@ state 59 % shift 31 > shift 34 < shift 35 - . reduce 50 (src line 363) - - -60: shift/reduce conflict (shift 36(0), red'n 51(0)) on T_EQUAL -60: shift/reduce conflict (shift 37(0), red'n 51(0)) on T_LT_EQUAL -60: shift/reduce conflict (shift 38(0), red'n 51(0)) on T_GT_EQUAL -60: shift/reduce conflict (shift 33(5), red'n 51(0)) on | -60: shift/reduce conflict (shift 32(7), red'n 51(0)) on & -60: shift/reduce conflict (shift 27(8), red'n 51(0)) on + -60: shift/reduce conflict (shift 28(8), red'n 51(0)) on - -60: shift/reduce conflict (shift 29(9), red'n 51(0)) on * -60: shift/reduce conflict (shift 30(9), red'n 51(0)) on / -60: shift/reduce conflict (shift 31(9), red'n 51(0)) on % -60: shift/reduce conflict (shift 34(0), red'n 51(0)) on > -60: shift/reduce conflict (shift 35(0), red'n 51(0)) on < -state 60 + . reduce 59 (src line 427) + + +61: shift/reduce conflict (shift 36(0), red'n 60(0)) on T_EQUAL +61: shift/reduce conflict (shift 37(0), red'n 60(0)) on T_LT_EQUAL +61: shift/reduce conflict (shift 38(0), red'n 60(0)) on T_GT_EQUAL +61: shift/reduce conflict (shift 33(5), red'n 60(0)) on | +61: shift/reduce conflict (shift 32(7), red'n 60(0)) on & +61: shift/reduce conflict (shift 27(8), red'n 60(0)) on + +61: shift/reduce conflict (shift 28(8), red'n 60(0)) on - +61: shift/reduce conflict (shift 29(9), red'n 60(0)) on * +61: shift/reduce conflict (shift 30(9), red'n 60(0)) on / +61: shift/reduce conflict (shift 31(9), red'n 60(0)) on % +61: shift/reduce conflict (shift 34(0), red'n 60(0)) on > +61: shift/reduce conflict (shift 35(0), red'n 60(0)) on < +state 61 expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -975,7 +994,7 @@ state 60 expr: expr.| expr expr: expr.> expr expr: expr.< expr - expr: expr < expr. (51) + expr: expr < expr. (60) expr: expr.T_EQUAL expr expr: expr.T_LT_EQUAL expr expr: expr.T_GT_EQUAL expr @@ -992,22 +1011,22 @@ state 60 % shift 31 > shift 34 < shift 35 - . reduce 51 (src line 367) - - -61: shift/reduce conflict (shift 36(0), red'n 52(0)) on T_EQUAL -61: shift/reduce conflict (shift 37(0), red'n 52(0)) on T_LT_EQUAL -61: shift/reduce conflict (shift 38(0), red'n 52(0)) on T_GT_EQUAL -61: shift/reduce conflict (shift 33(5), red'n 52(0)) on | -61: shift/reduce conflict (shift 32(7), red'n 52(0)) on & -61: shift/reduce conflict (shift 27(8), red'n 52(0)) on + -61: shift/reduce conflict (shift 28(8), red'n 52(0)) on - -61: shift/reduce conflict (shift 29(9), red'n 52(0)) on * -61: shift/reduce conflict (shift 30(9), red'n 52(0)) on / -61: shift/reduce conflict (shift 31(9), red'n 52(0)) on % -61: shift/reduce conflict (shift 34(0), red'n 52(0)) on > -61: shift/reduce conflict (shift 35(0), red'n 52(0)) on < -state 61 + . reduce 60 (src line 431) + + +62: shift/reduce conflict (shift 36(0), red'n 61(0)) on T_EQUAL +62: shift/reduce conflict (shift 37(0), red'n 61(0)) on T_LT_EQUAL +62: shift/reduce conflict (shift 38(0), red'n 61(0)) on T_GT_EQUAL +62: shift/reduce conflict (shift 33(5), red'n 61(0)) on | +62: shift/reduce conflict (shift 32(7), red'n 61(0)) on & +62: shift/reduce conflict (shift 27(8), red'n 61(0)) on + +62: shift/reduce conflict (shift 28(8), red'n 61(0)) on - +62: shift/reduce conflict (shift 29(9), red'n 61(0)) on * +62: shift/reduce conflict (shift 30(9), red'n 61(0)) on / +62: shift/reduce conflict (shift 31(9), red'n 61(0)) on % +62: shift/reduce conflict (shift 34(0), red'n 61(0)) on > +62: shift/reduce conflict (shift 35(0), red'n 61(0)) on < +state 62 expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -1018,7 +1037,7 @@ state 61 expr: expr.> expr expr: expr.< expr expr: expr.T_EQUAL expr - expr: expr T_EQUAL expr. (52) + expr: expr T_EQUAL expr. (61) expr: expr.T_LT_EQUAL expr expr: expr.T_GT_EQUAL expr @@ -1034,22 +1053,22 @@ state 61 % shift 31 > shift 34 < shift 35 - . reduce 52 (src line 371) - - -62: shift/reduce conflict (shift 36(0), red'n 53(0)) on T_EQUAL -62: shift/reduce conflict (shift 37(0), red'n 53(0)) on T_LT_EQUAL -62: shift/reduce conflict (shift 38(0), red'n 53(0)) on T_GT_EQUAL -62: shift/reduce conflict (shift 33(5), red'n 53(0)) on | -62: shift/reduce conflict (shift 32(7), red'n 53(0)) on & -62: shift/reduce conflict (shift 27(8), red'n 53(0)) on + -62: shift/reduce conflict (shift 28(8), red'n 53(0)) on - -62: shift/reduce conflict (shift 29(9), red'n 53(0)) on * -62: shift/reduce conflict (shift 30(9), red'n 53(0)) on / -62: shift/reduce conflict (shift 31(9), red'n 53(0)) on % -62: shift/reduce conflict (shift 34(0), red'n 53(0)) on > -62: shift/reduce conflict (shift 35(0), red'n 53(0)) on < -state 62 + . reduce 61 (src line 435) + + +63: shift/reduce conflict (shift 36(0), red'n 62(0)) on T_EQUAL +63: shift/reduce conflict (shift 37(0), red'n 62(0)) on T_LT_EQUAL +63: shift/reduce conflict (shift 38(0), red'n 62(0)) on T_GT_EQUAL +63: shift/reduce conflict (shift 33(5), red'n 62(0)) on | +63: shift/reduce conflict (shift 32(7), red'n 62(0)) on & +63: shift/reduce conflict (shift 27(8), red'n 62(0)) on + +63: shift/reduce conflict (shift 28(8), red'n 62(0)) on - +63: shift/reduce conflict (shift 29(9), red'n 62(0)) on * +63: shift/reduce conflict (shift 30(9), red'n 62(0)) on / +63: shift/reduce conflict (shift 31(9), red'n 62(0)) on % +63: shift/reduce conflict (shift 34(0), red'n 62(0)) on > +63: shift/reduce conflict (shift 35(0), red'n 62(0)) on < +state 63 expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -1061,7 +1080,7 @@ state 62 expr: expr.< expr expr: expr.T_EQUAL expr expr: expr.T_LT_EQUAL expr - expr: expr T_LT_EQUAL expr. (53) + expr: expr T_LT_EQUAL expr. (62) expr: expr.T_GT_EQUAL expr T_EQUAL shift 36 @@ -1076,22 +1095,22 @@ state 62 % shift 31 > shift 34 < shift 35 - . reduce 53 (src line 375) - - -63: shift/reduce conflict (shift 36(0), red'n 54(0)) on T_EQUAL -63: shift/reduce conflict (shift 37(0), red'n 54(0)) on T_LT_EQUAL -63: shift/reduce conflict (shift 38(0), red'n 54(0)) on T_GT_EQUAL -63: shift/reduce conflict (shift 33(5), red'n 54(0)) on | -63: shift/reduce conflict (shift 32(7), red'n 54(0)) on & -63: shift/reduce conflict (shift 27(8), red'n 54(0)) on + -63: shift/reduce conflict (shift 28(8), red'n 54(0)) on - -63: shift/reduce conflict (shift 29(9), red'n 54(0)) on * -63: shift/reduce conflict (shift 30(9), red'n 54(0)) on / -63: shift/reduce conflict (shift 31(9), red'n 54(0)) on % -63: shift/reduce conflict (shift 34(0), red'n 54(0)) on > -63: shift/reduce conflict (shift 35(0), red'n 54(0)) on < -state 63 + . reduce 62 (src line 439) + + +64: shift/reduce conflict (shift 36(0), red'n 63(0)) on T_EQUAL +64: shift/reduce conflict (shift 37(0), red'n 63(0)) on T_LT_EQUAL +64: shift/reduce conflict (shift 38(0), red'n 63(0)) on T_GT_EQUAL +64: shift/reduce conflict (shift 33(5), red'n 63(0)) on | +64: shift/reduce conflict (shift 32(7), red'n 63(0)) on & +64: shift/reduce conflict (shift 27(8), red'n 63(0)) on + +64: shift/reduce conflict (shift 28(8), red'n 63(0)) on - +64: shift/reduce conflict (shift 29(9), red'n 63(0)) on * +64: shift/reduce conflict (shift 30(9), red'n 63(0)) on / +64: shift/reduce conflict (shift 31(9), red'n 63(0)) on % +64: shift/reduce conflict (shift 34(0), red'n 63(0)) on > +64: shift/reduce conflict (shift 35(0), red'n 63(0)) on < +state 64 expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -1104,7 +1123,7 @@ state 63 expr: expr.T_EQUAL expr expr: expr.T_LT_EQUAL expr expr: expr.T_GT_EQUAL expr - expr: expr T_GT_EQUAL expr. (54) + expr: expr T_GT_EQUAL expr. (63) T_EQUAL shift 36 T_LT_EQUAL shift 37 @@ -1118,46 +1137,62 @@ state 63 % shift 31 > shift 34 < shift 35 - . reduce 54 (src line 379) - - -state 64 - if_statement: if_statement T_NEWLINE T_ELSEIF.expr block - - T_IDENTIFIER shift 41 - T_FLOATING shift 25 - T_NUMBER shift 24 - ( shift 15 - - shift 16 - . error + . reduce 63 (src line 443) - expr goto 78 - number goto 19 - floating_number goto 20 - function_call goto 17 state 65 - if_statement: if_statement T_NEWLINE T_ELSE.block + if: if T_ELSEIF expr.block T_NEWLINE + expr: expr.+ expr + expr: expr.- expr + expr: expr.* expr + expr: expr./ expr + expr: expr.% expr + expr: expr.& expr + expr: expr.| expr + expr: expr.> expr + expr: expr.< expr + expr: expr.T_EQUAL expr + expr: expr.T_LT_EQUAL expr + expr: expr.T_GT_EQUAL expr + T_EQUAL shift 36 + T_LT_EQUAL shift 37 + T_GT_EQUAL shift 38 T_INDENT shift 14 + | shift 33 + & shift 32 + + shift 27 + - shift 28 + * shift 29 + / shift 30 + % shift 31 + > shift 34 + < shift 35 . error block goto 79 state 66 - block: T_INDENT statement_list T_OUTDENT. (3) + if: if T_ELSE block.T_NEWLINE - . reduce 3 (src line 161) + T_NEWLINE shift 80 + . error state 67 - expr: ( expr ). (42) + block: T_INDENT statement_list T_OUTDENT. (3) - . reduce 42 (src line 325) + . reduce 3 (src line 163) state 68 - assignment: T_IDENTIFIER = expr. (21) + expr: ( expr ). (51) + + . reduce 51 (src line 389) + + +state 69 + assignment: T_IDENTIFIER = expr. (22) expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -1183,44 +1218,44 @@ state 68 % shift 31 > shift 34 < shift 35 - . reduce 21 (src line 220) + . reduce 22 (src line 223) -state 69 +state 70 function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list.T_FUNCTION_GLYPH block function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list.T_FUNCTION_GLYPH statement - T_FUNCTION_GLYPH shift 80 + T_FUNCTION_GLYPH shift 81 . error -state 70 +state 71 function_parameter_list: (.function_parameters ) function_parameter_list: (.) - T_IDENTIFIER shift 84 - ) shift 82 + T_IDENTIFIER shift 85 + ) shift 83 . error - function_parameters goto 81 - function_parameter goto 83 + function_parameters goto 82 + function_parameter goto 84 -state 71 +state 72 function_call_parameter_list: function_call_parameter_list., function_call_parameter function_call: T_IDENTIFIER ( function_call_parameter_list.) - ) shift 86 - , shift 85 + ) shift 87 + , shift 86 . error -state 72 - function_call_parameter_list: function_call_parameter. (64) +state 73 + function_call_parameter_list: function_call_parameter. (73) - . reduce 64 (src line 421) + . reduce 73 (src line 485) -state 73 +state 74 expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -1233,7 +1268,7 @@ state 73 expr: expr.T_EQUAL expr expr: expr.T_LT_EQUAL expr expr: expr.T_GT_EQUAL expr - function_call_parameter: expr. (62) + function_call_parameter: expr. (71) T_EQUAL shift 36 T_LT_EQUAL shift 37 @@ -1247,78 +1282,54 @@ state 73 % shift 31 > shift 34 < shift 35 - . reduce 62 (src line 410) - - -state 74 - if_statement: T_IF expr block. (18) - - . reduce 18 (src line 201) + . reduce 71 (src line 474) state 75 - class_decl_statement: T_CLASS T_IDENTIFIER class_decl_extends.class_decl_does class_decl_block - class_decl_does: . (38) + if: T_IF expr block.T_NEWLINE - T_DOES shift 88 - . reduce 38 (src line 305) + T_NEWLINE shift 88 + . error - class_decl_does goto 87 state 76 - class_decl_extends: T_EXTENDS.T_IDENTIFIER + class: T_CLASS T_IDENTIFIER class_decl_extends.class_decl_does class_decl_block + class_decl_does: . (39) - T_IDENTIFIER shift 89 - . error + T_DOES shift 90 + . reduce 39 (src line 330) + class_decl_does goto 89 state 77 - for_statement: T_FOR T_IDENTIFIER T_IN.listop + class_decl_extends: T_EXTENDS.T_IDENTIFIER - [ shift 91 + T_IDENTIFIER shift 91 . error - listop goto 90 state 78 - if_statement: if_statement T_NEWLINE T_ELSEIF expr.block - expr: expr.+ expr - expr: expr.- expr - expr: expr.* expr - expr: expr./ expr - expr: expr.% expr - expr: expr.& expr - expr: expr.| expr - expr: expr.> expr - expr: expr.< expr - expr: expr.T_EQUAL expr - expr: expr.T_LT_EQUAL expr - expr: expr.T_GT_EQUAL expr + for_statement: T_FOR T_IDENTIFIER T_IN.listop - T_EQUAL shift 36 - T_LT_EQUAL shift 37 - T_GT_EQUAL shift 38 - T_INDENT shift 14 - | shift 33 - & shift 32 - + shift 27 - - shift 28 - * shift 29 - / shift 30 - % shift 31 - > shift 34 - < shift 35 + [ shift 93 . error - block goto 92 + listop goto 92 state 79 - if_statement: if_statement T_NEWLINE T_ELSE block. (20) + if: if T_ELSEIF expr block.T_NEWLINE - . reduce 20 (src line 212) + T_NEWLINE shift 94 + . error state 80 + if: if T_ELSE block T_NEWLINE. (21) + + . reduce 21 (src line 215) + + +state 81 function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH.block function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH.statement @@ -1326,252 +1337,243 @@ state 80 T_FLOATING shift 25 T_NUMBER shift 24 T_INDENT shift 14 + T_NEWLINE shift 13 T_IF shift 21 T_FOR shift 23 T_CLASS shift 22 - T_RETURN shift 13 + T_RETURN shift 12 ( shift 15 - shift 16 . error - expr goto 7 + expr goto 6 number goto 19 floating_number goto 20 - statement goto 94 - function_decl_statement goto 9 + statement goto 96 + function_decl_statement goto 8 function_call goto 17 - class_decl_statement goto 11 - assignment goto 8 - if_statement goto 10 - for_statement goto 12 - block goto 93 + class goto 10 + assignment goto 7 + if goto 9 + for_statement goto 11 + block goto 95 -state 81 +state 82 function_parameters: function_parameters., function_parameter function_parameter_list: ( function_parameters.) - ) shift 96 - , shift 95 + ) shift 98 + , shift 97 . error -state 82 - function_parameter_list: ( ). (28) +state 83 + function_parameter_list: ( ). (29) - . reduce 28 (src line 259) + . reduce 29 (src line 262) -state 83 - function_parameters: function_parameter. (26) +state 84 + function_parameters: function_parameter. (27) - . reduce 26 (src line 250) + . reduce 27 (src line 253) -state 84 +state 85 function_parameter: T_IDENTIFIER.= expr function_parameter: T_IDENTIFIER.T_IDENTIFIER - function_parameter: T_IDENTIFIER. (24) + function_parameter: T_IDENTIFIER. (25) - T_IDENTIFIER shift 98 - = shift 97 - . reduce 24 (src line 237) + T_IDENTIFIER shift 100 + = shift 99 + . reduce 25 (src line 240) -state 85 +state 86 function_call_parameter_list: function_call_parameter_list ,.function_call_parameter - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 73 + expr goto 74 number goto 19 floating_number goto 20 - function_call_parameter goto 99 + function_call_parameter goto 101 function_call goto 17 -state 86 - function_call: T_IDENTIFIER ( function_call_parameter_list ). (66) - - . reduce 66 (src line 432) - - state 87 - class_decl_statement: T_CLASS T_IDENTIFIER class_decl_extends class_decl_does.class_decl_block - class_decl_block: . (34) + function_call: T_IDENTIFIER ( function_call_parameter_list ). (75) - T_INDENT shift 101 - . reduce 34 (src line 295) + . reduce 75 (src line 496) - class_decl_block goto 100 state 88 - class_decl_does: T_DOES.class_decl_does_list + if: T_IF expr block T_NEWLINE. (19) - T_IDENTIFIER shift 103 - . error + . reduce 19 (src line 204) - class_decl_does_list goto 102 state 89 - class_decl_extends: T_EXTENDS T_IDENTIFIER. (35) + class: T_CLASS T_IDENTIFIER class_decl_extends class_decl_does.class_decl_block + class_decl_block: . (35) - . reduce 35 (src line 298) + T_INDENT shift 103 + . reduce 35 (src line 320) + class_decl_block goto 102 state 90 - for_statement: T_FOR T_IDENTIFIER T_IN listop. (17) + class_decl_does: T_DOES.class_decl_does_list - . reduce 17 (src line 196) + T_IDENTIFIER shift 105 + . error + class_decl_does_list goto 104 state 91 + class_decl_extends: T_EXTENDS T_IDENTIFIER. (36) + + . reduce 36 (src line 323) + + +state 92 + for_statement: T_FOR T_IDENTIFIER T_IN listop. (18) + + . reduce 18 (src line 199) + + +state 93 listop: [.] listop: [.range ] - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 - ] shift 104 + ] shift 106 . error - expr goto 106 + expr goto 108 number goto 19 floating_number goto 20 function_call goto 17 - range goto 105 + range goto 107 -state 92 - if_statement: if_statement T_NEWLINE T_ELSEIF expr block. (19) +state 94 + if: if T_ELSEIF expr block T_NEWLINE. (20) - . reduce 19 (src line 206) + . reduce 20 (src line 209) - 93: reduce/reduce conflict (red'ns 7 and 30) on $end - 93: reduce/reduce conflict (red'ns 7 and 30) on T_OUTDENT - 93: reduce/reduce conflict (red'ns 7 and 30) on T_NEWLINE -state 93 + 95: reduce/reduce conflict (red'ns 7 and 31) on $end + 95: reduce/reduce conflict (red'ns 7 and 31) on T_OUTDENT + 95: reduce/reduce conflict (red'ns 7 and 31) on T_NEWLINE +state 95 statement: block. (7) - function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH block. (30) + function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH block. (31) - . reduce 7 (src line 180) + . reduce 7 (src line 182) -state 94 - function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH statement. (31) +state 96 + function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH statement. (32) - . reduce 31 (src line 274) + . reduce 32 (src line 277) -state 95 +state 97 function_parameters: function_parameters ,.function_parameter - T_IDENTIFIER shift 84 + T_IDENTIFIER shift 85 . error - function_parameter goto 107 + function_parameter goto 109 -state 96 - function_parameter_list: ( function_parameters ). (27) +state 98 + function_parameter_list: ( function_parameters ). (28) - . reduce 27 (src line 255) + . reduce 28 (src line 258) -state 97 +state 99 function_parameter: T_IDENTIFIER =.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 108 + expr goto 110 number goto 19 floating_number goto 20 function_call goto 17 -state 98 - function_parameter: T_IDENTIFIER T_IDENTIFIER. (23) +state 100 + function_parameter: T_IDENTIFIER T_IDENTIFIER. (24) - . reduce 23 (src line 233) + . reduce 24 (src line 236) -state 99 - function_call_parameter_list: function_call_parameter_list , function_call_parameter. (63) +state 101 + function_call_parameter_list: function_call_parameter_list , function_call_parameter. (72) - . reduce 63 (src line 414) + . reduce 72 (src line 478) -state 100 - class_decl_statement: T_CLASS T_IDENTIFIER class_decl_extends class_decl_does class_decl_block. (32) +state 102 + class: T_CLASS T_IDENTIFIER class_decl_extends class_decl_does class_decl_block. (33) - . reduce 32 (src line 282) + . reduce 33 (src line 285) -state 101 - class_decl_block: T_INDENT.statement_list T_OUTDENT +state 103 + class_decl_block: T_INDENT.class_decl_statement_list T_OUTDENT T_NEWLINE - T_IDENTIFIER shift 18 - T_FLOATING shift 25 - T_NUMBER shift 24 - T_INDENT shift 14 - T_NEWLINE shift 5 - T_IF shift 21 - T_FOR shift 23 - T_CLASS shift 22 - T_RETURN shift 13 - ( shift 15 - - shift 16 + T_IDENTIFIER shift 117 + @ shift 115 . error - expr goto 7 - number goto 19 - floating_number goto 20 - statement goto 4 - function_decl_statement goto 9 - function_call goto 17 - statement_list goto 109 - class_decl_statement goto 11 - assignment goto 8 - if_statement goto 10 - for_statement goto 12 - block goto 6 + function_decl_statement goto 116 + class_decl_statement goto 112 + class_decl_member goto 113 + class_decl_method goto 114 + class_decl_statement_list goto 111 -state 102 - class_decl_does: T_DOES class_decl_does_list. (37) +state 104 + class_decl_does: T_DOES class_decl_does_list. (38) class_decl_does_list: class_decl_does_list., T_IDENTIFIER - , shift 110 - . reduce 37 (src line 303) + , shift 118 + . reduce 38 (src line 328) -state 103 - class_decl_does_list: T_IDENTIFIER. (40) +state 105 + class_decl_does_list: T_IDENTIFIER. (41) - . reduce 40 (src line 315) + . reduce 41 (src line 340) -state 104 - listop: [ ]. (15) +state 106 + listop: [ ]. (16) - . reduce 15 (src line 191) + . reduce 16 (src line 194) -state 105 +state 107 listop: [ range.] - ] shift 111 + ] shift 119 . error -state 106 +state 108 range: expr.T_RANGE_OPERATOR expr expr: expr.+ expr expr: expr.- expr @@ -1589,7 +1591,7 @@ state 106 T_EQUAL shift 36 T_LT_EQUAL shift 37 T_GT_EQUAL shift 38 - T_RANGE_OPERATOR shift 112 + T_RANGE_OPERATOR shift 120 | shift 33 & shift 32 + shift 27 @@ -1602,14 +1604,14 @@ state 106 . error -state 107 - function_parameters: function_parameters , function_parameter. (25) +state 109 + function_parameters: function_parameters , function_parameter. (26) - . reduce 25 (src line 243) + . reduce 26 (src line 246) -state 108 - function_parameter: T_IDENTIFIER = expr. (22) +state 110 + function_parameter: T_IDENTIFIER = expr. (23) expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -1635,60 +1637,185 @@ state 108 % shift 31 > shift 34 < shift 35 - . reduce 22 (src line 229) + . reduce 23 (src line 232) -state 109 - statement_list: statement_list.T_NEWLINE statement - class_decl_block: T_INDENT statement_list.T_OUTDENT +state 111 + class_decl_block: T_INDENT class_decl_statement_list.T_OUTDENT T_NEWLINE + class_decl_statement_list: class_decl_statement_list.T_NEWLINE class_decl_statement_list + class_decl_statement_list: class_decl_statement_list.T_NEWLINE - T_OUTDENT shift 113 - T_NEWLINE shift 26 + T_OUTDENT shift 121 + T_NEWLINE shift 122 . error -state 110 +state 112 + class_decl_statement_list: class_decl_statement. (44) + + . reduce 44 (src line 358) + + +state 113 + class_decl_statement: class_decl_member. (45) + + . reduce 45 (src line 366) + + +state 114 + class_decl_statement: class_decl_method. (46) + + . reduce 46 (src line 368) + + +state 115 + class_decl_member: @.T_IDENTIFIER = expr + class_decl_member: @.T_IDENTIFIER + + T_IDENTIFIER shift 123 + . error + + +state 116 + class_decl_method: function_decl_statement. (49) + + . reduce 49 (src line 383) + + +state 117 + function_decl_statement: T_IDENTIFIER.T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH block + function_decl_statement: T_IDENTIFIER.T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH statement + + T_FUNCTION_PROTOTYPE shift 47 + . error + + +state 118 class_decl_does_list: class_decl_does_list ,.T_IDENTIFIER - T_IDENTIFIER shift 114 + T_IDENTIFIER shift 124 . error -state 111 - listop: [ range ]. (16) +state 119 + listop: [ range ]. (17) - . reduce 16 (src line 193) + . reduce 17 (src line 196) -state 112 +state 120 range: expr T_RANGE_OPERATOR.expr - T_IDENTIFIER shift 41 + T_IDENTIFIER shift 42 T_FLOATING shift 25 T_NUMBER shift 24 ( shift 15 - shift 16 . error - expr goto 115 + expr goto 125 number goto 19 floating_number goto 20 function_call goto 17 -state 113 - class_decl_block: T_INDENT statement_list T_OUTDENT. (33) +state 121 + class_decl_block: T_INDENT class_decl_statement_list T_OUTDENT.T_NEWLINE - . reduce 33 (src line 290) + T_NEWLINE shift 126 + . error -state 114 - class_decl_does_list: class_decl_does_list , T_IDENTIFIER. (39) +state 122 + class_decl_statement_list: class_decl_statement_list T_NEWLINE.class_decl_statement_list + class_decl_statement_list: class_decl_statement_list T_NEWLINE. (43) - . reduce 39 (src line 308) + T_IDENTIFIER shift 117 + @ shift 115 + . reduce 43 (src line 354) + function_decl_statement goto 116 + class_decl_statement goto 112 + class_decl_member goto 113 + class_decl_method goto 114 + class_decl_statement_list goto 127 -state 115 - range: expr T_RANGE_OPERATOR expr. (41) +state 123 + class_decl_member: @ T_IDENTIFIER.= expr + class_decl_member: @ T_IDENTIFIER. (48) + + = shift 128 + . reduce 48 (src line 378) + + +state 124 + class_decl_does_list: class_decl_does_list , T_IDENTIFIER. (40) + + . reduce 40 (src line 333) + + +state 125 + range: expr T_RANGE_OPERATOR expr. (50) + expr: expr.+ expr + expr: expr.- expr + expr: expr.* expr + expr: expr./ expr + expr: expr.% expr + expr: expr.& expr + expr: expr.| expr + expr: expr.> expr + expr: expr.< expr + expr: expr.T_EQUAL expr + expr: expr.T_LT_EQUAL expr + expr: expr.T_GT_EQUAL expr + + T_EQUAL shift 36 + T_LT_EQUAL shift 37 + T_GT_EQUAL shift 38 + | shift 33 + & shift 32 + + shift 27 + - shift 28 + * shift 29 + / shift 30 + % shift 31 + > shift 34 + < shift 35 + . reduce 50 (src line 387) + + +state 126 + class_decl_block: T_INDENT class_decl_statement_list T_OUTDENT T_NEWLINE. (34) + + . reduce 34 (src line 315) + + +127: shift/reduce conflict (shift 122(0), red'n 42(0)) on T_NEWLINE +state 127 + class_decl_statement_list: class_decl_statement_list.T_NEWLINE class_decl_statement_list + class_decl_statement_list: class_decl_statement_list T_NEWLINE class_decl_statement_list. (42) + class_decl_statement_list: class_decl_statement_list.T_NEWLINE + + T_NEWLINE shift 122 + . reduce 42 (src line 346) + + +state 128 + class_decl_member: @ T_IDENTIFIER =.expr + + T_IDENTIFIER shift 42 + T_FLOATING shift 25 + T_NUMBER shift 24 + ( shift 15 + - shift 16 + . error + + expr goto 129 + number goto 19 + floating_number goto 20 + function_call goto 17 + +state 129 + class_decl_member: @ T_IDENTIFIER = expr. (47) expr: expr.+ expr expr: expr.- expr expr: expr.* expr @@ -1714,19 +1841,19 @@ state 115 % shift 31 > shift 34 < shift 35 - . reduce 41 (src line 323) + . reduce 47 (src line 371) Rule not reduced: function_decl_statement: T_IDENTIFIER T_FUNCTION_PROTOTYPE function_parameter_list T_FUNCTION_GLYPH block -67 terminals, 26 nonterminals -67 grammar rules, 116/2000 states -101 shift/reduce, 3 reduce/reduce conflicts reported -75 working sets used -memory: parser 217/30000 -60 extra closures -446 shift entries, 1 exceptions -58 goto entries -110 entries saved by goto default -Optimizer space used: output 257/30000 -257 table entries, 46 zero -maximum spread: 67, maximum offset: 112 +68 terminals, 30 nonterminals +76 grammar rules, 130/2000 states +102 shift/reduce, 3 reduce/reduce conflicts reported +79 working sets used +memory: parser 219/30000 +61 extra closures +465 shift entries, 1 exceptions +65 goto entries +105 entries saved by goto default +Optimizer space used: output 266/30000 +266 table entries, 49 zero +maximum spread: 68, maximum offset: 128