Permalink
Browse files

Parse locale

  • Loading branch information...
josepjaume committed May 18, 2012
1 parent 7ba6d4b commit 820a7240955a4e57c2a3804ca5e4747b2cb71142
View
@@ -83,5 +83,9 @@ def initialize(name)
@name = name
end
end
+
+ class Locale < Node
+ attr_reader :name, :keyword
+ end
end
end
@@ -6,6 +6,7 @@ macro
BLANK [\ \t]+
rule
+ \#\s?locale: { [:LOCALE, text[0..-2]] }
# Whitespace
{BLANK} # no action
\#.*$
@@ -4,6 +4,7 @@ class Gherkin::Parser
# Declare tokens produced by the lexer
token NEWLINE
+token LOCALE
token FEATURE BACKGROUND SCENARIO
token TAG
token GIVEN WHEN THEN AND BUT
@@ -12,12 +13,21 @@ token TEXT
rule
Root:
+ Locale { result = val[0]; }
+ |
+ Feature { result = val[0] }
+ |
Feature { result = val[0]; }
|
Feature
Scenarios { result = val[0]; result.scenarios = val[1] }
;
+ Locale:
+ LOCALE TEXT { result = val[1] }
+ | LOCALE TEXT Newline { result = val[1] }
+
+
Newline:
NEWLINE
| Newline NEWLINE
@@ -59,6 +59,9 @@ def _next_token
token = case @state
when nil
case
+ when (text = @ss.scan(/\#\s?locale:/))
+ action { [:LOCALE, text[0..-2]] }
+
when (text = @ss.scan(/[ \t]+/))
;
Oops, something went wrong.

0 comments on commit 820a724

Please sign in to comment.