neugram / ng

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

ng/eval: implement 'x >> n' #221

Closed sbinet closed 6 years ago

sbinet commented 6 years ago

the following fails in ng:

ng> var y uint8 = 120
ng> v := y >> 0
maybeParseType: token=>
neugram: parser: panic: TODO parseStmt ; (off 29)
goroutine 6 [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(0xc420142070)
    /home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:145 +0x116
panic(0xafc880, 0xc42011a150)
    /home/binet/sdk/go/src/runtime/panic.go:502 +0x229
neugram.io/ng/parser.(*Parser).parseStmt(0xc420142070, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:1233 +0x1836
neugram.io/ng/parser.(*Parser).work(0xc420142070)
    /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(2),
        Column: int16(9),
    },
    Error: parser.Error{
        Pos: src.Pos{
            Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
            Line: int32(2),
            Column: int16(11),
        },
        Offset: int(29),
        Msg: "expected operand, got integer",
    },
}
goroutine 1 [running]:
runtime/debug.Stack(0x187, 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(0xc4201d6080, 0xc420141630, 0xc420141618)
    /home/binet/work/gonum/src/neugram.io/ng/eval/eval.go:476 +0x1ea
panic(0xafc880, 0xc42011a2c0)
    /home/binet/sdk/go/src/runtime/panic.go:502 +0x229
neugram.io/ng/typecheck.(*Checker).exprPartial(0xc4201561b0, 0xc4d120, 0xc4201165a0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc4d120, ...)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:2759 +0x6a7f
neugram.io/ng/typecheck.(*Checker).expr(0xc4201561b0, 0xc4d120, 0xc4201165a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:1351 +0x79
neugram.io/ng/typecheck.(*Checker).exprPartial(0xc4201561b0, 0xc4d1a0, 0xc4201201c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc4d1a0, ...)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:2372 +0x169c
neugram.io/ng/typecheck.(*Checker).exprNoElide(0xc4201561b0, 0xc4d1a0, 0xc4201201c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:1360 +0x79
neugram.io/ng/typecheck.(*Checker).stmt(0xc4201561b0, 0xc4d720, 0xc4201222d0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:166 +0x378
neugram.io/ng/typecheck.(*Checker).Add(0xc4201561b0, 0xc4d720, 0xc4201222d0, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:3572 +0x94
neugram.io/ng/eval.(*Program).Eval(0xc4201d6080, 0xc4d720, 0xc4201222d0, 0xc42016e0c0, 0x0, 0x0, 0x0, 0xc48a60, 0xc42011a2d0)
    /home/binet/work/gonum/src/neugram.io/ng/eval/eval.go:481 +0xe2
main.handleResult(0x2, 0xc42011a140, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc4202300c0, 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(2),
        Column: int16(9),
    },
    Error: parser.Error{
        Pos: src.Pos{
            Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
            Line: int32(2),
            Column: int16(11),
        },
        Offset: int(29),
        Msg: "expected operand, got integer",
    },
}
neugram: parser: expected operand, got integer (off 29)
neugram: parser: expected ";", found "integer" (off 29)
neugram: parser: panic: TODO parseStmt ; (off 29)