dxhd icon indicating copy to clipboard operation
dxhd copied to clipboard

Parser Proposal

Open NotUnlikeTheWaves opened this issue 3 years ago • 1 comments

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:

  1. 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)
  2. 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"])
  3. 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.
  4. 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.

NotUnlikeTheWaves avatar Jun 20 '21 22:06 NotUnlikeTheWaves

Sounds good to me :+1:

dakyskye avatar Jun 20 '21 22:06 dakyskye