Debian Codegraph @

internal/parser/lr1/items/testdata_test.go

raw symbols SCIP
1 //Copyright 2013 Vastech SA (PTY) LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package items
16
17 import (
18 "testing"
19
20 "github.com/goccmack/gocc/internal/ast"
21 "github.com/goccmack/gocc/internal/frontend/parser"
22 "github.com/goccmack/gocc/internal/frontend/scanner"
23 "github.com/goccmack/gocc/internal/frontend/token"
24 )
25
26 const G1 = `
27 A : B a ;
28
29 B : b ;
30 `
31
32 var G1S0 = []string{
33 "A : •B a «$»",
34 "B : •b «$»",
35 }
36
37 func parse(src string, t *testing.T) *ast.Grammar {
38 lexer := new(scanner.Scanner)
39 lexer.Init([]byte(src), token.FRONTENDTokens)
40 p := parser.NewParser(parser.ActionTable, parser.GotoTable, parser.ProductionsTable, token.FRONTENDTokens)
41 res, err := p.Parse(lexer)
42 if err != nil {
43 t.Fatal(err)
44 return nil
45 }
46 return res.(*ast.Grammar)
47 }