| 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 golangscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/ |
| 16 | |
| 17 | import ( |
| 18 | "bytesscip-go gomod github.com/golang/go/src go1.24 bytes/" |
| 19 | "pathscip-go gomod github.com/golang/go/src go1.24 path/" |
| 20 | "text/templatescip-go gomod github.com/golang/go/src go1.24 `text/template`/" |
| 21 | |
| 22 | "github.com/goccmack/gocc/internal/ioscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/io`/" |
| 23 | "github.com/goccmack/gocc/internal/lexer/symbolsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/symbols`/" |
| 24 | ) |
| 25 | |
| 26 | func genAsciiTablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/genAsciiTable().(outDir string, symbols *symbolsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/symbols`/.Symbolsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/symbols`/Symbols#) { |
| 27 | tmpl, err := templatescip-go gomod github.com/golang/go/src go1.24 `text/template`/.Newscip-go gomod github.com/golang/go/src go1.24 `text/template`/New().("ascii table").Parsescip-go gomod github.com/golang/go/src go1.24 `text/template`/Template#Parse().(asciiTabSrcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiTabSrc.) |
| 28 | if err != nil { |
| 29 | panic(err) |
| 30 | } |
| 31 | w := new(bytesscip-go gomod github.com/golang/go/src go1.24 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24 bytes/Buffer#) |
| 32 | if err = tmpl.Executescip-go gomod github.com/golang/go/src go1.24 `text/template`/Template#Execute().(w, getAsciiTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/getAsciiTab().(symbols)); err != nil { |
| 33 | panic(err) |
| 34 | } |
| 35 | ioscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/io`/.WriteFilescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/io`/WriteFile().(pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(outDir, "lexer", "asciitable.go"), w.Bytesscip-go gomod github.com/golang/go/src go1.24 bytes/Buffer#Bytes().()) |
| 36 | } |
| 37 | |
| 38 | func getAsciiTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/getAsciiTab().(symbols *symbolsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/symbols`/.Symbolsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/symbols`/Symbols#) map[rune]asciiTypescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiType# { |
| 39 | asciiMap := make(map[rune]asciiTypescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiType#) |
| 40 | for i, sym := range symbols.Listscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/symbols`/Symbols#List().() { |
| 41 | if cl, exist := symbols.CharLitSymbolsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/symbols`/Symbols#CharLitSymbols..GetSymbolIdscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/symbols`/CharLitSymbols#GetSymbolId().(sym); exist { |
| 42 | if cl.Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexCharLit#Val. < 0x100 { |
| 43 | asciiMap[cl.Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexCharLit#Val.] = asciiTypescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiType#{Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiType#Type.: i, Commentscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiType#Comment.: sym} |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | return asciiMap |
| 48 | } |
| 49 | |
| 50 | type asciiTypescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiType# struct { |
| 51 | Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiType#Type. int |
| 52 | Commentscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiType#Comment. string |
| 53 | } |
| 54 | |
| 55 | const asciiTabSrcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/asciiTabSrc. = ` |
| 56 | // Code generated by gocc; DO NOT EDIT. |
| 57 | |
| 58 | package lexer |
| 59 | |
| 60 | const asciiTabLen = 255 |
| 61 | |
| 62 | // asciiTable[rune] returns the lexer symbol type of rune |
| 63 | var asciiTable = func() *[asciiTabLen]int { |
| 64 | atab := new([asciiTabLen] int) |
| 65 | for i, _ := range atab { |
| 66 | atab[i] = -1 |
| 67 | } |
| 68 | {{range $run, $typ := .}}atab[{{$run}}] = {{$typ.Type}} // {{$typ.Comment}} |
| 69 | {{end}} |
| 70 | return atab |
| 71 | }() |
| 72 | |
| 73 | ` |