neugram / ng

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

ng/eval: implement '1<<n' #206

Closed sbinet closed 6 years ago

sbinet commented 6 years ago

the following fails in ng:

ng> 1<<7
maybeParseType: token=<
neugram: parser: panic: TODO parseStmt ; (off 4)
goroutine 9 [running]:
runtime/debug.Stack(0x31, 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(0xc4200d2540)
    /home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:145 +0x116
panic(0xaf2cc0, 0xc42001f120)
    /home/binet/sdk/go/src/runtime/panic.go:502 +0x229
neugram.io/ng/parser.(*Parser).parseStmt(0xc4200d2540, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:1233 +0x1836
neugram.io/ng/parser.(*Parser).work(0xc4200d2540)
    /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(1),
        Column: int16(3),
    },
    Error: parser.Error{
        Pos: src.Pos{
            Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
            Line: int32(1),
            Column: int16(4),
        },
        Offset: int(4),
        Msg: "expected operand, got integer",
    },
}
goroutine 1 [running]:
runtime/debug.Stack(0x185, 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(0xc4200c4480, 0xc42012b630, 0xc42012b618)
    /home/binet/work/gonum/src/neugram.io/ng/eval/eval.go:473 +0x1ea
panic(0xaf2cc0, 0xc42001f290)
    /home/binet/sdk/go/src/runtime/panic.go:502 +0x229
neugram.io/ng/typecheck.(*Checker).exprPartial(0xc4200ae240, 0xc41a40, 0xc420190510, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc41a40, ...)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:2672 +0x59aa
neugram.io/ng/typecheck.(*Checker).expr(0xc4200ae240, 0xc41a40, 0xc420190510, 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(0xc4200ae240, 0xc41ac0, 0xc420073480, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc41ac0, ...)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:2361 +0x169c
neugram.io/ng/typecheck.(*Checker).exprNoElide(0xc4200ae240, 0xc41ac0, 0xc420073480, 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(0xc4200ae240, 0xc424c0, 0xc420190540, 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(0xc4200ae240, 0xc424c0, 0xc420190540, 0x0, 0x0)
    /home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:3483 +0x94
neugram.io/ng/eval.(*Program).Eval(0xc4200c4480, 0xc424c0, 0xc420190540, 0xc4200801e0, 0x0, 0x0, 0x0, 0xc3d380, 0xc42001f2a0)
    /home/binet/work/gonum/src/neugram.io/ng/eval/eval.go:478 +0xe2
main.handleResult(0x2, 0xc42001f110, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc4200b4180, 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(1),
        Column: int16(3),
    },
    Error: parser.Error{
        Pos: src.Pos{
            Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
            Line: int32(1),
            Column: int16(4),
        },
        Offset: int(4),
        Msg: "expected operand, got integer",
    },
}
neugram: parser: expected operand, got integer (off 4)
neugram: parser: expected ";", found "integer" (off 4)
neugram: parser: panic: TODO parseStmt ; (off 4)
..> ^C
TODO interrupt partial statement
..> 
..>