MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Process

Method Process

testing/generation/command_docs/scanner.go:108–317  ·  view source on GitHub ↗

Process processes the synopsis and returns the generated tokens.

()

Source from the content-addressed store, hash-verified

106
107// Process processes the synopsis and returns the generated tokens.
108func (scanner *Scanner) Process() ([]utils.Token, error) {
109 if scanner.isFinished || scanner.savedErr != nil {
110 return scanner.tokens, scanner.savedErr
111 }
112ScannerLoop:
113 for {
114 r, ok := scanner.Next()
115 if !ok {
116 break ScannerLoop
117 }
118 switch r {
119 case '$':
120 var name []rune
121 for r, ok = scanner.Peek(); ok && r != '$'; r, ok = scanner.Peek() {
122 scanner.Advance()
123 name = append(name, r)
124 }
125 if !ok {
126 scanner.savedErr = fmt.Errorf("unexpected EOF when reading variable name")
127 break ScannerLoop
128 }
129 scanner.Advance()
130 scanner.tokens = append(scanner.tokens, utils.Token{
131 Type: utils.TokenType_Variable,
132 Literal: string(name),
133 })
134 case '\t':
135 scanner.savedErr = fmt.Errorf("tab found, remove all tabs from the synopsis")
136 break ScannerLoop
137 case ' ', '\n':
138 spaceCount := 0
139 lineCount := 0
140 if r == ' ' {
141 spaceCount += 1
142 }
143 if r == '\n' {
144 lineCount++
145 }
146 commentMode := false
147 WhitespaceLoop:
148 for r, ok = scanner.Peek(); ok; r, ok = scanner.Peek() {
149 if commentMode {
150 scanner.Advance()
151 if r == '\n' {
152 commentMode = false
153 }
154 } else {
155 switch r {
156 case ' ':
157 scanner.Advance()
158 spaceCount += 1
159 case '\n':
160 scanner.Advance()
161 lineCount++
162 case '/':
163 if next, _ := scanner.PeekBy(2); next == '/' {
164 if last, _ := scanner.PeekBy(0); last == '\n' {
165 scanner.Advance()

Callers 4

NewScannerFunction · 0.95
customDefinitionFunction · 0.95

Calls 10

NextMethod · 0.95
PeekMethod · 0.95
AdvanceMethod · 0.95
PeekByMethod · 0.95
AdvanceByMethod · 0.95
PeekMatchOffsetMethod · 0.95
PeekMatchMethod · 0.95
RepeatMethod · 0.80
IsSpaceMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected