You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This documentation specifies grammar rules for Sarcasm.
@namespace Sarcasm . Parser
@class SarcasmGrammar
@name "Sarcasm"
@version "0.1"
@description "An EBNF-like DSL that generates Irony"
Overall Structure
Body is the root node:
Root := Body ;
The body consists of multiple lines of statements:
BodyNode Body := Stmt + ;
Valid statements are headers, comments, directives and production rules.
Stmt := Header | Comment | Rule | Directive ;
Grammar Documentation
Sarcasm are designed to generate both parser class and nice specification document of the grammar in MarkDown language.
MarkDown header syntax is directly supported for it can also be used to organize code in sections,
while other syntaxes should only be uesed in comments.
All literal contents will be directly copied into final MD document.
Directives, terminal declarations and rules will be formatted to a readable manner.
Some syntaxes (like grammar hint) will be filtered. Named consts, keywords will be displayed as literal instead of identifiers.
6 level of headers are supported, all starting with #s:
When grammar becomes more and more complex, Irony somethimes gets confused and produces conflicts.
Grammar hints are provided to resolve those conflicts.
Some hints are plain and simple:
SIMPLE_HINTS = [ "shift" "reduce" ] ;
Others are conditional:
CONDITIONAL_HINTS = [ "shiftIf" "reduceIf" ] ;
That it:
Hint := SIMPLE_HINTS | CONDITIONAL_HINTS "(" SimpleValueList ")" ;
Adding Things Up
We argument Nodes with Repeats and Hints
NodeExt := Node | Node Repeat reduce | Hint ;
When writing sequencially from left to right, we perform AND operation:
And := NodeOpt {} ;
Alternaitves are describle with or (|) operator:
Or := Production "|" Production ;
Wrapping Up
Mark transient non-terminals:
@transient Stmt Expr Header Comment SimpleValue Production Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters