require 'parslet' module Shift module Parser include Parslet rule(:if_statement) { if_keyword >> space >> (conditional_statement | boolean_valued_expression).as(:condition)} rule(:for_statement) { for_keyword >> space >> primitives >> in_keyword >> primitives } rule(:while_statement) { while_keyword >> space >> (conditional_statement | boolean_valued_expression).as(:condition) } rule(:control_statement) { if_statement.as(:if_statement) | else_keyword.as(:else_statement) | for_statement.as(:for_statement) | while_statement.as(:while_statement) } end end