Browse Source

Fixed issue #425, keeping in mind unicode issue #411

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.7.4
Erez Shinan 5 years ago
parent
commit
7e8488d1a0
2 changed files with 4 additions and 4 deletions
  1. +1
    -1
      lark/lexer.py
  2. +3
    -3
      lark/load_grammar.py

+ 1
- 1
lark/lexer.py View File

@@ -101,7 +101,7 @@ class Token(Str):


self.type = type_ self.type = type_
self.pos_in_stream = pos_in_stream self.pos_in_stream = pos_in_stream
self.value = Str(value)
self.value = value
self.line = line self.line = line
self.column = column self.column = column
self.end_line = end_line self.end_line = end_line


+ 3
- 3
lark/load_grammar.py View File

@@ -12,7 +12,7 @@ from .parse_tree_builder import ParseTreeBuilder
from .parser_frontends import LALR_TraditionalLexer from .parser_frontends import LALR_TraditionalLexer
from .common import LexerConf, ParserConf from .common import LexerConf, ParserConf
from .grammar import RuleOptions, Rule, Terminal, NonTerminal, Symbol from .grammar import RuleOptions, Rule, Terminal, NonTerminal, Symbol
from .utils import classify, suppress, dedup_list
from .utils import classify, suppress, dedup_list, Str
from .exceptions import GrammarError, UnexpectedCharacters, UnexpectedToken from .exceptions import GrammarError, UnexpectedCharacters, UnexpectedToken


from .tree import Tree, SlottedTree as ST from .tree import Tree, SlottedTree as ST
@@ -451,9 +451,9 @@ class PrepareSymbols(Transformer_InPlace):
if isinstance(v, Tree): if isinstance(v, Tree):
return v return v
elif v.type == 'RULE': elif v.type == 'RULE':
return NonTerminal(v.value)
return NonTerminal(Str(v.value))
elif v.type == 'TERMINAL': elif v.type == 'TERMINAL':
return Terminal(v.value, filter_out=v.startswith('_'))
return Terminal(Str(v.value), filter_out=v.startswith('_'))
assert False assert False


def _choice_of_rules(rules): def _choice_of_rules(rules):


Loading…
Cancel
Save