scriptGrammar
enum scriptGrammar = `
ScriptGrammar:
# This is a simple testing bed for grammars
Script <- (EmptyLine / Block)+ :eoi
Block <- Attribute? (:' ' Attribute)* (EnclosedBlock / OpenBlock) :Whitespace*
Attribute <- ( OSAttr )
OSAttr <- ('win' / 'linux')
EnclosedBlock <- :Whitespace* '{'
( :Whitespace* (Statement / Block) :Whitespace* )*
:Whitespace* '}' :Whitespace*
OpenBlock <- (:Whitespace* Statement :Whitespace*)
Statement <- :Whitespace* (Comment / Spawn / Send / Expect / Set / Import) :Spacing* :Whitespace*
Comment <: :Spacing* '#' (!eoi !endOfLine .)*
Spawn <- :"spawn" :Spacing* ToSpawn
ToSpawn <- (~Variable / ~String) :Spacing ('~' :Spacing ToSpawn)*
Send <- :"send" :Spacing* ToSend
ToSend <- (~Variable / ~String) :Spacing ('~' :Spacing ToSend)*
Expect <- :"expect" :Spacing* ToExpect
ToExpect <- (~Variable / ~String) :Spacing ('~' :Spacing ToExpect)*
Set <- :'set' :Spacing* SetVar :Spacing :'=' Spacing SetVal
SetVar <- ~VarName
SetVal <- (~Variable / ~String) :Spacing ('~' :Spacing SetVal)*
Import <- 'import' :Spacing* ToImport
ToImport <- (~Variable / ~String)
Keyword <~ ('#' / 'set' / 'expect' / 'spawn' / 'send')
KeywordData <~ (!eoi !endOfLine .)+
Variable <- :"$(" VarName :")"
VarName <- (!eoi !endOfLine !')' !'(' !'$' !'=' !'~' .)+
Text <- (!eoi !endOfLine !'~' .)+
DoubleQuoteText <- :doublequote
(!eoi !doublequote .)+
:doublequote
SingleQuoteText <- :"'"
(!eoi !"'" .)+
:"'"
String <- (
~DoubleQuoteText /
~SingleQuoteText /
~Text
)
Whitespace <- (Spacing / EmptyLine)
EmptyLine <- ('\n\r' / '\n')+
`;
Grammar to be parsed by pegged Potentially full of bugs