kit

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

keywords_utf8.ebnf (817B)


      1 // utf8-mode %keywords fixture. The DFA is byte-oriented in both modes and the
      2 // keyword MPH is byte-level, so extraction works unchanged in utf8 mode — the
      3 // host (IDENT over XID scalars) stays in the DFA and keywords (including the
      4 // multi-byte "café" and "λ") are recovered by the minimal perfect hash. Held
      5 // byte-identical across the C and Python generators by the parity stamps and
      6 // excluded from NO_UNICODE builds.
      7 %lex :utf8 {
      8   %skip WS = \s+;
      9 
     10   INT   = [0-9]+;
     11   IDENT = [\p{XID_Start}] [\p{XID_Continue}]*;
     12 
     13   %keywords IDENT {
     14     IF     = "if";
     15     ELSE   = "else";
     16     WHILE  = "while";
     17     RETURN = "return";
     18     FUNC   = "fn";
     19     LET    = "let";
     20     CAFE   = "café";
     21     LAMBDA = "λ";
     22   }
     23 }
     24 
     25 program = item*;
     26 item = IF | ELSE | WHILE | RETURN | FUNC | LET | CAFE | LAMBDA | INT | IDENT;