xbnf-vscodeVScode addon for Xbnf. Xbnf is a bnf-like definition language for parsing and lexing. It was written because there are to many variations of bnf, ebnf and abnf out there and I needed one that fit my needs. Rather to spend eons researching wich i could use, i simply designed one myself, loesly based on ebnf and abnf. Writing XbnfFirst thing first, Xbnf allows comments:
A definition in Xbnf is the assosiaction of a symbol (name) with rules / syntax. There are two kinds of definitions: 'Rules' and 'Tokens'. RuleA rule is simply a definition of things that must occur in a specific order. For example a variable definiton in a programming language can be covered by a rule:
The rule above would trigger by a string like this:
A important thing about rules is, that their parts can have any number of linear whitespace (spaces and tabulators) between them when it's atleast one whitespace apart. Alternative string that would also trigger the rule:
But this would'nt trigger the rule:
and this neither:
Concatination-OperatorIn order to allow no whitespace between parts of a rule, there is the concatination operator:
Examples:
Note: with the Or-OperatorYou already know one operator: the concatination operator
The above rule is triggered when either the string GroupingXbnf allows grouping of parts in a rule:
A group of parts itself behaves like a part, and can recievbed specifiers on it's own. But apart of that they do not have any special features. SpecifiersA specifier is used to specifiey how often a part can occur on its given place:
This can be used for example in lists:
Example input:
A specifier is part of the rule-part its attached to, means that the concatination operator before the group/part is applied on the resultat of the specifier: For example:
Input:
TokenA token is a group of characters like To name a token you write its symbol all uppercase:
|