Debian Codegraph @

example/bools/lexer/lexer.go

raw symbols SCIP
1 // Code generated by gocc; DO NOT EDIT.
2
3 package lexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/
4
5 import (
6 "osscip-go gomod github.com/golang/go/src go1.24 os/"
7 "unicode/utf8scip-go gomod github.com/golang/go/src go1.24 `unicode/utf8`/"
8
9 "github.com/goccmack/gocc/example/bools/tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/"
10 )
11
12 const (
13 NoStatescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/NoState. = -1
14 NumStatesscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/NumStates. = 22
15 NumSymbolsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/NumSymbols. = 25
16 )
17
18 type Lexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer# struct {
19 srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#src. []byte
20 posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos. int
21 linescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#line. int
22 columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#column. int
23 Contextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#Context. tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.Contextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Context#
24 }
25
26 func NewLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/NewLexer().(src []byte) *Lexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer# {
27 lexer := &Lexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#{
28 srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#src.: src,
29 posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos.: 0,
30 linescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#line.: 1,
31 columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#column.: 1,
32 Contextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#Context.: nil,
33 }
34 return lexer
35 }
36
37 // SourceContext is a simple instance of a token.Context which
38 // contains the name of the source file.
39 type SourceContextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/SourceContext# struct {
40 Filepathscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/SourceContext#Filepath. string
41 }
42
43 func (s *SourceContextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/SourceContext#) Sourcescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/SourceContext#Source().() string {
44 return s.Filepathscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/SourceContext#Filepath.
45 }
46
47 func NewLexerFilescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/NewLexerFile().(fpath string) (*Lexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#, error) {
48 src, err := osscip-go gomod github.com/golang/go/src go1.24 os/.ReadFilescip-go gomod github.com/golang/go/src go1.24 os/ReadFile().(fpath)
49 if err != nil {
50 return nil, err
51 }
52 lexer := NewLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/NewLexer().(src)
53 lexer.Contextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#Context. = &SourceContextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/SourceContext#{Filepathscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/SourceContext#Filepath.: fpath}
54 return lexer, nil
55 }
56
57 func (l *Lexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#) Scanscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#Scan().() (tok *tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.Tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#) {
58 tok = &tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.Tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#{}
59 if l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos. >= len(l.srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#src.) {
60 tok.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Type. = tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.EOFscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/EOF.
61 tok.Posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Pos..Offsetscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Pos#Offset., tok.Posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Pos..Linescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Pos#Line., tok.Posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Pos..Columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Pos#Column. = l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos., l.linescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#line., l.columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#column.
62 tok.Posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Pos..Contextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Pos#Context. = l.Contextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#Context.
63 return
64 }
65 start, startLine, startColumn, end := l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos., l.linescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#line., l.columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#column., 0
66 tok.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Type. = tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.INVALIDscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/INVALID.
67 state, rune1, size := 0, rune(-1), 0
68 for state != -1 {
69 if l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos. >= len(l.srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#src.) {
70 rune1 = -1
71 } else {
72 rune1, size = utf8scip-go gomod github.com/golang/go/src go1.24 `unicode/utf8`/.DecodeRunescip-go gomod github.com/golang/go/src go1.24 `unicode/utf8`/DecodeRune().(l.srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#src.[l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos.:])
73 l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos. += size
74 }
75
76 nextState := -1
77 if rune1 != -1 {
78 nextState = TransTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/TransTab.[state](rune1)
79 }
80 state = nextState
81
82 if state != -1 {
83
84 switch rune1 {
85 case '\n':
86 l.linescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#line.++
87 l.columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#column. = 1
88 case '\r':
89 l.columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#column. = 1
90 case '\t':
91 l.columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#column. += 4
92 default:
93 l.columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#column.++
94 }
95
96 switch {
97 case ActTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/ActTab.[state].Acceptscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/ActionRow#Accept. != -1:
98 tok.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Type. = ActTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/ActTab.[state].Acceptscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/ActionRow#Accept.
99 end = l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos.
100 case ActTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/ActTab.[state].Ignorescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/ActionRow#Ignore. != "":
101 start, startLine, startColumn = l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos., l.linescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#line., l.columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#column.
102 state = 0
103 if start >= len(l.srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#src.) {
104 tok.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Type. = tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.EOFscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/EOF.
105 }
106
107 }
108 } else {
109 if tok.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Type. == tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.INVALIDscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/INVALID. {
110 end = l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos.
111 }
112 }
113 }
114 if end > start {
115 l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos. = end
116 tok.Litscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Lit. = l.srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#src.[start:end]
117 } else {
118 tok.Litscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Lit. = []byte{}
119 }
120 tok.Posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Pos..Offsetscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Pos#Offset., tok.Posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Pos..Linescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Pos#Line., tok.Posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Pos..Columnscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Pos#Column. = start, startLine, startColumn
121 tok.Posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Pos..Contextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Pos#Context. = l.Contextscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#Context.
122
123 return
124 }
125
126 func (l *Lexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#) Resetscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#Reset().() {
127 l.posscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/lexer`/Lexer#pos. = 0
128 }
129
130 /*
131 Lexer symbols:
132 0: '"'
133 1: '"'
134 2: '&'
135 3: '|'
136 4: '('
137 5: ')'
138 6: 't'
139 7: 'r'
140 8: 'u'
141 9: 'e'
142 10: 'f'
143 11: 'a'
144 12: 'l'
145 13: 's'
146 14: 'e'
147 15: '<'
148 16: '>'
149 17: 'i'
150 18: 'n'
151 19: ' '
152 20: '\t'
153 21: '\n'
154 22: '\r'
155 23: '0'-'9'
156 24: .
157 */