Merge pull request #1068 from hashicorp/f-lang-math
Add math support to embedded interpolation language
This commit is contained in:
commit
d01c764966
|
@ -0,0 +1,43 @@
|
||||||
|
package ast
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Arithmetic represents a node where the result is arithmetic of
|
||||||
|
// two or more operands in the order given.
|
||||||
|
type Arithmetic struct {
|
||||||
|
Op ArithmeticOp
|
||||||
|
Exprs []Node
|
||||||
|
Posx Pos
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Arithmetic) Accept(v Visitor) Node {
|
||||||
|
for i, expr := range n.Exprs {
|
||||||
|
n.Exprs[i] = expr.Accept(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
return v(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Arithmetic) Pos() Pos {
|
||||||
|
return n.Posx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Arithmetic) GoString() string {
|
||||||
|
return fmt.Sprintf("*%#v", *n)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Arithmetic) String() string {
|
||||||
|
var b bytes.Buffer
|
||||||
|
for _, expr := range n.Exprs {
|
||||||
|
b.WriteString(fmt.Sprintf("%s", expr))
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Arithmetic) Type(Scope) (Type, error) {
|
||||||
|
return TypeInt, nil
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ast
|
||||||
|
|
||||||
|
// ArithmeticOp is the operation to use for the math.
|
||||||
|
type ArithmeticOp int
|
||||||
|
|
||||||
|
const (
|
||||||
|
ArithmeticOpInvalid ArithmeticOp = 0
|
||||||
|
ArithmeticOpAdd ArithmeticOp = iota
|
||||||
|
ArithmeticOpSub
|
||||||
|
ArithmeticOpMul
|
||||||
|
ArithmeticOpDiv
|
||||||
|
ArithmeticOpMod
|
||||||
|
)
|
|
@ -15,11 +15,109 @@ func registerBuiltins(scope *ast.BasicScope) *ast.BasicScope {
|
||||||
if scope.FuncMap == nil {
|
if scope.FuncMap == nil {
|
||||||
scope.FuncMap = make(map[string]ast.Function)
|
scope.FuncMap = make(map[string]ast.Function)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implicit conversions
|
||||||
|
scope.FuncMap["__builtin_FloatToInt"] = builtinFloatToInt()
|
||||||
|
scope.FuncMap["__builtin_FloatToString"] = builtinFloatToString()
|
||||||
|
scope.FuncMap["__builtin_IntToFloat"] = builtinIntToFloat()
|
||||||
scope.FuncMap["__builtin_IntToString"] = builtinIntToString()
|
scope.FuncMap["__builtin_IntToString"] = builtinIntToString()
|
||||||
scope.FuncMap["__builtin_StringToInt"] = builtinStringToInt()
|
scope.FuncMap["__builtin_StringToInt"] = builtinStringToInt()
|
||||||
|
|
||||||
|
// Math operations
|
||||||
|
scope.FuncMap["__builtin_IntMath"] = builtinIntMath()
|
||||||
|
scope.FuncMap["__builtin_FloatMath"] = builtinFloatMath()
|
||||||
return scope
|
return scope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func builtinFloatMath() ast.Function {
|
||||||
|
return ast.Function{
|
||||||
|
ArgTypes: []ast.Type{ast.TypeInt},
|
||||||
|
Variadic: true,
|
||||||
|
VariadicType: ast.TypeFloat,
|
||||||
|
ReturnType: ast.TypeFloat,
|
||||||
|
Callback: func(args []interface{}) (interface{}, error) {
|
||||||
|
op := args[0].(ast.ArithmeticOp)
|
||||||
|
result := args[1].(float64)
|
||||||
|
for _, raw := range args[2:] {
|
||||||
|
arg := raw.(float64)
|
||||||
|
switch op {
|
||||||
|
case ast.ArithmeticOpAdd:
|
||||||
|
result += arg
|
||||||
|
case ast.ArithmeticOpSub:
|
||||||
|
result -= arg
|
||||||
|
case ast.ArithmeticOpMul:
|
||||||
|
result *= arg
|
||||||
|
case ast.ArithmeticOpDiv:
|
||||||
|
result /= arg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func builtinIntMath() ast.Function {
|
||||||
|
return ast.Function{
|
||||||
|
ArgTypes: []ast.Type{ast.TypeInt},
|
||||||
|
Variadic: true,
|
||||||
|
VariadicType: ast.TypeInt,
|
||||||
|
ReturnType: ast.TypeInt,
|
||||||
|
Callback: func(args []interface{}) (interface{}, error) {
|
||||||
|
op := args[0].(ast.ArithmeticOp)
|
||||||
|
result := args[1].(int)
|
||||||
|
for _, raw := range args[2:] {
|
||||||
|
arg := raw.(int)
|
||||||
|
switch op {
|
||||||
|
case ast.ArithmeticOpAdd:
|
||||||
|
result += arg
|
||||||
|
case ast.ArithmeticOpSub:
|
||||||
|
result -= arg
|
||||||
|
case ast.ArithmeticOpMul:
|
||||||
|
result *= arg
|
||||||
|
case ast.ArithmeticOpDiv:
|
||||||
|
result /= arg
|
||||||
|
case ast.ArithmeticOpMod:
|
||||||
|
result = result % arg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func builtinFloatToInt() ast.Function {
|
||||||
|
return ast.Function{
|
||||||
|
ArgTypes: []ast.Type{ast.TypeFloat},
|
||||||
|
ReturnType: ast.TypeInt,
|
||||||
|
Callback: func(args []interface{}) (interface{}, error) {
|
||||||
|
return int(args[0].(float64)), nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func builtinFloatToString() ast.Function {
|
||||||
|
return ast.Function{
|
||||||
|
ArgTypes: []ast.Type{ast.TypeFloat},
|
||||||
|
ReturnType: ast.TypeString,
|
||||||
|
Callback: func(args []interface{}) (interface{}, error) {
|
||||||
|
return strconv.FormatFloat(
|
||||||
|
args[0].(float64), 'g', -1, 64), nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func builtinIntToFloat() ast.Function {
|
||||||
|
return ast.Function{
|
||||||
|
ArgTypes: []ast.Type{ast.TypeInt},
|
||||||
|
ReturnType: ast.TypeFloat,
|
||||||
|
Callback: func(args []interface{}) (interface{}, error) {
|
||||||
|
return float64(args[0].(int)), nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func builtinIntToString() ast.Function {
|
func builtinIntToString() ast.Function {
|
||||||
return ast.Function{
|
return ast.Function{
|
||||||
ArgTypes: []ast.Type{ast.TypeInt},
|
ArgTypes: []ast.Type{ast.TypeInt},
|
||||||
|
|
|
@ -55,6 +55,9 @@ func (v *TypeCheck) visit(raw ast.Node) ast.Node {
|
||||||
var result ast.Node
|
var result ast.Node
|
||||||
var err error
|
var err error
|
||||||
switch n := raw.(type) {
|
switch n := raw.(type) {
|
||||||
|
case *ast.Arithmetic:
|
||||||
|
tc := &typeCheckArithmetic{n}
|
||||||
|
result, err = tc.TypeCheck(v)
|
||||||
case *ast.Call:
|
case *ast.Call:
|
||||||
tc := &typeCheckCall{n}
|
tc := &typeCheckCall{n}
|
||||||
result, err = tc.TypeCheck(v)
|
result, err = tc.TypeCheck(v)
|
||||||
|
@ -70,7 +73,7 @@ func (v *TypeCheck) visit(raw ast.Node) ast.Node {
|
||||||
default:
|
default:
|
||||||
tc, ok := raw.(TypeCheckNode)
|
tc, ok := raw.(TypeCheckNode)
|
||||||
if !ok {
|
if !ok {
|
||||||
err = fmt.Errorf("unknown node: %#v", raw)
|
err = fmt.Errorf("unknown node for type check: %#v", raw)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +89,72 @@ func (v *TypeCheck) visit(raw ast.Node) ast.Node {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type typeCheckArithmetic struct {
|
||||||
|
n *ast.Arithmetic
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tc *typeCheckArithmetic) TypeCheck(v *TypeCheck) (ast.Node, error) {
|
||||||
|
// The arguments are on the stack in reverse order, so pop them off.
|
||||||
|
exprs := make([]ast.Type, len(tc.n.Exprs))
|
||||||
|
for i, _ := range tc.n.Exprs {
|
||||||
|
exprs[len(tc.n.Exprs)-1-i] = v.StackPop()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine the resulting type we want
|
||||||
|
mathFunc := "__builtin_IntMath"
|
||||||
|
mathType := ast.TypeInt
|
||||||
|
switch v := exprs[0]; v {
|
||||||
|
case ast.TypeInt:
|
||||||
|
mathFunc = "__builtin_IntMath"
|
||||||
|
mathType = v
|
||||||
|
case ast.TypeFloat:
|
||||||
|
mathFunc = "__builtin_FloatMath"
|
||||||
|
mathType = v
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf(
|
||||||
|
"Math operations can only be done with ints and floats, got %s",
|
||||||
|
v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the args
|
||||||
|
for i, arg := range exprs {
|
||||||
|
if arg != mathType {
|
||||||
|
cn := v.ImplicitConversion(exprs[i], mathType, tc.n.Exprs[i])
|
||||||
|
if cn != nil {
|
||||||
|
tc.n.Exprs[i] = cn
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, fmt.Errorf(
|
||||||
|
"operand %d should be %s, got %s",
|
||||||
|
i+1, mathType, arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modulo doesn't work for floats
|
||||||
|
if mathType == ast.TypeFloat && tc.n.Op == ast.ArithmeticOpMod {
|
||||||
|
return nil, fmt.Errorf("modulo cannot be used with floats")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return type
|
||||||
|
v.StackPush(mathType)
|
||||||
|
|
||||||
|
// Replace our node with a call to the proper function. This isn't
|
||||||
|
// type checked but we already verified types.
|
||||||
|
args := make([]ast.Node, len(tc.n.Exprs)+1)
|
||||||
|
args[0] = &ast.LiteralNode{
|
||||||
|
Value: tc.n.Op,
|
||||||
|
Typex: ast.TypeInt,
|
||||||
|
Posx: tc.n.Pos(),
|
||||||
|
}
|
||||||
|
copy(args[1:], tc.n.Exprs)
|
||||||
|
return &ast.Call{
|
||||||
|
Func: mathFunc,
|
||||||
|
Args: args,
|
||||||
|
Posx: tc.n.Pos(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
type typeCheckCall struct {
|
type typeCheckCall struct {
|
||||||
n *ast.Call
|
n *ast.Call
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,12 @@ func Eval(root ast.Node, config *EvalConfig) (interface{}, ast.Type, error) {
|
||||||
}
|
}
|
||||||
scope := registerBuiltins(config.GlobalScope)
|
scope := registerBuiltins(config.GlobalScope)
|
||||||
implicitMap := map[ast.Type]map[ast.Type]string{
|
implicitMap := map[ast.Type]map[ast.Type]string{
|
||||||
|
ast.TypeFloat: {
|
||||||
|
ast.TypeInt: "__builtin_FloatToInt",
|
||||||
|
ast.TypeString: "__builtin_FloatToString",
|
||||||
|
},
|
||||||
ast.TypeInt: {
|
ast.TypeInt: {
|
||||||
|
ast.TypeFloat: "__builtin_IntToFloat",
|
||||||
ast.TypeString: "__builtin_IntToString",
|
ast.TypeString: "__builtin_IntToString",
|
||||||
},
|
},
|
||||||
ast.TypeString: {
|
ast.TypeString: {
|
||||||
|
@ -47,7 +52,8 @@ func Eval(root ast.Node, config *EvalConfig) (interface{}, ast.Type, error) {
|
||||||
// Build up the semantic checks for execution
|
// Build up the semantic checks for execution
|
||||||
checks := make(
|
checks := make(
|
||||||
[]SemanticChecker,
|
[]SemanticChecker,
|
||||||
len(config.SemanticChecks), len(config.SemanticChecks)+2)
|
len(config.SemanticChecks),
|
||||||
|
len(config.SemanticChecks)+2)
|
||||||
copy(checks, config.SemanticChecks)
|
copy(checks, config.SemanticChecks)
|
||||||
checks = append(checks, ic.Visit)
|
checks = append(checks, ic.Visit)
|
||||||
checks = append(checks, tv.Visit)
|
checks = append(checks, tv.Visit)
|
||||||
|
|
|
@ -39,6 +39,101 @@ func TestEval(t *testing.T) {
|
||||||
ast.TypeString,
|
ast.TypeString,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42+1}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 43",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42-1}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 41",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42*2}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 84",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42/2}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 21",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42%4}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 2",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42.0+1.0}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 43",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42.0+1}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 43",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42+1.0}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 43",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42+2*2}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 88",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42+(2*2)}",
|
||||||
|
nil,
|
||||||
|
false,
|
||||||
|
"foo 46",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${bar+1}",
|
||||||
|
&ast.BasicScope{
|
||||||
|
VarMap: map[string]ast.Variable{
|
||||||
|
"bar": ast.Variable{
|
||||||
|
Value: 41,
|
||||||
|
Type: ast.TypeInt,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
"foo 42",
|
||||||
|
ast.TypeString,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"foo ${rand()}",
|
"foo ${rand()}",
|
||||||
&ast.BasicScope{
|
&ast.BasicScope{
|
||||||
|
|
|
@ -22,11 +22,13 @@ import (
|
||||||
%token <str> PROGRAM_STRING_START PROGRAM_STRING_END
|
%token <str> PROGRAM_STRING_START PROGRAM_STRING_END
|
||||||
%token <str> PAREN_LEFT PAREN_RIGHT COMMA
|
%token <str> PAREN_LEFT PAREN_RIGHT COMMA
|
||||||
|
|
||||||
%token <token> IDENTIFIER INTEGER FLOAT STRING
|
%token <token> ARITH_OP IDENTIFIER INTEGER FLOAT STRING
|
||||||
|
|
||||||
%type <node> expr interpolation literal literalModeTop literalModeValue
|
%type <node> expr interpolation literal literalModeTop literalModeValue
|
||||||
%type <nodeList> args
|
%type <nodeList> args
|
||||||
|
|
||||||
|
%left ARITH_OP
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
top:
|
top:
|
||||||
|
@ -96,7 +98,11 @@ interpolation:
|
||||||
}
|
}
|
||||||
|
|
||||||
expr:
|
expr:
|
||||||
literalModeTop
|
PAREN_LEFT expr PAREN_RIGHT
|
||||||
|
{
|
||||||
|
$$ = $2
|
||||||
|
}
|
||||||
|
| literalModeTop
|
||||||
{
|
{
|
||||||
$$ = $1
|
$$ = $1
|
||||||
}
|
}
|
||||||
|
@ -116,6 +122,14 @@ expr:
|
||||||
Posx: $1.Pos,
|
Posx: $1.Pos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
| expr ARITH_OP expr
|
||||||
|
{
|
||||||
|
$$ = &ast.Arithmetic{
|
||||||
|
Op: $2.Value.(ast.ArithmeticOp),
|
||||||
|
Exprs: []ast.Node{$1, $3},
|
||||||
|
Posx: $1.Pos(),
|
||||||
|
}
|
||||||
|
}
|
||||||
| IDENTIFIER
|
| IDENTIFIER
|
||||||
{
|
{
|
||||||
$$ = &ast.VariableAccess{Name: $1.Value.(string), Posx: $1.Pos}
|
$$ = &ast.VariableAccess{Name: $1.Value.(string), Posx: $1.Pos}
|
||||||
|
|
|
@ -168,6 +168,21 @@ func (x *parserLex) lexModeInterpolation(yylval *parserSymType) int {
|
||||||
return PAREN_RIGHT
|
return PAREN_RIGHT
|
||||||
case ',':
|
case ',':
|
||||||
return COMMA
|
return COMMA
|
||||||
|
case '+':
|
||||||
|
yylval.token = &parserToken{Value: ast.ArithmeticOpAdd}
|
||||||
|
return ARITH_OP
|
||||||
|
case '-':
|
||||||
|
yylval.token = &parserToken{Value: ast.ArithmeticOpSub}
|
||||||
|
return ARITH_OP
|
||||||
|
case '*':
|
||||||
|
yylval.token = &parserToken{Value: ast.ArithmeticOpMul}
|
||||||
|
return ARITH_OP
|
||||||
|
case '/':
|
||||||
|
yylval.token = &parserToken{Value: ast.ArithmeticOpDiv}
|
||||||
|
return ARITH_OP
|
||||||
|
case '%':
|
||||||
|
yylval.token = &parserToken{Value: ast.ArithmeticOpMod}
|
||||||
|
return ARITH_OP
|
||||||
default:
|
default:
|
||||||
x.backup()
|
x.backup()
|
||||||
return x.lexId(yylval)
|
return x.lexId(yylval)
|
||||||
|
|
|
@ -63,6 +63,15 @@ func TestLex(t *testing.T) {
|
||||||
PROGRAM_BRACKET_RIGHT, lexEOF},
|
PROGRAM_BRACKET_RIGHT, lexEOF},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"${bar(42+1)}",
|
||||||
|
[]int{PROGRAM_BRACKET_LEFT,
|
||||||
|
IDENTIFIER, PAREN_LEFT,
|
||||||
|
INTEGER, ARITH_OP, INTEGER,
|
||||||
|
PAREN_RIGHT,
|
||||||
|
PROGRAM_BRACKET_RIGHT, lexEOF},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"${bar(3.14159)}",
|
"${bar(3.14159)}",
|
||||||
[]int{PROGRAM_BRACKET_LEFT,
|
[]int{PROGRAM_BRACKET_LEFT,
|
||||||
|
|
|
@ -152,6 +152,37 @@ func TestParse(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"foo ${42+1}",
|
||||||
|
false,
|
||||||
|
&ast.Concat{
|
||||||
|
Posx: ast.Pos{Column: 1, Line: 1},
|
||||||
|
Exprs: []ast.Node{
|
||||||
|
&ast.LiteralNode{
|
||||||
|
Value: "foo ",
|
||||||
|
Typex: ast.TypeString,
|
||||||
|
Posx: ast.Pos{Column: 1, Line: 1},
|
||||||
|
},
|
||||||
|
&ast.Arithmetic{
|
||||||
|
Op: ast.ArithmeticOpAdd,
|
||||||
|
Exprs: []ast.Node{
|
||||||
|
&ast.LiteralNode{
|
||||||
|
Value: 42,
|
||||||
|
Typex: ast.TypeInt,
|
||||||
|
Posx: ast.Pos{Column: 7, Line: 1},
|
||||||
|
},
|
||||||
|
&ast.LiteralNode{
|
||||||
|
Value: 1,
|
||||||
|
Typex: ast.TypeInt,
|
||||||
|
Posx: ast.Pos{Column: 10, Line: 1},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Posx: ast.Pos{Column: 7, Line: 1},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"${foo()}",
|
"${foo()}",
|
||||||
false,
|
false,
|
||||||
|
|
112
config/lang/y.go
112
config/lang/y.go
|
@ -24,10 +24,11 @@ const PROGRAM_STRING_END = 57349
|
||||||
const PAREN_LEFT = 57350
|
const PAREN_LEFT = 57350
|
||||||
const PAREN_RIGHT = 57351
|
const PAREN_RIGHT = 57351
|
||||||
const COMMA = 57352
|
const COMMA = 57352
|
||||||
const IDENTIFIER = 57353
|
const ARITH_OP = 57353
|
||||||
const INTEGER = 57354
|
const IDENTIFIER = 57354
|
||||||
const FLOAT = 57355
|
const INTEGER = 57355
|
||||||
const STRING = 57356
|
const FLOAT = 57356
|
||||||
|
const STRING = 57357
|
||||||
|
|
||||||
var parserToknames = []string{
|
var parserToknames = []string{
|
||||||
"PROGRAM_BRACKET_LEFT",
|
"PROGRAM_BRACKET_LEFT",
|
||||||
|
@ -37,6 +38,7 @@ var parserToknames = []string{
|
||||||
"PAREN_LEFT",
|
"PAREN_LEFT",
|
||||||
"PAREN_RIGHT",
|
"PAREN_RIGHT",
|
||||||
"COMMA",
|
"COMMA",
|
||||||
|
"ARITH_OP",
|
||||||
"IDENTIFIER",
|
"IDENTIFIER",
|
||||||
"INTEGER",
|
"INTEGER",
|
||||||
"FLOAT",
|
"FLOAT",
|
||||||
|
@ -48,7 +50,7 @@ const parserEofCode = 1
|
||||||
const parserErrCode = 2
|
const parserErrCode = 2
|
||||||
const parserMaxDepth = 200
|
const parserMaxDepth = 200
|
||||||
|
|
||||||
//line lang.y:151
|
//line lang.y:165
|
||||||
|
|
||||||
//line yacctab:1
|
//line yacctab:1
|
||||||
var parserExca = []int{
|
var parserExca = []int{
|
||||||
|
@ -57,51 +59,51 @@ var parserExca = []int{
|
||||||
-2, 0,
|
-2, 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
const parserNprod = 17
|
const parserNprod = 19
|
||||||
const parserPrivate = 57344
|
const parserPrivate = 57344
|
||||||
|
|
||||||
var parserTokenNames []string
|
var parserTokenNames []string
|
||||||
var parserStates []string
|
var parserStates []string
|
||||||
|
|
||||||
const parserLast = 23
|
const parserLast = 30
|
||||||
|
|
||||||
var parserAct = []int{
|
var parserAct = []int{
|
||||||
|
|
||||||
9, 7, 7, 3, 18, 19, 8, 15, 13, 11,
|
9, 20, 16, 16, 7, 7, 3, 18, 10, 8,
|
||||||
12, 6, 6, 14, 8, 1, 17, 10, 2, 16,
|
1, 17, 14, 12, 13, 6, 6, 19, 8, 22,
|
||||||
20, 4, 5,
|
15, 23, 24, 11, 2, 25, 16, 21, 4, 5,
|
||||||
}
|
}
|
||||||
var parserPact = []int{
|
var parserPact = []int{
|
||||||
|
|
||||||
-2, -1000, -2, -1000, -1000, -1000, -1000, -3, -1000, 8,
|
1, -1000, 1, -1000, -1000, -1000, -1000, 0, -1000, 15,
|
||||||
-2, -1000, -1000, -1, -1000, -3, -5, -1000, -1000, -3,
|
0, 1, -1000, -1000, -1, -1000, 0, -8, 0, -1000,
|
||||||
-1000,
|
-1000, 12, -9, -1000, 0, -9,
|
||||||
}
|
}
|
||||||
var parserPgo = []int{
|
var parserPgo = []int{
|
||||||
|
|
||||||
0, 0, 22, 21, 17, 3, 19, 15,
|
0, 0, 29, 28, 23, 6, 27, 10,
|
||||||
}
|
}
|
||||||
var parserR1 = []int{
|
var parserR1 = []int{
|
||||||
|
|
||||||
0, 7, 7, 4, 4, 5, 5, 2, 1, 1,
|
0, 7, 7, 4, 4, 5, 5, 2, 1, 1,
|
||||||
1, 1, 1, 6, 6, 6, 3,
|
1, 1, 1, 1, 1, 6, 6, 6, 3,
|
||||||
}
|
}
|
||||||
var parserR2 = []int{
|
var parserR2 = []int{
|
||||||
|
|
||||||
0, 0, 1, 1, 2, 1, 1, 3, 1, 1,
|
0, 0, 1, 1, 2, 1, 1, 3, 3, 1,
|
||||||
1, 1, 4, 0, 3, 1, 1,
|
1, 1, 3, 1, 4, 0, 3, 1, 1,
|
||||||
}
|
}
|
||||||
var parserChk = []int{
|
var parserChk = []int{
|
||||||
|
|
||||||
-1000, -7, -4, -5, -3, -2, 14, 4, -5, -1,
|
-1000, -7, -4, -5, -3, -2, 15, 4, -5, -1,
|
||||||
-4, 12, 13, 11, 5, 8, -6, -1, 9, 10,
|
8, -4, 13, 14, 12, 5, 11, -1, 8, -1,
|
||||||
-1,
|
9, -6, -1, 9, 10, -1,
|
||||||
}
|
}
|
||||||
var parserDef = []int{
|
var parserDef = []int{
|
||||||
|
|
||||||
1, -2, 2, 3, 5, 6, 16, 0, 4, 0,
|
1, -2, 2, 3, 5, 6, 18, 0, 4, 0,
|
||||||
8, 9, 10, 11, 7, 13, 0, 15, 12, 0,
|
0, 9, 10, 11, 13, 7, 0, 0, 15, 12,
|
||||||
14,
|
8, 0, 17, 14, 0, 16,
|
||||||
}
|
}
|
||||||
var parserTok1 = []int{
|
var parserTok1 = []int{
|
||||||
|
|
||||||
|
@ -110,7 +112,7 @@ var parserTok1 = []int{
|
||||||
var parserTok2 = []int{
|
var parserTok2 = []int{
|
||||||
|
|
||||||
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
||||||
12, 13, 14,
|
12, 13, 14, 15,
|
||||||
}
|
}
|
||||||
var parserTok3 = []int{
|
var parserTok3 = []int{
|
||||||
0,
|
0,
|
||||||
|
@ -342,7 +344,7 @@ parserdefault:
|
||||||
switch parsernt {
|
switch parsernt {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
//line lang.y:33
|
//line lang.y:35
|
||||||
{
|
{
|
||||||
parserResult = &ast.LiteralNode{
|
parserResult = &ast.LiteralNode{
|
||||||
Value: "",
|
Value: "",
|
||||||
|
@ -351,7 +353,7 @@ parserdefault:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
//line lang.y:41
|
//line lang.y:43
|
||||||
{
|
{
|
||||||
parserResult = parserS[parserpt-0].node
|
parserResult = parserS[parserpt-0].node
|
||||||
|
|
||||||
|
@ -373,12 +375,12 @@ parserdefault:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
//line lang.y:64
|
//line lang.y:66
|
||||||
{
|
{
|
||||||
parserVAL.node = parserS[parserpt-0].node
|
parserVAL.node = parserS[parserpt-0].node
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
//line lang.y:68
|
//line lang.y:70
|
||||||
{
|
{
|
||||||
var result []ast.Node
|
var result []ast.Node
|
||||||
if c, ok := parserS[parserpt-1].node.(*ast.Concat); ok {
|
if c, ok := parserS[parserpt-1].node.(*ast.Concat); ok {
|
||||||
|
@ -393,27 +395,32 @@ parserdefault:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
//line lang.y:84
|
//line lang.y:86
|
||||||
{
|
{
|
||||||
parserVAL.node = parserS[parserpt-0].node
|
parserVAL.node = parserS[parserpt-0].node
|
||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
//line lang.y:88
|
//line lang.y:90
|
||||||
{
|
{
|
||||||
parserVAL.node = parserS[parserpt-0].node
|
parserVAL.node = parserS[parserpt-0].node
|
||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
//line lang.y:94
|
//line lang.y:96
|
||||||
{
|
{
|
||||||
parserVAL.node = parserS[parserpt-1].node
|
parserVAL.node = parserS[parserpt-1].node
|
||||||
}
|
}
|
||||||
case 8:
|
case 8:
|
||||||
//line lang.y:100
|
//line lang.y:102
|
||||||
|
{
|
||||||
|
parserVAL.node = parserS[parserpt-1].node
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
//line lang.y:106
|
||||||
{
|
{
|
||||||
parserVAL.node = parserS[parserpt-0].node
|
parserVAL.node = parserS[parserpt-0].node
|
||||||
}
|
}
|
||||||
case 9:
|
case 10:
|
||||||
//line lang.y:104
|
//line lang.y:110
|
||||||
{
|
{
|
||||||
parserVAL.node = &ast.LiteralNode{
|
parserVAL.node = &ast.LiteralNode{
|
||||||
Value: parserS[parserpt-0].token.Value.(int),
|
Value: parserS[parserpt-0].token.Value.(int),
|
||||||
|
@ -421,8 +428,8 @@ parserdefault:
|
||||||
Posx: parserS[parserpt-0].token.Pos,
|
Posx: parserS[parserpt-0].token.Pos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 10:
|
case 11:
|
||||||
//line lang.y:112
|
//line lang.y:118
|
||||||
{
|
{
|
||||||
parserVAL.node = &ast.LiteralNode{
|
parserVAL.node = &ast.LiteralNode{
|
||||||
Value: parserS[parserpt-0].token.Value.(float64),
|
Value: parserS[parserpt-0].token.Value.(float64),
|
||||||
|
@ -430,33 +437,42 @@ parserdefault:
|
||||||
Posx: parserS[parserpt-0].token.Pos,
|
Posx: parserS[parserpt-0].token.Pos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 11:
|
case 12:
|
||||||
//line lang.y:120
|
//line lang.y:126
|
||||||
|
{
|
||||||
|
parserVAL.node = &ast.Arithmetic{
|
||||||
|
Op: parserS[parserpt-1].token.Value.(ast.ArithmeticOp),
|
||||||
|
Exprs: []ast.Node{parserS[parserpt-2].node, parserS[parserpt-0].node},
|
||||||
|
Posx: parserS[parserpt-2].node.Pos(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 13:
|
||||||
|
//line lang.y:134
|
||||||
{
|
{
|
||||||
parserVAL.node = &ast.VariableAccess{Name: parserS[parserpt-0].token.Value.(string), Posx: parserS[parserpt-0].token.Pos}
|
parserVAL.node = &ast.VariableAccess{Name: parserS[parserpt-0].token.Value.(string), Posx: parserS[parserpt-0].token.Pos}
|
||||||
}
|
}
|
||||||
case 12:
|
case 14:
|
||||||
//line lang.y:124
|
//line lang.y:138
|
||||||
{
|
{
|
||||||
parserVAL.node = &ast.Call{Func: parserS[parserpt-3].token.Value.(string), Args: parserS[parserpt-1].nodeList, Posx: parserS[parserpt-3].token.Pos}
|
parserVAL.node = &ast.Call{Func: parserS[parserpt-3].token.Value.(string), Args: parserS[parserpt-1].nodeList, Posx: parserS[parserpt-3].token.Pos}
|
||||||
}
|
}
|
||||||
case 13:
|
case 15:
|
||||||
//line lang.y:129
|
//line lang.y:143
|
||||||
{
|
{
|
||||||
parserVAL.nodeList = nil
|
parserVAL.nodeList = nil
|
||||||
}
|
}
|
||||||
case 14:
|
case 16:
|
||||||
//line lang.y:133
|
//line lang.y:147
|
||||||
{
|
{
|
||||||
parserVAL.nodeList = append(parserS[parserpt-2].nodeList, parserS[parserpt-0].node)
|
parserVAL.nodeList = append(parserS[parserpt-2].nodeList, parserS[parserpt-0].node)
|
||||||
}
|
}
|
||||||
case 15:
|
case 17:
|
||||||
//line lang.y:137
|
//line lang.y:151
|
||||||
{
|
{
|
||||||
parserVAL.nodeList = append(parserVAL.nodeList, parserS[parserpt-0].node)
|
parserVAL.nodeList = append(parserVAL.nodeList, parserS[parserpt-0].node)
|
||||||
}
|
}
|
||||||
case 16:
|
case 18:
|
||||||
//line lang.y:143
|
//line lang.y:157
|
||||||
{
|
{
|
||||||
parserVAL.node = &ast.LiteralNode{
|
parserVAL.node = &ast.LiteralNode{
|
||||||
Value: parserS[parserpt-0].token.Value.(string),
|
Value: parserS[parserpt-0].token.Value.(string),
|
||||||
|
|
|
@ -5,7 +5,7 @@ state 0
|
||||||
|
|
||||||
PROGRAM_BRACKET_LEFT shift 7
|
PROGRAM_BRACKET_LEFT shift 7
|
||||||
STRING shift 6
|
STRING shift 6
|
||||||
. reduce 1 (src line 32)
|
. reduce 1 (src line 34)
|
||||||
|
|
||||||
interpolation goto 5
|
interpolation goto 5
|
||||||
literal goto 4
|
literal goto 4
|
||||||
|
@ -26,7 +26,7 @@ state 2
|
||||||
|
|
||||||
PROGRAM_BRACKET_LEFT shift 7
|
PROGRAM_BRACKET_LEFT shift 7
|
||||||
STRING shift 6
|
STRING shift 6
|
||||||
. reduce 2 (src line 40)
|
. reduce 2 (src line 42)
|
||||||
|
|
||||||
interpolation goto 5
|
interpolation goto 5
|
||||||
literal goto 4
|
literal goto 4
|
||||||
|
@ -35,164 +35,229 @@ state 2
|
||||||
state 3
|
state 3
|
||||||
literalModeTop: literalModeValue. (3)
|
literalModeTop: literalModeValue. (3)
|
||||||
|
|
||||||
. reduce 3 (src line 62)
|
. reduce 3 (src line 64)
|
||||||
|
|
||||||
|
|
||||||
state 4
|
state 4
|
||||||
literalModeValue: literal. (5)
|
literalModeValue: literal. (5)
|
||||||
|
|
||||||
. reduce 5 (src line 82)
|
. reduce 5 (src line 84)
|
||||||
|
|
||||||
|
|
||||||
state 5
|
state 5
|
||||||
literalModeValue: interpolation. (6)
|
literalModeValue: interpolation. (6)
|
||||||
|
|
||||||
. reduce 6 (src line 87)
|
. reduce 6 (src line 89)
|
||||||
|
|
||||||
|
|
||||||
state 6
|
state 6
|
||||||
literal: STRING. (16)
|
literal: STRING. (18)
|
||||||
|
|
||||||
. reduce 16 (src line 141)
|
. reduce 18 (src line 155)
|
||||||
|
|
||||||
|
|
||||||
state 7
|
state 7
|
||||||
interpolation: PROGRAM_BRACKET_LEFT.expr PROGRAM_BRACKET_RIGHT
|
interpolation: PROGRAM_BRACKET_LEFT.expr PROGRAM_BRACKET_RIGHT
|
||||||
|
|
||||||
PROGRAM_BRACKET_LEFT shift 7
|
PROGRAM_BRACKET_LEFT shift 7
|
||||||
IDENTIFIER shift 13
|
PAREN_LEFT shift 10
|
||||||
INTEGER shift 11
|
IDENTIFIER shift 14
|
||||||
FLOAT shift 12
|
INTEGER shift 12
|
||||||
|
FLOAT shift 13
|
||||||
STRING shift 6
|
STRING shift 6
|
||||||
. error
|
. error
|
||||||
|
|
||||||
expr goto 9
|
expr goto 9
|
||||||
interpolation goto 5
|
interpolation goto 5
|
||||||
literal goto 4
|
literal goto 4
|
||||||
literalModeTop goto 10
|
literalModeTop goto 11
|
||||||
literalModeValue goto 3
|
literalModeValue goto 3
|
||||||
|
|
||||||
state 8
|
state 8
|
||||||
literalModeTop: literalModeTop literalModeValue. (4)
|
literalModeTop: literalModeTop literalModeValue. (4)
|
||||||
|
|
||||||
. reduce 4 (src line 67)
|
. reduce 4 (src line 69)
|
||||||
|
|
||||||
|
|
||||||
state 9
|
state 9
|
||||||
interpolation: PROGRAM_BRACKET_LEFT expr.PROGRAM_BRACKET_RIGHT
|
interpolation: PROGRAM_BRACKET_LEFT expr.PROGRAM_BRACKET_RIGHT
|
||||||
|
expr: expr.ARITH_OP expr
|
||||||
|
|
||||||
PROGRAM_BRACKET_RIGHT shift 14
|
PROGRAM_BRACKET_RIGHT shift 15
|
||||||
|
ARITH_OP shift 16
|
||||||
. error
|
. error
|
||||||
|
|
||||||
|
|
||||||
state 10
|
state 10
|
||||||
|
expr: PAREN_LEFT.expr PAREN_RIGHT
|
||||||
|
|
||||||
|
PROGRAM_BRACKET_LEFT shift 7
|
||||||
|
PAREN_LEFT shift 10
|
||||||
|
IDENTIFIER shift 14
|
||||||
|
INTEGER shift 12
|
||||||
|
FLOAT shift 13
|
||||||
|
STRING shift 6
|
||||||
|
. error
|
||||||
|
|
||||||
|
expr goto 17
|
||||||
|
interpolation goto 5
|
||||||
|
literal goto 4
|
||||||
|
literalModeTop goto 11
|
||||||
|
literalModeValue goto 3
|
||||||
|
|
||||||
|
state 11
|
||||||
literalModeTop: literalModeTop.literalModeValue
|
literalModeTop: literalModeTop.literalModeValue
|
||||||
expr: literalModeTop. (8)
|
expr: literalModeTop. (9)
|
||||||
|
|
||||||
PROGRAM_BRACKET_LEFT shift 7
|
PROGRAM_BRACKET_LEFT shift 7
|
||||||
STRING shift 6
|
STRING shift 6
|
||||||
. reduce 8 (src line 98)
|
. reduce 9 (src line 105)
|
||||||
|
|
||||||
interpolation goto 5
|
interpolation goto 5
|
||||||
literal goto 4
|
literal goto 4
|
||||||
literalModeValue goto 8
|
literalModeValue goto 8
|
||||||
|
|
||||||
state 11
|
|
||||||
expr: INTEGER. (9)
|
|
||||||
|
|
||||||
. reduce 9 (src line 103)
|
|
||||||
|
|
||||||
|
|
||||||
state 12
|
state 12
|
||||||
expr: FLOAT. (10)
|
expr: INTEGER. (10)
|
||||||
|
|
||||||
. reduce 10 (src line 111)
|
. reduce 10 (src line 109)
|
||||||
|
|
||||||
|
|
||||||
state 13
|
state 13
|
||||||
expr: IDENTIFIER. (11)
|
expr: FLOAT. (11)
|
||||||
expr: IDENTIFIER.PAREN_LEFT args PAREN_RIGHT
|
|
||||||
|
|
||||||
PAREN_LEFT shift 15
|
. reduce 11 (src line 117)
|
||||||
. reduce 11 (src line 119)
|
|
||||||
|
|
||||||
|
|
||||||
state 14
|
state 14
|
||||||
interpolation: PROGRAM_BRACKET_LEFT expr PROGRAM_BRACKET_RIGHT. (7)
|
expr: IDENTIFIER. (13)
|
||||||
|
expr: IDENTIFIER.PAREN_LEFT args PAREN_RIGHT
|
||||||
|
|
||||||
. reduce 7 (src line 92)
|
PAREN_LEFT shift 18
|
||||||
|
. reduce 13 (src line 133)
|
||||||
|
|
||||||
|
|
||||||
state 15
|
state 15
|
||||||
expr: IDENTIFIER PAREN_LEFT.args PAREN_RIGHT
|
interpolation: PROGRAM_BRACKET_LEFT expr PROGRAM_BRACKET_RIGHT. (7)
|
||||||
args: . (13)
|
|
||||||
|
|
||||||
PROGRAM_BRACKET_LEFT shift 7
|
. reduce 7 (src line 94)
|
||||||
IDENTIFIER shift 13
|
|
||||||
INTEGER shift 11
|
|
||||||
FLOAT shift 12
|
|
||||||
STRING shift 6
|
|
||||||
. reduce 13 (src line 128)
|
|
||||||
|
|
||||||
expr goto 17
|
|
||||||
interpolation goto 5
|
|
||||||
literal goto 4
|
|
||||||
literalModeTop goto 10
|
|
||||||
literalModeValue goto 3
|
|
||||||
args goto 16
|
|
||||||
|
|
||||||
state 16
|
state 16
|
||||||
expr: IDENTIFIER PAREN_LEFT args.PAREN_RIGHT
|
expr: expr ARITH_OP.expr
|
||||||
args: args.COMMA expr
|
|
||||||
|
|
||||||
PAREN_RIGHT shift 18
|
PROGRAM_BRACKET_LEFT shift 7
|
||||||
COMMA shift 19
|
PAREN_LEFT shift 10
|
||||||
|
IDENTIFIER shift 14
|
||||||
|
INTEGER shift 12
|
||||||
|
FLOAT shift 13
|
||||||
|
STRING shift 6
|
||||||
. error
|
. error
|
||||||
|
|
||||||
|
expr goto 19
|
||||||
|
interpolation goto 5
|
||||||
|
literal goto 4
|
||||||
|
literalModeTop goto 11
|
||||||
|
literalModeValue goto 3
|
||||||
|
|
||||||
state 17
|
state 17
|
||||||
args: expr. (15)
|
expr: PAREN_LEFT expr.PAREN_RIGHT
|
||||||
|
expr: expr.ARITH_OP expr
|
||||||
|
|
||||||
. reduce 15 (src line 136)
|
PAREN_RIGHT shift 20
|
||||||
|
ARITH_OP shift 16
|
||||||
|
. error
|
||||||
|
|
||||||
|
|
||||||
state 18
|
state 18
|
||||||
expr: IDENTIFIER PAREN_LEFT args PAREN_RIGHT. (12)
|
expr: IDENTIFIER PAREN_LEFT.args PAREN_RIGHT
|
||||||
|
args: . (15)
|
||||||
|
|
||||||
. reduce 12 (src line 123)
|
PROGRAM_BRACKET_LEFT shift 7
|
||||||
|
PAREN_LEFT shift 10
|
||||||
|
IDENTIFIER shift 14
|
||||||
|
INTEGER shift 12
|
||||||
|
FLOAT shift 13
|
||||||
|
STRING shift 6
|
||||||
|
. reduce 15 (src line 142)
|
||||||
|
|
||||||
|
expr goto 22
|
||||||
|
interpolation goto 5
|
||||||
|
literal goto 4
|
||||||
|
literalModeTop goto 11
|
||||||
|
literalModeValue goto 3
|
||||||
|
args goto 21
|
||||||
|
|
||||||
state 19
|
state 19
|
||||||
|
expr: expr.ARITH_OP expr
|
||||||
|
expr: expr ARITH_OP expr. (12)
|
||||||
|
|
||||||
|
. reduce 12 (src line 125)
|
||||||
|
|
||||||
|
|
||||||
|
state 20
|
||||||
|
expr: PAREN_LEFT expr PAREN_RIGHT. (8)
|
||||||
|
|
||||||
|
. reduce 8 (src line 100)
|
||||||
|
|
||||||
|
|
||||||
|
state 21
|
||||||
|
expr: IDENTIFIER PAREN_LEFT args.PAREN_RIGHT
|
||||||
|
args: args.COMMA expr
|
||||||
|
|
||||||
|
PAREN_RIGHT shift 23
|
||||||
|
COMMA shift 24
|
||||||
|
. error
|
||||||
|
|
||||||
|
|
||||||
|
state 22
|
||||||
|
expr: expr.ARITH_OP expr
|
||||||
|
args: expr. (17)
|
||||||
|
|
||||||
|
ARITH_OP shift 16
|
||||||
|
. reduce 17 (src line 150)
|
||||||
|
|
||||||
|
|
||||||
|
state 23
|
||||||
|
expr: IDENTIFIER PAREN_LEFT args PAREN_RIGHT. (14)
|
||||||
|
|
||||||
|
. reduce 14 (src line 137)
|
||||||
|
|
||||||
|
|
||||||
|
state 24
|
||||||
args: args COMMA.expr
|
args: args COMMA.expr
|
||||||
|
|
||||||
PROGRAM_BRACKET_LEFT shift 7
|
PROGRAM_BRACKET_LEFT shift 7
|
||||||
IDENTIFIER shift 13
|
PAREN_LEFT shift 10
|
||||||
INTEGER shift 11
|
IDENTIFIER shift 14
|
||||||
FLOAT shift 12
|
INTEGER shift 12
|
||||||
|
FLOAT shift 13
|
||||||
STRING shift 6
|
STRING shift 6
|
||||||
. error
|
. error
|
||||||
|
|
||||||
expr goto 20
|
expr goto 25
|
||||||
interpolation goto 5
|
interpolation goto 5
|
||||||
literal goto 4
|
literal goto 4
|
||||||
literalModeTop goto 10
|
literalModeTop goto 11
|
||||||
literalModeValue goto 3
|
literalModeValue goto 3
|
||||||
|
|
||||||
state 20
|
state 25
|
||||||
args: args COMMA expr. (14)
|
expr: expr.ARITH_OP expr
|
||||||
|
args: args COMMA expr. (16)
|
||||||
|
|
||||||
. reduce 14 (src line 132)
|
ARITH_OP shift 16
|
||||||
|
. reduce 16 (src line 146)
|
||||||
|
|
||||||
|
|
||||||
14 terminals, 8 nonterminals
|
15 terminals, 8 nonterminals
|
||||||
17 grammar rules, 21/2000 states
|
19 grammar rules, 26/2000 states
|
||||||
0 shift/reduce, 0 reduce/reduce conflicts reported
|
0 shift/reduce, 0 reduce/reduce conflicts reported
|
||||||
57 working sets used
|
57 working sets used
|
||||||
memory: parser 25/30000
|
memory: parser 35/30000
|
||||||
16 extra closures
|
21 extra closures
|
||||||
25 shift entries, 1 exceptions
|
45 shift entries, 1 exceptions
|
||||||
12 goto entries
|
14 goto entries
|
||||||
15 entries saved by goto default
|
23 entries saved by goto default
|
||||||
Optimizer space used: output 23/30000
|
Optimizer space used: output 30/30000
|
||||||
23 table entries, 0 zero
|
30 table entries, 0 zero
|
||||||
maximum spread: 14, maximum offset: 19
|
maximum spread: 15, maximum offset: 24
|
||||||
|
|
Loading…
Reference in New Issue