class LucidTDL::Parser macro BLANK [\ \t]+ rule {BLANK} # no action \#.*$ # no action \n { [:NEWLINE, text] } Feature: { [:FEATURE, text[0..-2]] } Ability: { [:ABILITY, text[0..-2]] } Responsibility: { [:RESPONSIBILITY, text[0..-2]] } Background: { [:BACKGROUND, text[0..-2]] } Context: { [:CONTEXT, text[0..-2]] } Scenario: { [:SCENARIO, text[0..-2]] } Test: { [:TEST, text[0..-2]] } @(\w|-)+ { [:TAG, text[1..-1]] } Given { [:GIVEN, text] } When { [:WHEN, text] } Then { [:THEN, text] } And { [:AND, text] } But { [:BUT, text] } \* { [:GENERIC, text] } [^#\n]* { [:TEXT, text.strip] } inner def tokenize(code) scan_setup(code) tokens = [] while token = next_token tokens << token end tokens end end