MCPcopy Create free account
hub / github.com/donatj/sqlread / StartState

Function StartState

states.go:8–53  ·  view source on GitHub ↗
(l *lexer)

Source from the content-addressed store, hash-verified

6)
7
8func StartState(l *lexer) state {
9 l.accept(sep)
10
11 if l.hasPrefix("--") {
12 return doubleDashCommentStateBuilder(StartState)
13 }
14
15 if l.hasPrefix("/*") {
16 return blockCommentStateBuilder(StartState)
17 }
18
19 if l.hasPrefix("DROP TABLE ") {
20 return untilSemiStateBuilder(TDropTableFullStmt, StartState)
21 }
22
23 if l.hasPrefix("LOCK TABLES ") {
24 return untilSemiStateBuilder(TLockTableFullStmt, StartState)
25 }
26
27 if l.hasPrefix("UNLOCK TABLES") {
28 return untilSemiStateBuilder(TUnlockTablesFullStmt, StartState)
29 }
30
31 if l.hasPrefix("CREATE TABLE ") {
32 return createTableState
33 }
34
35 if l.hasPrefix("INSERT INTO ") {
36 return insertIntoTableState
37 }
38
39 if l.hasPrefix("DELIMITER ") { // TODO: Add delimiter awareness
40 return untilNewlineStateBuilder(TDelim, StartState)
41 }
42
43 if l.hasPrefix("SET ") {
44 return untilSemiStateBuilder(TSetFullStmt, StartState)
45 }
46
47 _, p := l.peek(1)
48 if p[0] != eof {
49 l.emit(TIllegal)
50 }
51
52 return nil
53}
54
55func insertIntoTableState(l *lexer) state {
56 l.start = l.pos

Callers

nothing calls this directly

Calls 8

blockCommentStateBuilderFunction · 0.85
untilSemiStateBuilderFunction · 0.85
untilNewlineStateBuilderFunction · 0.85
acceptMethod · 0.80
hasPrefixMethod · 0.80
peekMethod · 0.80
emitMethod · 0.80

Tested by

no test coverage detected