extend concrete syntax: edge can be defined as (src -> tgt) OR (tgt <- src)
This commit is contained in:
parent
5c3026d1f6
commit
838bb18630
1 changed files with 7 additions and 2 deletions
|
|
@ -33,9 +33,10 @@ INDENTED_CODE: /```[^`]*```/
|
||||||
type_name: IDENTIFIER
|
type_name: IDENTIFIER
|
||||||
|
|
||||||
# name (optional) type
|
# name (optional) type
|
||||||
object: [IDENTIFIER] ":" type_name [link_spec] ["{" slot* "}"]
|
object: [IDENTIFIER] ":" type_name [link_spec | rev_link_spec] ["{" slot* "}"]
|
||||||
|
|
||||||
link_spec: "(" IDENTIFIER "->" IDENTIFIER ")"
|
link_spec: "(" IDENTIFIER "->" IDENTIFIER ")"
|
||||||
|
rev_link_spec: "(" IDENTIFIER "<-" IDENTIFIER ")"
|
||||||
|
|
||||||
slot: IDENTIFIER "=" literal ";"
|
slot: IDENTIFIER "=" literal ";"
|
||||||
"""
|
"""
|
||||||
|
|
@ -64,6 +65,10 @@ def parse_od(state, m_text, mm, type_transform=lambda type_name: type_name):
|
||||||
[src, tgt] = el
|
[src, tgt] = el
|
||||||
return (src, tgt)
|
return (src, tgt)
|
||||||
|
|
||||||
|
def rev_link_spec(self, el):
|
||||||
|
[tgt, src] = el # <-- reversed :)
|
||||||
|
return (src, tgt)
|
||||||
|
|
||||||
def type_name(self, el):
|
def type_name(self, el):
|
||||||
type_name = el[0]
|
type_name = el[0]
|
||||||
if type_name in primitive_types:
|
if type_name in primitive_types:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue