Syntax Reference¶
Below are syntax diagrams for Paxter language.
Document: Starting rule of Paxter language grammar. It is a special case of FragmentList rule, and thus the result is always a
FragmentListnode whose children are non-emptyTextinterleaving with the result produced by AtExpression rule.
AtExpression: Rule for parsing right after encountering @-switch symbol.
Note
The red
elsebox in this diagram indicates that such path can be followed only if the next token does not match any other possible paths. Pursuing thiselsepath does not consume anything.There are 2 possible scenarios.
A normal
Commandnode consisting of 3 sections: starter, options, and main argument, respectively.The starter section is resulted from parsing either greedily for an identifier or non-greedily for a text enclosed by a pair of bars plus and an equal number of zero or more hashes at both ends.
Following the starter section, if a left square bracket is found, then the option section as a list of tokens must be parsed and it will result in a
TokenListnode. Otherwise (if the left square bracket is absent), this option section will be represented byNone.Finally, the main argument section. (a) If there is zero or more hashes followed by a left brace, then the FragmentList parse rule must be followed and thus yields
FragmentListas the result.Warning
There is a restriction imposed on parsing the FragmentList rule, which is that the child text node may not contain a right brace followed by the same number of hashes as the preceding part. Otherwise, the parsing of FragmentList rule would have terminated earlier.
However, (b) if there is zero or more hashes followed by a quotation mark, then the text is parsed non-greedily until the another quotation mark followed by the same number of hashes is found.
Well, if both conditions (a) and (b) do not hold, then the main argument would be
None.A special
SingleSymbolnode where a single symbol follows the @-switch.
FragmentList: Consists of an interleaving of non-empty texts and results produced by AtExpression rule.
Note that the parsing of AtExpression rule at the previous level may put some restriction on the parsing of
Textnodes. For example, if preceding the fragment list is an opening brace pattern###{, then eachTextnode may contain}###.In other words, we non-greedily parses text within the fragment list.
TokenList: A sequence of zero or more tokens Each token either a command, an identifier, an operator, a number following JSON specification, a wrapped fragment list, a wrapped text, or a nested token list enclosed by a pair of square brackets
[]. The result is aTokenListnode type.
Note
The option section (or the token list) is the only place where whitespaces are ignored (when they appear between tokens).
Identifier: Generally follows Python rules for greedily parsing an identifier token (with some extreme exceptions). The result is an
Identifiernode type.
Operator: Greedily consumes as many operator character as possible (with two notable exceptions: a comma and a semicolon, which has to appear on their own). A whitespace may be needed to separate two consecutive, multi-character operator tokens. The result is an
Operatornode type.