Skip to content

fix: ignore UTF-8 BOM when loading grammars - #1701

Open
Gary7702 wants to merge 1 commit into
lark-parser:masterfrom
Gary7702:fix/skip-grammar-bom
Open

Gary7702 wants to merge 1 commit into
lark-parser:masterfrom
Gary7702:fix/skip-grammar-bom

Conversation

@Gary7702

Copy link
Copy Markdown

Fixes #407.

A leading UTF-8 BOM was previously parsed as part of the grammar text and caused a GrammarError. This strips a single leading U+FEFF when grammar text enters Lark and when GrammarBuilder loads a grammar, covering inline grammars, Lark.open(), and %import-ed grammars.

Three regression tests cover inline grammar text, a grammar file, and an imported grammar with a BOM. The full test suite passes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skip BOM (Byte order mark)

1 participant