Sha256: 426a3b6a60c738548644d6f195b196161b47da4bda2dd8166441d08de5ce0c5c

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

require 'parslet'

module Shift
	module Parser
		include Parslet

		rule(:addition_operator) { space? >> str('+') >> space? }
		rule(:subtraction_operator) { space? >> str('-') >> space? }
		rule(:multiplication_operator) { space? >> str('*') >> space? }
		rule(:division_operator) { space? >> str('/') >> space? }

		rule(:arithmetic_operator) { addition_operator | subtraction_operator | multiplication_operator | division_operator }


		rule(:and_operator) { space? >> str('&&') >> space? }
		rule(:or_operator) { space? >> str('||') >> space? }
		rule(:not_operator) { space? >> str('!') }

		rule(:boolean_operator) { and_operator | or_operator }

		
		rule(:assignment_operator) { space? >> str("=") >> space? }

		rule(:less_than_operator) { space? >> str("<") >> space? }
		rule(:greater_than_operator) { space? >> str(">") >> space? }
		rule(:equal_to_operator) { space? >> str("==") >> space? }
		rule(:less_than_or_equal_to_operator) { space? >> str("<=") >> space? }
		rule(:greater_than_or_equal_to_operator) { space? >> str(">=") >> space? }
		rule(:not_equal_to_operator) { space? >> str("!=") >> space? }

		rule(:conditional_operator) { less_than_or_equal_to_operator | greater_than_or_equal_to_operator | not_equal_to_operator | equal_to_operator | less_than_operator | greater_than_operator }

		rule(:query_find_operator) { less_than_or_equal_to_operator | greater_than_or_equal_to_operator | not_equal_to_operator | assignment_operator | less_than_operator | greater_than_operator }
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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