jweinst1
3/29/2017 - 6:46 AM

new parser for pegjs

new parser for pegjs

//parser for Xenon language
//language to be a sketchbook
//data interchange language

Document
  = e:Element* {
      return {node:"document", args:e};
  }
  
Element
  = _ c:CodeBlock {return c;}
  / _ t:Text {return t;} 
  
Text
  = "'" t:[^']+ "'" {return {node:",text", args:[t.join("")]};}
  
CodeBlock
  = "{" code:JSCode "}" { return {node:",jscode", args:[code]};} 

JSCode
  = $((![{}] .)+ / "{" JSCode "}")*

_ "whitespace"
  = [ \t\n\r]*