| 1 | package astxscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.24 fmt/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.24 testing/" |
| 6 | |
| 7 | "github.com/goccmack/gocc/example/astx/astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/ast`/" |
| 8 | "github.com/goccmack/gocc/example/astx/lexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/lexer`/" |
| 9 | "github.com/goccmack/gocc/example/astx/parserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/parser`/" |
| 10 | ) |
| 11 | |
| 12 | func TestPassscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx`/TestPass().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 13 | sml, err := testscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx`/test().([]byte("a b c d e f")) |
| 14 | if err != nil { |
| 15 | t.Fatalscip-go gomod github.com/golang/go/src go1.24 testing/common#Fatal().(err.Error()) |
| 16 | } |
| 17 | fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("output: %s\n", sml) |
| 18 | } |
| 19 | |
| 20 | func TestFailscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx`/TestFail().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 21 | _, err := testscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx`/test().([]byte("a b ; d e f")) |
| 22 | if err == nil { |
| 23 | t.Fatalscip-go gomod github.com/golang/go/src go1.24 testing/common#Fatal().("expected parse error") |
| 24 | } else { |
| 25 | fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("Parsing failed as expected: %v\n", err) |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | func testscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx`/test().(src []byte) (astree astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/ast`/.StmtListscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/ast`/StmtList#, err error) { |
| 30 | fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("input: %s\n", src) |
| 31 | s := lexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/lexer`/.NewLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/lexer`/NewLexer().(src) |
| 32 | p := parserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/parser`/.NewParserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/parser`/NewParser().() |
| 33 | a, err := p.Parsescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/parser`/Parser#Parse().(s) |
| 34 | if err == nil { |
| 35 | astree = a.(astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/ast`/.StmtListscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/astx/ast`/StmtList#) |
| 36 | } |
| 37 | return |
| 38 | } |