Support '.' in Ref
This commit is contained in:
parent
c449d41759
commit
1644736625
|
@ -55,7 +55,7 @@ type
|
|||
name*: string
|
||||
pattern*: SchemaNode
|
||||
of snkRef:
|
||||
def*: string
|
||||
refPath*: seq[string]
|
||||
else:
|
||||
nodes*: seq[SchemaNode]
|
||||
|
||||
|
@ -139,7 +139,7 @@ proc `$`*(n: SchemaNode): string =
|
|||
result.add ' '
|
||||
result.add $n.pattern
|
||||
of snkRef:
|
||||
result.add n.def
|
||||
result.add join(n.refPath, ".")
|
||||
|
||||
proc `$`*(scm: Schema): string =
|
||||
result.add("version = $1 .\n" % $scm.version)
|
||||
|
@ -328,8 +328,9 @@ const parser = peg("Schema", p: ParseState):
|
|||
assert(n.nodes.len == 2, $n.nodes)
|
||||
pushStack n
|
||||
|
||||
Ref <- id:
|
||||
let n = SchemaNode(kind: snkRef, def: $0)
|
||||
Ref <- >(Alpha * *Alnum) * *('.' * >(*Alnum)):
|
||||
let n = SchemaNode(kind: snkRef)
|
||||
for i in 1..<capture.len: n.refPath.add capture[i].s
|
||||
pushStack n
|
||||
|
||||
CompoundPattern <-
|
||||
|
|
Loading…
Reference in New Issue