diff --git a/mse.pegjs b/mse.pegjs index fe1357e..0e2eced 100644 --- a/mse.pegjs +++ b/mse.pegjs @@ -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] \ No newline at end of file +space "whitespace" = [ \t\n\r] \ No newline at end of file