Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load gherkin parser considering language comment #109

Closed
wants to merge 1 commit into from
Closed

Load gherkin parser considering language comment #109

wants to merge 1 commit into from

Conversation

vslinko
Copy link

@vslinko vslinko commented Jan 28, 2013

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
Copy link
Author

vslinko commented Jan 28, 2013

REF #34

@jbpros
Copy link
Member

jbpros commented Jan 28, 2013

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

@vslinko
Copy link
Author

vslinko commented Jan 28, 2013

@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
Copy link
Author

vslinko commented Jan 28, 2013

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

@vslinko
Copy link
Author

vslinko commented Jan 28, 2013

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
Copy link

bclozel commented Mar 20, 2013

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

@vslinko
Copy link
Author

vslinko commented Mar 20, 2013

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

@aslakhellesoy
Copy link
Contributor

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

ldegen pushed a commit to ldegen/cucumber-js that referenced this pull request Jan 13, 2014
@ldegen ldegen mentioned this pull request Jan 13, 2014
Closed
@ldegen ldegen mentioned this pull request Feb 21, 2014
@jbpros jbpros closed this in 9ace841 Mar 5, 2014
@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants