mirror of https://github.com/status-im/NimYAML.git
Renaming of stuff
This commit is contained in:
parent
8e7b3b32bb
commit
acea6e34b6
|
@ -61,14 +61,6 @@ proc advance(lex: YamlLexer[StringSource], step: int = 1) {.inline.} =
|
||||||
if lex.source.pos >= lex.source.src.len: lex.c = EndOfFile
|
if lex.source.pos >= lex.source.src.len: lex.c = EndOfFile
|
||||||
else: lex.c = lex.source.src[lex.source.pos]
|
else: lex.c = lex.source.src[lex.source.pos]
|
||||||
|
|
||||||
proc peek(lex: YamlLexer[StringSource], at: int = 1): char {.inline.} =
|
|
||||||
let index = lex.source.pos + at
|
|
||||||
if index >= lex.source.src.len: result = EndOfFile
|
|
||||||
else: result = lex.source.src[index]
|
|
||||||
|
|
||||||
proc peek(lex: YamlLexer[BaseLexer], at: int = 1): char {.inline.} =
|
|
||||||
lex.source.buf[lex.source.bufpos + at]
|
|
||||||
|
|
||||||
# lexer states
|
# lexer states
|
||||||
|
|
||||||
proc outsideDoc[T](lex: YamlLexer[T], t: var LexerToken): bool
|
proc outsideDoc[T](lex: YamlLexer[T], t: var LexerToken): bool
|
||||||
|
@ -80,8 +72,8 @@ proc expectLineEnd[T](lex: YamlLexer[T], t: var LexerToken): bool
|
||||||
proc possibleDirectivesEnd[T](lex: YamlLexer[T], t: var LexerToken): bool
|
proc possibleDirectivesEnd[T](lex: YamlLexer[T], t: var LexerToken): bool
|
||||||
proc possibleDocumentEnd[T](lex: YamlLexer[T], t: var LexerToken): bool
|
proc possibleDocumentEnd[T](lex: YamlLexer[T], t: var LexerToken): bool
|
||||||
proc afterSeqInd[T](lex: YamlLexer[T], t: var LexerToken): bool
|
proc afterSeqInd[T](lex: YamlLexer[T], t: var LexerToken): bool
|
||||||
proc blockStyle[T](lex: YamlLexer[T], t: var LexerToken): bool {.locks:0.}
|
proc insideDoc[T](lex: YamlLexer[T], t: var LexerToken): bool {.locks:0.}
|
||||||
proc blockStyleInline[T](lex: YamlLexer[T], t: var LexerToken): bool
|
proc insideLine[T](lex: YamlLexer[T], t: var LexerToken): bool
|
||||||
proc plainScalarPart[T](lex: YamlLexer[T], t: var LexerToken): bool
|
proc plainScalarPart[T](lex: YamlLexer[T], t: var LexerToken): bool
|
||||||
proc blockScalarHeader[T](lex: YamlLexer[T], t: var LexerToken): bool
|
proc blockScalarHeader[T](lex: YamlLexer[T], t: var LexerToken): bool
|
||||||
proc blockScalar[T](lex: YamlLexer[T], t: var LexerToken): bool
|
proc blockScalar[T](lex: YamlLexer[T], t: var LexerToken): bool
|
||||||
|
@ -103,7 +95,7 @@ proc newYamlLexer*(source: string, startAt: int = 0):
|
||||||
proc init*[T](lex: YamlLexer[T]) =
|
proc init*[T](lex: YamlLexer[T]) =
|
||||||
lex.nextImpl = outsideDoc[T]
|
lex.nextImpl = outsideDoc[T]
|
||||||
lex.lineStartImpl = outsideDoc[T]
|
lex.lineStartImpl = outsideDoc[T]
|
||||||
lex.inlineImpl = blockStyleInline[T]
|
lex.inlineImpl = insideLine[T]
|
||||||
|
|
||||||
proc next*(lex: YamlLexer): LexerToken =
|
proc next*(lex: YamlLexer): LexerToken =
|
||||||
while not lex.nextImpl(lex, result): discard
|
while not lex.nextImpl(lex, result): discard
|
||||||
|
@ -113,8 +105,8 @@ proc setFlow*[T](lex: YamlLexer[T], value: bool) =
|
||||||
|
|
||||||
proc endBlockScalar*[T](lex: YamlLexer[T]) =
|
proc endBlockScalar*[T](lex: YamlLexer[T]) =
|
||||||
assert lex.nextImpl == blockScalar[T], "Expected blockScalar, got " & lex.nextImpl.repr
|
assert lex.nextImpl == blockScalar[T], "Expected blockScalar, got " & lex.nextImpl.repr
|
||||||
lex.inlineImpl = blockStyleInline[T]
|
lex.inlineImpl = insideLine[T]
|
||||||
lex.nextImpl = blockStyleInline[T]
|
lex.nextImpl = insideLine[T]
|
||||||
|
|
||||||
# implementation
|
# implementation
|
||||||
|
|
||||||
|
@ -310,7 +302,7 @@ proc expectLineEnd[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
|
|
||||||
proc possibleDirectivesEnd[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
proc possibleDirectivesEnd[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
debug("lex: possibleDirectivesEnd")
|
debug("lex: possibleDirectivesEnd")
|
||||||
lex.lineStartImpl = blockStyle[T]
|
lex.lineStartImpl = insideDoc[T]
|
||||||
lex.advance()
|
lex.advance()
|
||||||
if lex.c == '-':
|
if lex.c == '-':
|
||||||
lex.advance()
|
lex.advance()
|
||||||
|
@ -318,7 +310,7 @@ proc possibleDirectivesEnd[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
lex.advance()
|
lex.advance()
|
||||||
if lex.c in spaceOrLineEnd:
|
if lex.c in spaceOrLineEnd:
|
||||||
t = ltDirectivesEnd
|
t = ltDirectivesEnd
|
||||||
lex.nextImpl = blockStyleInline[T]
|
lex.nextImpl = insideLine[T]
|
||||||
return true
|
return true
|
||||||
lex.buf.add('-')
|
lex.buf.add('-')
|
||||||
lex.buf.add('-')
|
lex.buf.add('-')
|
||||||
|
@ -335,7 +327,7 @@ proc afterSeqInd[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
result = true
|
result = true
|
||||||
t = ltSeqItemInd
|
t = ltSeqItemInd
|
||||||
if lex.c notin lineEnd: lex.advance()
|
if lex.c notin lineEnd: lex.advance()
|
||||||
lex.nextImpl = blockStyleInline[T]
|
lex.nextImpl = insideLine[T]
|
||||||
|
|
||||||
proc possibleDocumentEnd[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
proc possibleDocumentEnd[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
debug("lex: possibleDocumentEnd")
|
debug("lex: possibleDocumentEnd")
|
||||||
|
@ -388,16 +380,16 @@ proc outsideDoc[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
if lex.c in spaceOrLineEnd + {'#'}:
|
if lex.c in spaceOrLineEnd + {'#'}:
|
||||||
lex.nextImpl = expectLineEnd[T]
|
lex.nextImpl = expectLineEnd[T]
|
||||||
return false
|
return false
|
||||||
lex.nextImpl = blockStyleInline[T]
|
lex.nextImpl = insideLine[T]
|
||||||
else:
|
else:
|
||||||
lex.indentation = 0
|
lex.indentation = 0
|
||||||
lex.nextImpl = blockStyleInline[T]
|
lex.nextImpl = insideLine[T]
|
||||||
lex.lineStartImpl = blockStyle[T]
|
lex.lineStartImpl = insideDoc[T]
|
||||||
t = ltIndentation
|
t = ltIndentation
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
proc blockStyle[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
proc insideDoc[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
debug("lex: blockStyle")
|
debug("lex: insideDoc")
|
||||||
lex.indentation = 0
|
lex.indentation = 0
|
||||||
case lex.c
|
case lex.c
|
||||||
of '-':
|
of '-':
|
||||||
|
@ -561,8 +553,8 @@ proc doubleQuotedScalar[T](lex: YamlLexer[T]) =
|
||||||
else: lex.buf.add(lex.c)
|
else: lex.buf.add(lex.c)
|
||||||
lex.advance()
|
lex.advance()
|
||||||
|
|
||||||
proc blockStyleInline[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
proc insideLine[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
debug("lex: blockStyleInline")
|
debug("lex: insideLine")
|
||||||
case lex.c
|
case lex.c
|
||||||
of ':': result = lex.possibleIndicatorChar(ltMapValInd, t)
|
of ':': result = lex.possibleIndicatorChar(ltMapValInd, t)
|
||||||
of '?': result = lex.possibleIndicatorChar(ltMapKeyInd, t)
|
of '?': result = lex.possibleIndicatorChar(ltMapKeyInd, t)
|
||||||
|
@ -612,12 +604,12 @@ proc plainScalarPart[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
if lex.nextIsPlainSafe(lex.inFlow): break
|
if lex.nextIsPlainSafe(lex.inFlow): break
|
||||||
else:
|
else:
|
||||||
lex.buf.setLen(lenBeforeSpace)
|
lex.buf.setLen(lenBeforeSpace)
|
||||||
lex.nextImpl = blockStyleInline[T]
|
lex.nextImpl = insideLine[T]
|
||||||
break outer
|
break outer
|
||||||
of flowIndicators:
|
of flowIndicators:
|
||||||
if lex.inFlow:
|
if lex.inFlow:
|
||||||
lex.buf.setLen(lenBeforeSpace)
|
lex.buf.setLen(lenBeforeSpace)
|
||||||
lex.nextImpl = blockStyleInline[T]
|
lex.nextImpl = insideLine[T]
|
||||||
break outer
|
break outer
|
||||||
else:
|
else:
|
||||||
lex.buf.add(lex.c)
|
lex.buf.add(lex.c)
|
||||||
|
@ -630,11 +622,11 @@ proc plainScalarPart[T](lex: YamlLexer[T], t: var LexerToken): bool =
|
||||||
break
|
break
|
||||||
of flowIndicators:
|
of flowIndicators:
|
||||||
if lex.inFlow:
|
if lex.inFlow:
|
||||||
lex.nextImpl = blockStyleInline[T]
|
lex.nextImpl = insideLine[T]
|
||||||
break
|
break
|
||||||
of ':':
|
of ':':
|
||||||
if not lex.nextIsPlainSafe(lex.inFlow):
|
if not lex.nextIsPlainSafe(lex.inFlow):
|
||||||
lex.nextImpl = blockStyleInline[T]
|
lex.nextImpl = insideLine[T]
|
||||||
break outer
|
break outer
|
||||||
else: discard
|
else: discard
|
||||||
t = ltScalarPart
|
t = ltScalarPart
|
||||||
|
|
Loading…
Reference in New Issue