I load the following grammar and test into ohm-editor and set the start rule to "KVkeep_inputport". The parse fails. When I click on the "Explain parse" option, the parse tree shows garbled information (scroll to far right).
background: I am trying to figure out why the comma in ,..."contents":{...} is disappearing when I set the start rule to "object". [This probably has to do with a misunderstanding I have about space-skipping and shortest vs. longest match, but, it doesn't change the fact that the editor parse appears garbled].
grammar:
keep {
main = item+
item =
| rootArray -- root
| "{" spaces item+ "}" -- braces
| "[" spaces item+ "]" -- square
| ~"{" ~"}" ~"[" ~"]" any
rootArray = "[" object+ "]"
object = "{" kvPair+ "}"
kvPair =
| applySyntactic<KVkeep> -- keep
| string ":" other+ -- ignore
| space -- separator
KVkeep =
| Key<"attributes"> "{" ID Key<"kind"> value<"inputgate"> (#other)* "}"-- inputgate
| Key<"attributes"> "{" ID Key<"kind"> value<"inputport"> (#other)* "}" -- inputport
| Key<"attributes"> "{" ID Key<"kind"> value<"outputgate"> (#other)* "}" -- outputgate
| Key<"attributes"> "{" ID Key<"kind"> value<"outputport"> (#other)* "}" -- outputport
| Key<"attributes"> "{" ID Key<"kind"> value<"part"> (#other)* "}" -- part
| Key<"attributes"> "{" ID Key<"kind"> value<"wire"> (#other)* "}" -- wire
other =
| "{" ws other+ "}" ws -- braces
| "[" ws other+ "]" ws -- square
| ~"{" ~"}" ~"[" ~"]" any -- default
ID = Key<"id"> string
Key<s> = dq s dq ":"
value<s> = dq s dq
string = dq (~dq any)* dq
dq = "\""
space += ","
ws = spaces
}
test:
"attributes": {
"id": "3",
"kind": "inputport",
"label": "pin",
"parent": "2"
},
"contents": {
"boundingbox": [
-16.75,
27.5,
36.75,
25
]
}
I load the following grammar and test into ohm-editor and set the start rule to "KVkeep_inputport". The parse fails. When I click on the "Explain parse" option, the parse tree shows garbled information (scroll to far right).
background: I am trying to figure out why the comma in
,..."contents":{...}is disappearing when I set the start rule to "object". [This probably has to do with a misunderstanding I have about space-skipping and shortest vs. longest match, but, it doesn't change the fact that the editor parse appears garbled].grammar:
test: