Open stevefan1999-personal opened 11 months ago
Thing is, Hime handles context-free grammars (with some extensions for context-sensitive lexing indeed). XML is a prime example of context-sensitive grammar with the repetition of the tag name for closing tags.
Handling (and defining!) such grammars is a huge undertaking, outside the scope of Hime. In general for such languages, people hand-roll their own parsing scheme. See the plethora of XML parsers and the headache that is parsing Python.
Consider an XML file:
And this:
Clearly the latter is wrong. Right now there is no way to add tags with regards to context sensitive rules in runtime but only lexical scope: https://cenotelie.fr/projects/hime/referenceLangContextSensitive
Technically speaking, whitespace sensitive programming language like Python also fall under this category of having associated data in runtime.
In this case, we track the number of whitespaces and try our best to match their multiplications on each line For example, I have 2 whitespaces predating on line 2, so I should have 4 whitespaces or 2 whitespace per indent x at least 2 indents = at least 4 whitespaces:
Related: #53