4 Concrete Grammar🔗ℹ

The parser in "ick-bnf.rkt" is a brag grammar. The exact file is the most authoritative source, but the following excerpt captures the language accepted by the frontend after line cleaning and packed-SUB preprocessing:

program : line+

 

line : label? stmt

     | label

 

label : LPAREN NUMBER RPAREN

 

stmt : do-prefix* op do-postfix*

 

do-prefix : PLEASE

          | DO

          | NOT

          | MAYBE

          | PERCENT NUMBER

 

do-postfix : ONCE

           | AGAIN

 

op : assign

   | next

   | comefrom

   | readout

   | giveup

   | tryagain

   | writein

   | stash

   | retrieve

   | ignore

   | remember

   | forget

   | resume

   | abstain

   | reinstate

   | nothing

 

assign : var GETS expr

       | var GETS dim-list

 

next : target NEXT

comefrom : COME FROM target

readout : READ OUT expr

writein : WRITE IN var

forget : FORGET expr

resume : RESUME expr

giveup : GIVE UP

tryagain : TRY AGAIN

 

abstain : ABSTAIN FROM abstain-target

        | ABSTAIN expr FROM abstain-target

reinstate : REINSTATE abstain-target

 

var : DOT ident

    | STAR ident

    | COLON ident

    | SEMICOLON ident

    | COMMA ident

    | var SUB sublist

 

expr : mingle

mingle : select

       | mingle MINGLE select

select : unary

       | select SELECT unary

unary : UNARY_AND unary

      | UNARY_OR unary

      | UNARY_XOR unary

      | postfix

postfix : primary

        | postfix SUB sublist

primary : var

        | NUMBER

        | MESH NUMBER

        | SQUOTE expr SQUOTE

        | DQUOTE expr DQUOTE

Two practical notes:

  • The cleaner merges continuation lines before this grammar runs.

  • Packed subscript syntax from upstream programs is expanded before parsing, so the grammar sees explicit repeated SUB structure.