| 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 astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/ |
| 16 | |
| 17 | import ( |
| 18 | "bytesscip-go gomod github.com/golang/go/src go1.24 bytes/" |
| 19 | "fmtscip-go gomod github.com/golang/go/src go1.24 fmt/" |
| 20 | "stringsscip-go gomod github.com/golang/go/src go1.24 strings/" |
| 21 | |
| 22 | "github.com/goccmack/gocc/internal/frontend/tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/" |
| 23 | ) |
| 24 | |
| 25 | type LexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef# struct { |
| 26 | idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#id. string |
| 27 | patternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#pattern. *LexPatternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexPattern# |
| 28 | } |
| 29 | |
| 30 | func NewLexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/NewLexTokDef().(tokId, lexPattern interface{}) (*LexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#, error) { |
| 31 | tokDef := &LexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#{ |
| 32 | idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#id.: string(tokId.(*tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.Tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#).Litscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#Lit.), |
| 33 | patternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#pattern.: lexPattern.(*LexPatternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexPattern#), |
| 34 | } |
| 35 | return tokDef, nil |
| 36 | } |
| 37 | |
| 38 | func NewLexStringLitTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/NewLexStringLitTokDef().(tokId string) *LexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef# { |
| 39 | runes := bytesscip-go gomod github.com/golang/go/src go1.24 bytes/.Runesscip-go gomod github.com/golang/go/src go1.24 bytes/Runes().([]byte(tokId)) |
| 40 | alt, _ := NewLexAltscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/NewLexAlt().(newLexCharLitFromRunescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/newLexCharLitFromRune().(runes[0])) |
| 41 | for i := 1; i < len(runes); i++ { |
| 42 | alt, _ = AppendLexTermscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/AppendLexTerm().(alt, newLexCharLitFromRunescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/newLexCharLitFromRune().(runes[i])) |
| 43 | } |
| 44 | ptrn, _ := NewLexPatternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/NewLexPattern().(alt) |
| 45 | return &LexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#{ |
| 46 | idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#id.: tokId, |
| 47 | patternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#pattern.: ptrn, |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func (*LexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#) RegDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#RegDef().() bool { |
| 52 | return false |
| 53 | } |
| 54 | |
| 55 | func (this *LexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#) Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#String().() string { |
| 56 | buf := new(stringsscip-go gomod github.com/golang/go/src go1.24 strings/.Builderscip-go gomod github.com/golang/go/src go1.24 strings/Builder#) |
| 57 | fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Fprintf().(buf, "%s : %s", this.idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#id., this.patternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#pattern..Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexPattern#String().()) |
| 58 | return buf.Stringscip-go gomod github.com/golang/go/src go1.24 strings/Builder#String().() |
| 59 | } |
| 60 | |
| 61 | func (this *LexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#) Idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#Id().() string { |
| 62 | return this.idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#id. |
| 63 | } |
| 64 | |
| 65 | func (this *LexTokDefscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#) LexPatternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#LexPattern().() *LexPatternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexPattern# { |
| 66 | return this.patternscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexTokDef#pattern. |
| 67 | } |