STELF's grammar
The grammar of STELF was designed with a couple goals in mind:
To be parsable with a finite amount of lookahead (usually only 1 token)
- Produce at most one output
Substituting one identifier for another will either change only the output at that identifier, or cause the parser to fail (all identifiers are syntactically equivalent), where an identifier is a sequence of non-whitespace charecters excluding
()[]{}%
Apart from this, there are a couple of other design choices that were made, including making STELF literate by default (per as a matter of fact STELF starts in markup mode)
The Core Lexical Syntax
Section titled “The Core Lexical Syntax”The core lexical syntax of STELF involves a couple different lexical classes.
- Whitespace: any sequence of charecters that have the property
White_Space=yesTODO - Commands any sequence of non-whitespace charecters that begins with
%and does not contain()[]{}% - Identifiers: any sequence of non-whitespace charecters that does not begin with
%and does not contain()[]{}%, this uses the longest match rule. - Special characters:
()[]{}% - Outer: any sequence of charecters up to
% - String literals,
%[, with variants%[[,%[[[, etc, that are terminated by%]with the same number of]s as[s. String literals can contain any charecters, including newlines and special characters, except%
Expressions
Section titled “Expressions”Full grammar
Section titled “Full grammar”The complete grammar, as expressed by the tree-sitter parser:
outer_text ::= ([^%]|\%\%\%)+
comment ::=
%[ \t][^\n]*
ident ::= [^ \t\n(){}\[\]%]+
nat ::= [0-9]+
mode ::=
%in%out%out1%star
_any ::= .+?
command ::=
<stop>
<sort_cmd>
<term_cmd>
<mode_cmd>
<worlds_cmd>
<total_cmd>
<terminates_cmd>
<reduces_cmd>
<query_cmd>
<qtab_cmd>
<adhoc_query>
<define_cmd>
<decl_cmd>
<inline_cmd>
<unique_cmd>
<prec_cmd>
<block_cmd>
<union_cmd>
<repl_cmd>
<name_cmd>
<symbol_cmd>
<freeze_cmd>
<thaw_cmd>
<deterministic_cmd>
<use_cmd>
<open_cmd>
<eval_cmd>
<covers_cmd>
stop ::= %.