spacepaste

  1.  
  2. parser_root : <root>+;
  3. root : <comment> | <definition> | <instruction> | <S> <EOL>;
  4. definition : <definition_start> <definition_statement>+;
  5. instruction : <instruction_start>? <instruction_statement> ((<S> (<action_code> | <action_code_segmented>))+)? <instruction_end>;
  6. definition_start : <hash>? <ISA_DEFINE> <S> <colon> <EOL>;
  7. definition_statement : <S> <definition_item>+;
  8. definition_item : <S> (<item> <S> ( <pair> | <single> ))? <S> <comment>? <EOL>;
  9. instruction_start : <ISA_DEFINE> <S> <colon>;
  10. instruction_statement : <S> <instruction_item>;
  11. instruction_item : <S> ('|' | <binary> (<action>+)? | <ISA_RULE> | <space> | <tab>)+;
  12. instruction_end : <S> <comment>? <EOL>;
  13. ISA_DEFINE : <word> (<action>+)?;
  14. ISA_RULE : <word> (<action>+)?;
  15. item : <bracketed_item> | <normal_item>;
  16. bracketed_item : '[' <word> ']' <colon>;
  17. normal_item : <word> <colon>;
  18. single : <word>;
  19. pair : <word> <colon> <word>;
  20. binary : /[01]+/;
  21. colon : ':';
  22. hash : '#';
  23. EOL : ( "\n" | "\r\n" | "\r" | ";" );
  24. comment : <S> (<single_line_comment> | <multi_line_comment>);
  25. single_line_comment : "//" /[^\r\n]*/;
  26. multi_line_comment : "/*" ("*/"! /.|\n/)+ "*/";
  27. name : '$' <word>;
  28. num : '#' <number>;
  29. indexedname : "${" <word> <num> '}';
  30. action_code : (<name> | <num> | <indexedname> | (<space> | <tab>)+)+ <action>+;
  31. word : /[a-zA-Z0-9]+/;
  32. number : /[0-9]+/;
  33. space : ' ';
  34. tab : "\t";
  35. SS : (<space> | <tab> | "\n");
  36. S : (<space> | <tab>)*;
  37. word_segmented : <SS>* <word>;
  38. number_segmented : <SS>* <number>;
  39. name_segmented : <SS>* '$' <word_segmented>+;
  40. num_segmented : <SS>* '#' <number_segmented>+;
  41. indexedname_segmented : <SS>* "$" <SS>* "{" <word_segmented>+ <num_segmented>+ <SS>* '}';
  42. action_code_segmented : (<name_segmented> | <num_segmented> | <indexedname_segmented> | <SS>+)+ <S> <action>+;
  43. action : <S> "{" ("}"! /.|\n/)+ "}";
  44.