Hera is a grammar language created in 2021 by Daniel X Moore.
#2195on PLDB | 3Years Old |
git clone https://github.com/DanielXMoore/Hera
Elegant parsing expression grammars
# WIP Coffee-like lang
Grammar
Line*
Line
Indent Content EOL
Indent EOL
Indent
" "*
Content
Statement
Expression
Expression
Applied
# Function application:
# a b
# a(b)
# a b, c, d
# a(b, c, d)
Applied
Operated Application?
Application
"()"
__ "(" ArgumentList ")"
Space+ ArgumentList
ArgumentList
Expression (__ "," __ Expression)*
Operated
Assigned (__ BinaryOp __ Assigned)*
UnaryOp* Assigned
Assigned
(Accessed __ "=" __)+ Expression
Accessed
Accessed
Primary Access*
Access
"?"? "." Name
"?"? "[" Expression "]"
Primary
"(" Expression ")"
Function
Literal
Name
This
"this"
"@"
Function
Parameters "->"
Literal
StringValue
Numeric
"true"
"false"
"null"
"undefined"
Parameters
"(" Name (Comma Name)+ ")"
"(" Name ")"
""
Comma
Space* "," Space*
Name
[$a-zA-Z_][$a-zA-Z0-9_]*
BinaryOp
"+"
"-"
"*"
"/"
"and"
"&&"
"or"
"||"
# TODO: delete, void, typeof
UnaryOp
[!~+-]
Statement
Import
Export
Import
/import[^\r\n]*/
Export
/export[^\r\n]*/
Numeric
/\d+(?:\.\d*)?/
StringValue
"\"" $DoubleStringCharacter* "\"" -> $2
"\'" $SingleStringCharacter* "\'" -> $2
DoubleStringCharacter
[^"\\]+
EscapeSequence
SingleStringCharacter
[^'\\]+
EscapeSequence
EscapeSequence
$( "\\" . )
# Required non-newline white space
Space
[\t ]
# Whitespace including newlines
__
/\s*/
# End of line
EOL
/\r\n|\n|\r/