rubyx/lib/parser/crystal.rb

35 lines
1.1 KiB
Ruby
Raw Normal View History

2014-04-27 15:30:32 +02:00
require_relative "basic_types"
require_relative "compound_types"
2014-04-27 17:13:10 +02:00
require_relative "tokens"
require_relative "keywords"
require_relative "control"
2014-05-10 10:14:34 +02:00
require_relative "expression"
require_relative "call_site"
2014-05-10 10:14:34 +02:00
require_relative "function_definition"
require_relative "operators"
2014-04-24 14:43:20 +02:00
module Parser
2014-04-27 17:13:10 +02:00
2014-04-29 15:22:12 +02:00
# obviously a work in progress !!
2014-04-27 17:13:10 +02:00
# We "compose" the parser from bits, divide and hopefully conquer
2014-05-10 10:14:34 +02:00
# a note about .maybe : .maybe is almost every respect the same as .repeat(0,1)
# so either 0, or 1, in other words maybe. Nice feature, but there are strings attached:
# a maybe removes the 0 a sequence (array) to a single (hash). Thus 2 transformations are needed
# More work than the prettiness is worth, so only use .maybe on something that does not need capturing
2014-05-10 10:03:23 +02:00
class Crystal < Parslet::Parser
2014-04-27 15:30:32 +02:00
include BasicTypes
# include CompoundTypes
2014-04-27 17:13:10 +02:00
include Tokens
include Keywords
include Control
2014-05-10 10:14:34 +02:00
include Expression
include CallSite
include FunctionDefinition
include Operators
2014-04-24 14:43:20 +02:00
2014-05-21 20:08:15 +02:00
rule(:root){ (function_definition | expression | operator_expression | call_site | space).repeat }
2014-04-24 14:43:20 +02:00
end
end