neugram / ng

scripting language integrated with Go
https://neugram.io
BSD 2-Clause "Simplified" License
916 stars 43 forks source link

ng/eval,parser: support for binary '&^' #214

Closed sbinet closed 6 years ago

sbinet commented 6 years ago

the following fails in ng:

ng> a := 1
ng> b := 2
ng> a &^ b
maybeParseType: token=^
neugram: parser: panic: TODO parseStmt ; (off 20)
goroutine 23 [running]:
runtime/debug.Stack(0x32, 0x0, 0x0)
    /home/binet/sdk/go/src/runtime/debug/stack.go:24 +0xa7
runtime/debug.PrintStack()
    /home/binet/sdk/go/src/runtime/debug/stack.go:16 +0x22
neugram.io/ng/parser.(*Parser).work.func1(0xc4200f2540)
    /home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:145 +0x116
panic(0xaf87a0, 0xc420118150)
    /home/binet/sdk/go/src/runtime/panic.go:502 +0x229
neugram.io/ng/parser.(*Parser).parseStmt(0xc4200f2540, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:1233 +0x1836
neugram.io/ng/parser.(*Parser).work(0xc4200f2540)
    /home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:188 +0x1f4
created by neugram.io/ng/parser.New
    /home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:30 +0x114
ng eval panic: expr TODO: &expr.Bad{
    Position: src.Pos{
        Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
        Line: int32(3),
        Column: int16(4),
    },
    Error: parser.Error{
        Pos: src.Pos{
            Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
            Line: int32(3),
            Column: int16(6),
        },
        Offset: int(20),
        Msg: "expected operand, got ident",
    },
}
goroutine 1 [running]:
runtime/debug.Stack(0x184, 0x0, 0x0)
    /home/binet/sdk/go/src/runtime/debug/stack.go:24 +0xa7
runtime/debug.PrintStack()
    /home/binet/sdk/go/src/runtime/debug/stack.go:16 +0x22
neugram.io/ng/eval.(*Program).Eval.func1(0xc4200e2280, 0xc42013b630, 0xc42013b618)
    /home/binet/work/gonum/src/neugram.io/ng/eval/eval.go:476 +0x1ea
panic(0xaf87a0, 0xc4201182c0)
    /home/binet/sdk/go/src/runtime/panic.go:502 +0x229
neugram.io/ng/typecheck.(*Checker).exprPartial(0xc4200cc240, 0xc48500, 0xc4201143c0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc48500, ...)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:2679 +0x59aa
neugram.io/ng/typecheck.(*Checker).expr(0xc4200cc240, 0xc48500, 0xc4201143c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:1350 +0x79
neugram.io/ng/typecheck.(*Checker).exprPartial(0xc4200cc240, 0xc48580, 0xc4201241c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc48580, ...)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:2368 +0x169c
neugram.io/ng/typecheck.(*Checker).exprNoElide(0xc4200cc240, 0xc48580, 0xc4201241c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:1359 +0x79
neugram.io/ng/typecheck.(*Checker).stmt(0xc4200cc240, 0xc48f80, 0xc4201143f0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:252 +0x3d06
neugram.io/ng/typecheck.(*Checker).Add(0xc4200cc240, 0xc48f80, 0xc4201143f0, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:3490 +0x94
neugram.io/ng/eval.(*Program).Eval(0xc4200e2280, 0xc48f80, 0xc4201143f0, 0xc42008c1e0, 0x0, 0x0, 0x0, 0xc43e40, 0xc4201182d0)
    /home/binet/work/gonum/src/neugram.io/ng/eval/eval.go:481 +0xe2
main.handleResult(0x2, 0xc420118140, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc4201ee0c0, 0x3, 0x4)
    /home/binet/work/gonum/src/neugram.io/ng/ng.go:393 +0x72b
main.loop(0xc400000000)
    /home/binet/work/gonum/src/neugram.io/ng/ng.go:385 +0x5d2
main.main()
    /home/binet/work/gonum/src/neugram.io/ng/ng.go:147 +0x5be
ng: ng eval panic: expr TODO: &expr.Bad{
    Position: src.Pos{
        Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
        Line: int32(3),
        Column: int16(4),
    },
    Error: parser.Error{
        Pos: src.Pos{
            Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
            Line: int32(3),
            Column: int16(6),
        },
        Offset: int(20),
        Msg: "expected operand, got ident",
    },
}
neugram: parser: expected operand, got ident (off 20)
neugram: parser: expected ";", found "ident" (off 20)
neugram: parser: panic: TODO parseStmt ; (off 20)