Skip to content

Commit

Permalink
Support grammar within metamodels
Browse files Browse the repository at this point in the history
  • Loading branch information
fuhrmanator committed Feb 2, 2021
1 parent 8a05931 commit 7a4bbc4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mse.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@ AttributeNode = OPEN n:SIMPLENAME vals:(ValueNode *) CLOSE {return {name:n, vals
ValueNode = Primitive / Reference / ElementNode
Primitive = STRING / NUMBER / Boolean
Boolean = TRUE / FALSE
Reference = IntegerReference / NameReference
Reference = IntegerReference / NameReference / TypeReference
IntegerReference = OPEN REF i:INTEGER CLOSE {return {ref:i}}
NameReference = OPEN REF e:ELEMENTNAME CLOSE {return {ref:e}}
TypeReference = OPEN REF t:TYPENAME CLOSE {return {ref:t}}
OPEN = _ "(" _
CLOSE = _ ")" _
ID = _ t:"id:" _ {return t}
REF = _ t:"ref:" _ {return t}
TRUE = _ t:"true" _ {return t}
FALSE = _ t:"false" _ {return t}
ELEMENTNAME = _ letter ( letter / digit ) * ( "." letter ( letter / digit ) * ) _ {return text().trim()}
SIMPLENAME = _ letter ( letter / digit ) * _ {return text().trim()}
INTEGER = _ digit + _ {return text().trim()}
ELEMENTNAME "ElementName" = _ letter ( letter / digit ) * ( "." letter ( letter / digit ) * ) _ {return text().trim()}
SIMPLENAME "Simplename" = _ letter ( letter / digit ) * _ {return text().trim()}
TYPENAME "Typename" = 'Object' / 'Number' / 'Boolean' / 'String'
INTEGER "Integer" = _ digit + _ {return text().trim()}
NUMBER = _ "-" ? digit + ( "." digit + ) ? ( ( "e" / "E" ) ( "-" / "+" ) ? digit + ) ? _ {return text().trim()}
STRING = _ ( "\'" [^'] * "\'" ) + _ {return text().trim()}
letter = [A-Za-z]
digit = [0-9]
_ = space*
space = [ \t\n\r]
space "whitespace" = [ \t\n\r]

0 comments on commit 7a4bbc4

Please sign in to comment.