lark-parser / lark_cython

Cython plugin for Lark, reimplementing the LALR parser & lexer for better performance
MIT License
45 stars 5 forks source link

Tests fail with the lastet Lark (unexpected keyword argument strict). #23

Closed Erotemic closed 1 year ago

Erotemic commented 1 year ago

With the latest version of Lark, lark-cython tests throw the following errors:

FAILED tests/test_basic.py::test_minimal - TypeError: __init__() got an unexpected keyword argument 'strict'
FAILED tests/test_basic.py::test_lark_meta_propagation - TypeError: __init__() got an unexpected keyword argument 'strict'
FAILED tests/test_basic.py::test_no_placeholders - TypeError: __init__() got an unexpected keyword argument 'strict'
FAILED tests/test_basic.py::test_start - TypeError: __init__() got an unexpected keyword argument 'strict'
FAILED tests/test_basic.py::test_lexer_callbacks - TypeError: __init__() got an unexpected keyword argument 'strict'

One example test failure is:


    def test_lexer_callbacks():
        comments = []

>       parser = Lark("""
            start: INT*

            COMMENT: /#.*/

            %import common (INT, WS)
            %ignore COMMENT
            %ignore WS
        """, parser="lalr", _plugins=lark_cython.plugins, lexer_callbacks={'COMMENT': comments.append})

tests/test_basic.py:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/lark/lark.py:438: in __init__
    self.parser = self._build_parser()
../../.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/lark/lark.py:484: in _build_parser
    return _construct_parsing_frontend(
../../.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/lark/parser_frontends.py:253: in _construct_parsing_frontend
    return ParsingFrontend(lexer_conf, parser_conf, options)
../../.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/lark/parser_frontends.py:58: in __init__
    self.parser = create_parser(lexer_conf, parser_conf, options)
../../.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/lark/parser_frontends.py:157: in create_lalr_parser
    return cls(parser_conf, debug=debug, strict=strict)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   def __init__(self, parser_conf, debug=False):
E   TypeError: __init__() got an unexpected keyword argument 'strict'

lark_cython/lark_cython.pyx:570: TypeError

I think this means that lark-cython needs to add the "strict" option. Not sure what else will need to happen.

erezsh commented 1 year ago

Thank you for reporting it!