cenotelie / hime

Apache License 2.0
27 stars 4 forks source link

fixed issue 109: In memory grammar #110

Closed xuanbachle closed 1 month ago

xuanbachle commented 1 month ago

Referring to issue 109: https://github.com/cenotelie/hime/issues/109 and also other related issues such as 104: https://github.com/cenotelie/hime/issues/104.

The problem is with the in memory parser in which: (1) the function build_in_memory_grammar incorrectly initializes/writes the parser with lrk when the option is_rnglr is True. (2) the SDK incorrectly initializes the lexer as ContextFree when the option lexer_is_context_sensitive is True.

Therefore, the fix is to negate the conditions if the if conditions so that the lexer and the parser are created with the right kinds, e.g., LRK parser and ContextFree lexer.

A test case is attached for this bug fix.