Load gherkin parser considering language comment #109

Closed
wants to merge 1 commit into
from

4 participants

@vslinko

Basic support for i18n.

Problem is all languages but not EN throwing that error:

/Users/vyacheslav/Code/cucumber-js/node_modules/gherkin/lib/gherkin/lexer/ru.js:1614
 throw "Lexing error on line " + this.line_number + ": '" + content + "'. See 
                                                                    ^
Lexing error on line 2: 'Функционал: Сложение чисел'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information.

I'm think problem in generated gherkin lexers.
But I can't find where is problem because generated lexers isn't readable by normal human.

@vslinko

REF #34

@vslinko vslinko referenced this pull request in cucumber/gherkin2 Jan 28, 2013
Closed

Issue with i18n in cucumber-js #225

@jbpros
Cucumber member

Thank you @vslinko for this pull request. Have you tried loading the russian lexer module directly? Did that work?

@vslinko

@jbpros what are you mean directly, how is it?
I just run these features https://github.com/cucumber/cucumber/tree/master/examples/i18n using bin/cucumber.js

@vslinko

Error throws not only on russian, but on all languages except english.

@vslinko

Maybe helps.

Modified gherkin/lib/gherkin/lexer/ru.js, from line 1470:

    if (_lexer_trans_actions[_trans] != 0) {
        _acts = _lexer_trans_actions[_trans];
        _nacts = _lexer_actions[_acts];
        _acts += 1;
        while (_nacts > 0) {
            _nacts -= 1;
            _acts += 1;
            console.log(_lexer_actions[_acts - 1]) // <<< print used actions by lexer
            switch (_lexer_actions[_acts - 1]) {

Feature:

# language: ru
Функционал: Сложение чисел
  Чтобы не складывать в уме
  Все, у кого с этим туго
  Хотят автоматическое сложение целых чисел

  Сценарий: Сложение двух целых чисел
    Допустим я ввожу число 50
    И затем ввожу число 70
    Если я нажимаю "+"
    То результатом должно быть число 120

Output:

0
12
14
15
23

/Users/vyacheslav/Code/cucumber-js/node_modules/gherkin/lib/gherkin/lexer/ru.js:1615
 throw "Lexing error on line " + this.line_number + ": '" + content + "'. See 
                                                                    ^
Lexing error on line 2: 'Функционал: Сложение чисел'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information.

Numbers means actions:

0  - begin_content
12 - store_comment_content
14 - inc_line_number
15 - last_newline
23 - end_feature

Output when replace in my PR lexer(language).scan(featureSource.toString()); by lexer(language).scan(featureSource); (like before my PR):

0
12
14
15
23

buffer.js:559
  if (start > end) throw new Error('oob');
                         ^
Error: oob
    at Buffer.slice (buffer.js:559:26)
    at Lexer.current_line_content (/Users/vyacheslav/Code/cucumber-js/node_modules/gherkin/lib/gherkin/lexer/ru.js:1717:19)
    at Lexer.scan (/Users/vyacheslav/Code/cucumber-js/node_modules/gherkin/lib/gherkin/lexer/ru.js:1614:26)
    at Object.parse (/Users/vyacheslav/Code/cucumber-js/lib/cucumber/parser.js:28:25)
    at Object.getFeatures (/Users/vyacheslav/Code/cucumber-js/lib/cucumber/runtime.js:24:35)
    at Object.start (/Users/vyacheslav/Code/cucumber-js/lib/cucumber/runtime.js:10:37)
    at Object.runSuiteWithConfiguration (/Users/vyacheslav/Code/cucumber-js/lib/cucumber/cli.js:19:15)
    at Object.run (/Users/vyacheslav/Code/cucumber-js/lib/cucumber/cli.js:12:14)
    at Object.<anonymous> (/Users/vyacheslav/Code/cucumber-js/bin/cucumber.js:4:5)
    at Module._compile (module.js:449:26)

As seen buffer error throws after action 23-end_feature.

@bclozel

Does this PR need help? What's the status?
i18n is a missing feature adn I'd really like to help.

@vslinko

I'm migrate from cucumber to mocha, so you can try to continue my work.

@bclozel bclozel added a commit that referenced this pull request Mar 20, 2013
@bclozel bclozel used a modified patch made by @vslinko - see #109 2626af3
@aslakhellesoy
Cucumber member

Can you please add the test so we don't accidentally break this in the future?

@bclozel bclozel added a commit that referenced this pull request Sep 2, 2013
@bclozel bclozel used a modified patch made by @vslinko - see #109 a8ce515
@ldegen ldegen added a commit to ldegen/cucumber-js that referenced this pull request Jan 13, 2014
@bclozel bclozel used a modified patch made by @vslinko - see #109 6fa8f93
This was referenced Jan 13, 2014
Closed
@jbpros jbpros added a commit that closed this pull request Mar 5, 2014
@ldegen ldegen Add i18n support (close #156)
Also closes #34, closes #109 and closes #116.

Squashed commit of the following:

commit 8a6b2cfc6fbc32780dc94b17cb62285ee442bc8b
Author: Julien Biezemans <jb@jbpros.com>
Date:   Wed Mar 5 16:11:41 2014 +0100

    Bump TCK

commit 1a3c684d2d737d9dfff4cf6d95b923911f520ad0
Merge: 0beabd4 98a2725
Author: Julien Biezemans <jb@jbpros.com>
Date:   Wed Mar 5 16:05:11 2014 +0100

    Merge branch 'master' into i18n

commit 0beabd4
Author: Lukas Degener <l.degener@tarent.de>
Date:   Tue Sep 10 21:41:34 2013 +0200

    more flexible regexp for detecting language

commit b107286
Author: Brian Clozel <brian.clozel@gmail.com>
Date:   Wed Mar 20 18:26:40 2013 +0100

    update specs for i18n support

commit 6fa8f93
Author: Brian Clozel <brian.clozel@gmail.com>
Date:   Wed Mar 20 18:25:04 2013 +0100

    used a modified patch made by @vslinko - see #109
9ace841
@jbpros jbpros closed this in 9ace841 Mar 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment