kit

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

mixfix.ebnf (584B)


      1 // Mixfix Pratt with a lexer, so the recursive-descent codegen backend can be
      2 // exercised both buffered and fused. Same operator table as pratt_mixfix.ebnf
      3 // (ternary ?:, circumfix call/index, member `.`) plus a small %lex.
      4 %lex {
      5   %skip WS = [ \t\r\n]+;
      6   NUMBER = [0-9]+;
      7   NAME   = [A-Za-z_] [A-Za-z0-9_]*;
      8 }
      9 
     10 %pratt expr {
     11   primary   primary;
     12   ternary   "?" ":";
     13   infixl    "+" "-";
     14   infixl    "*" "/";
     15   circumfix "(" args ")";
     16   circumfix "[" expr "]";
     17   infixl    ".";
     18 }
     19 
     20 primary  = NUMBER | NAME | "(" expr ")";
     21 args     = %empty | expr arg_more*;
     22 arg_more = "," expr;