kit

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

ident_call.ebnf (867B)


      1 // RED FIXTURE — does not compile; preserved on purpose.
      2 //
      3 // A primary that is either a bare name or a call, written the obvious way:
      4 //   primary = ... | IDENT | call ;
      5 //   call    = IDENT "(" args? ")" ;
      6 // Both alternatives start with IDENT, a FIRST/FIRST conflict. The fix is manual
      7 // left-factoring through a `call_tail = "(" args? ")" | %empty` (see
      8 // clike.ebnf). A real language grammar hits this for every "name or call",
      9 // "name or index", "name or field access" pair.
     10 //
     11 // Observed diagnostic (note the bogus location):
     12 //   red/ident_call.ebnf:NNN:1: error: LL(1) conflict in primary: token 'IDENT'
     13 //   selects alternative 1 and alternative 2
     14 %lex {
     15   %skip WS = [ \t\r\n]+;
     16   IDENT = [A-Za-z_] [A-Za-z0-9_]*;
     17   INT   = [0-9]+;
     18 }
     19 
     20 primary = INT | IDENT | call;
     21 call    = IDENT "(" args? ")";
     22 args    = primary arg_tail*;
     23 arg_tail = "," primary;