kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

desugar.ebnf (737B)


      1 // Front-end desugaring fixture: %def fragments, the `+` and `{n,m}` quantifiers,
      2 // and ASCII shorthand classes (standalone and inside `[...]`). Byte mode, so it
      3 // also builds under NO_UNICODE. Held byte-identical across the C and Python
      4 // generators by the parity stamps and exercised at runtime by test_desugar.c.
      5 %lex {
      6   %def digit  = [0-9];
      7   %def hexit  = [0-9a-fA-F];
      8   %def hexnum = "0x" hexit ("_"? hexit)*;   // fragments may use fragments
      9 
     10   %skip WS = \s+;
     11   HEX    = hexnum;
     12   FLOAT  = digit+ "." digit+ (("e" | "E") ("+" | "-")? digit+)?;
     13   INT    = digit ("_"? digit)*;
     14   IDENT  = [A-Za-z_] \w*;
     15   PERCENT = "%" digit{2};
     16   OP     = [+*/\-]{1,2};
     17 }
     18 
     19 program = item*;
     20 item    = HEX | FLOAT | INT | IDENT | PERCENT | OP;