This issue is currently mostly focused on parsing the bindings, not the actions. I'll update this soon
I currently propose the parser for dxhd to consist of 4 parts:
Tokenizer. This turns an input strings (e.g. shift + d + {b,c}) into a list of tokens like [Text("shift"), Plus, Text("d"), Plus, OptionStart, Text("b"), Comma, Text("c"), OptionEnd] that can be more easily read and understood. This can also remove whitespaces and possibly detect (but not handle) escape characters for control elements. (Is this necessary? might mess with the substitution logic for the action on a binding)
A lexer. This takes the tokens and creates syntax elements from them based on the information around them. For example, {0-9} would become a Range(0, 9) and an option list {a,b} would become Option(["a", "b"])
A desugarer for syntactic sugar elements. A range of for example {1-4} is no different than an option list of {1,2,3,4} and should be parsed as such.
A parser that will understand the remaining syntax elements
All parts except the tokenizer can throw an error. The tokenizer can't throw an error because it only transforms input into tokens that are representations of the input.
This issue is currently mostly focused on parsing the bindings, not the actions. I'll update this soon
I currently propose the parser for dxhd to consist of 4 parts:
shift + d + {b,c}
) into a list of tokens like [Text("shift"), Plus, Text("d"), Plus, OptionStart, Text("b"), Comma, Text("c"), OptionEnd] that can be more easily read and understood. This can also remove whitespaces and possibly detect (but not handle) escape characters for control elements. (Is this necessary? might mess with the substitution logic for the action on a binding){0-9}
would become aRange(0, 9)
and an option list{a,b}
would becomeOption(["a", "b"])
{1-4}
is no different than an option list of{1,2,3,4}
and should be parsed as such.All parts except the tokenizer can throw an error. The tokenizer can't throw an error because it only transforms input into tokens that are representations of the input.