| 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 itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ |
| 16 | |
| 17 | import ( |
| 18 | "testingscip-go gomod github.com/golang/go/src go1.24 testing/" |
| 19 | |
| 20 | "github.com/goccmack/gocc/internal/astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/" |
| 21 | "github.com/goccmack/gocc/internal/frontend/parserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/" |
| 22 | "github.com/goccmack/gocc/internal/frontend/scannerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/" |
| 23 | "github.com/goccmack/gocc/internal/frontend/tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/" |
| 24 | ) |
| 25 | |
| 26 | func findSetscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/findSet().(sets *ItemSetsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSets#, items []string) *ItemSetscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSet# { |
| 27 | for _, set := range sets.Listscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSets#List().() { |
| 28 | if setEqualItemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/setEqualItems().(set, items) { |
| 29 | return set |
| 30 | } |
| 31 | } |
| 32 | return nil |
| 33 | } |
| 34 | |
| 35 | func setEqualItemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/setEqualItems().(set *ItemSetscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSet#, items []string) bool { |
| 36 | if set.Sizescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSet#Size().() != len(items) { |
| 37 | return false |
| 38 | } |
| 39 | for _, item := range items { |
| 40 | if !setContainItemscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/setContainItem().(set, item) { |
| 41 | return false |
| 42 | } |
| 43 | } |
| 44 | return true |
| 45 | } |
| 46 | |
| 47 | func setContainItemscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/setContainItem().(set *ItemSetscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSet#, item string) bool { |
| 48 | for _, setItem := range set.Itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSet#Items. { |
| 49 | if setItem.strscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/Item#str. == item { |
| 50 | return true |
| 51 | } |
| 52 | } |
| 53 | return false |
| 54 | } |
| 55 | |
| 56 | func parsescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/parse().(src string, t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) *astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/.Grammarscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/Grammar# { |
| 57 | scanner := new(scannerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/.Scannerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Scanner#) |
| 58 | scanner.Initscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Scanner#Init().([]byte(src), tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens.) |
| 59 | parser := parserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/.NewParserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/NewParser().(parserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/.ActionTablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/ActionTable., parserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/.GotoTablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/GotoTable., parserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/.ProductionsTablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/ProductionsTable., tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens.) |
| 60 | g, err := parser.Parsescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/parser`/Parser#Parse().(scanner) |
| 61 | if err != nil { |
| 62 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24 testing/common#Fatalf().("Parse error: %s\n", err) |
| 63 | return nil |
| 64 | } |
| 65 | |
| 66 | return g.(*astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/.Grammarscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/Grammar#) |
| 67 | } |