Browse Source

Merge branch 'fix-utf8-python2' with fixes

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.1
Erez Shinan 7 years ago
parent
commit
00c37caa23
2 changed files with 20 additions and 1 deletions
  1. +3
    -1
      .travis.yml
  2. +17
    -0
      tests/test_parser.py

+ 3
- 1
.travis.yml View File

@@ -8,4 +8,6 @@ python:
- "3.6"
- "pypy" # PyPy2 2.5.0
- "pypy3" # Pypy3 2.4.0
script: python -m tests
script:
- pip install -r nearley-requirements.txt
- python -m tests

+ 17
- 0
tests/test_parser.py View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import unittest
@@ -875,6 +876,22 @@ def _make_parser_test(LEXER, PARSER):
self.assertEqual(''.join(child.data for child in res.children), 'indirection')


def test_utf8(self):
g = u"""start: a
a: "±a"
"""
l = _Lark(g)
self.assertEqual(l.parse(u'±a'), Tree('start', [Tree('a', [])]))

g = u"""start: A
A: "±a"
"""
l = _Lark(g)
self.assertEqual(l.parse(u'±a'), Tree('start', [u'\xb1a']))




_NAME = "Test" + PARSER.capitalize() + (LEXER or 'Scanless').capitalize()
_TestParser.__name__ = _NAME
globals()[_NAME] = _TestParser


Loading…
Cancel
Save