require 'parslet' module Shift module Parser include Parslet rule(:url_method) { get_keyword.as(:url_method) | post_keyword.as(:url_method) } rule(:url_variable) { colon >> identifier.as(:url_variable) } rule(:url_token) { (url_variable | identifier.as(:url_token)) >> fwd_slash.maybe } rule(:url) { fwd_slash >> url_token.repeat(0) } rule(:model_definition_statement) { model_keyword >> space >> identifier.as(:model_name) } rule(:model_attribute_type) { string_keyword | integer_keyword } rule(:model_attribute_definition_statement) { identifier.as(:attribute_name) >> space >> model_attribute_type.as(:attribute_type) } rule(:model_definition) { model_definition_statement.as(:model_definition_statement) | model_attribute_definition_statement.as(:model_attribute_definition_statement) } rule(:write_statement) { write_keyword >> space >> string_valued_expression.as(:write_statement_param) } rule(:write_file_statement) { write_file_keyword >> space >> string_valued_expression.as(:file_name) >> (space? >> comma >> space? >> variables).as(:template_values).repeat(0) } rule(:redirect_statement) { redirect_keyword >> space >> string_valued_expression.as(:redirect_statement_param) } end end