Sha256: 83628d4a7857f36c877874b24df121fca767dfdb9244162a0eea496d185befaa

Contents?: true

Size: 872 Bytes

Versions: 4

Compression:

Stored size: 872 Bytes

Contents

require 'parslet'

module Shift
	module Parser
		include Parslet

		rule(:cud_keyword) { new_keyword | all_keyword | update_keyword | delete_keyword }

		rule(:cud_query) { cud_keyword.as(:operation) >> space >> identifier.as(:model_name) }

		rule(:find_by_id_query) { find_by_id_keyword.as(:operation) >> space >> identifier.as(:model_name) >> variables.as(:item_id) }

		rule(:find_condition) { space? >> identifier.as(:attribute) >> space? >> query_find_operator.as(:operator) >> space? >> value_returning_expression.as(:value) >> space?}

		rule(:find_query) { find_keyword.as(:operation) >> space >> identifier.as(:model_name) >> space >> where_keyword >> find_condition.as(:condition) >> (space? >> comma >> space? >> find_condition.as(:condition)).repeat(0) }

		rule(:query) { find_query.as(:query) | find_by_id_query.as(:query) | cud_query.as(:query) }

	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shift-lang-0.1.4 lib/shift-lang/parser/db_query_parser.rb
shift-lang-0.1.3 lib/shift-lang/parser/db_query_parser.rb
shift-lang-0.1.2 lib/shift-lang/parser/db_query_parser.rb
shift-lang-0.1.1 lib/shift-lang/parser/db_query_parser.rb