% this is /athe/a/toni/papers/semiotes/grammar.bnf % cut and pasted from the grammar.tex file in /sthenias/a/the_agora/code/trade/semiotes/manual; % make sure this is identical to the backed-up one from last fall (can also check % slide for 341). % Kazic, 17.1.02. % This is a BNF specification of a left-recursive, context-free grammar for the % Glossa. It is in ASCII with tab-delimited fields, one rule/line. % With very little alteration it should be suitable as input for a look-ahead % 1 character left-right parser generator, such as YACC and CUP. % I haven't included definitions of things like alphanumeric characters, % upper and lower case, numerals, etc., thinking those are pretty obvious. % Numbers can be either floating point or integer. I've also skipped lines % for visual clarity, even among alternative right hand sides. % This is the most current form of the grammar; grammar.bnf is older and % contains the quandries about we resolved. Kazic, 5.1.01. % syntax is: % nonterminal is represented as % terminal is in UPPERCASE or between '' (e.g. '*') % a text description is just a plain string % comments begin with % % Kazic. 11.4.00. and 8.8.00. ::= ::= | | | | | | | | ::= | | | FUNCTOR ::= FUNCTOR | FUNCTOR | FUNCTOR ::= FUNCTOR % the null statement; how this is coded likely depends on the particular % parser's language | | FUNCTOR FUNCTOR ::= alphanumeric, underscore string beginning with lower-case letter ::= | | | ::= | ::= | ::= VARIABLE ::= 'variable' VARIABLE ::= alphanumeric string ::= empty string, atom, term, or functor ::= | ::= | | | ::= | | | ::= '{' ::= '}' ::= '(' ::= ')' ::= '[' ::= ']' ::= '( ' ::= ' )' ::= FUNCTOR | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | % Operator classification % The greater the precedence integer, the higher % the precedence. Semantics follows the common programming standards; different % operators are used to assign values to variables and to assign the numerical result % of a computed expression to a variable. Similarly, different operators are used % for numerical and string comparisons. No standard string comparison operators have % been assigned since string sort criteria seem to vary among programming languages. % The 'surround' operator type is really a prefix operator but with a closing right % parenthesis; both must be present. It's written this way for tokenizer benefit. % Notice that many of these operators are for embedding Glossa code within a % transmission, NOT for simply reporting back what the computed value of some % variable is. So, do not misread = as a Variable = ComputedValue statement. % Instead, values which have been computed are returned wrapped in their corresponding % functor, JUST AS they are when the values are input in a transmission. % % Kazic, 17.1.02. nonterminal terminal type assoc precedence ::= '%' prefix right 1400 ::= ':-' infix none 1200 ::= '||' infix right 1100 ::= 'else' prefix right 1100 ::= 'if' prefix right 1050 ::= 'then' prefix right 1050 ::= 'for' prefix right 1050 ::= 'do' prefix right 1050 ::= '&&' infix right 1000 ::= '!' prefix right 900 ::= '=' infix none 700 ::= 'is' infix none 700 ::= '<' infix none 700 ::= '>' infix none 700 ::= '=<' infix none 700 ::= '>=' infix none 700 ::= '==' infix none 700 ::= 'eq' infix none 700 ::= '!=' infix none 700 ::= 'neq' infix none 700 ::= '+' infix left 500 ::= '-' infix left 500 ::= '-' prefix right 500 ::= '*' infix left 400 ::= '/' infix left 400 ::= 'mod' infix none 300 ::= '^' infix right 200 ::= 'setof(' ')' surround interior 100 ::= 'union(' ')' surround interior 100 ::= 'intersection(' ')' surround interior 100 ::= '@@' prefix right 100 ::= '%%' prefix right 100 ::= ',' infix none 50 ::= '.' postfix left 20