Skip to content

Editor: overlapping text in exploded input #501

@guitarvydas

Description

@guitarvydas

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
              ]
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions