Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic/Associated context sensitive rules? #90

Open
stevefan1999-personal opened this issue Oct 14, 2023 · 1 comment
Open

Dynamic/Associated context sensitive rules? #90

stevefan1999-personal opened this issue Oct 14, 2023 · 1 comment
Labels
question Further information is requested wontfix This will not be worked on

Comments

@stevefan1999-personal
Copy link
Contributor

stevefan1999-personal commented Oct 14, 2023

Consider an XML file:

<foo>
</foo>

And this:

<foo>
</bar>

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:

def foo():
  if bar:
    return "foo bar"

Related: #53

@woutersl
Copy link
Member

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.

@woutersl woutersl added question Further information is requested wontfix This will not be worked on labels Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants