2014-04-27 16:30:32 +03:00
|
|
|
require_relative "basic_types"
|
2014-05-12 21:36:38 +03:00
|
|
|
require_relative "compound_types"
|
2014-04-27 18:13:10 +03:00
|
|
|
require_relative "tokens"
|
2014-04-27 21:12:42 +03:00
|
|
|
require_relative "keywords"
|
2014-05-12 12:20:31 +03:00
|
|
|
require_relative "control"
|
2014-05-10 11:14:34 +03:00
|
|
|
require_relative "expression"
|
2014-05-13 21:15:02 +03:00
|
|
|
require_relative "call_site"
|
2014-05-10 11:14:34 +03:00
|
|
|
require_relative "function_definition"
|
2014-05-30 10:42:43 +03:00
|
|
|
require_relative "module_definition"
|
2014-05-11 18:37:26 +03:00
|
|
|
require_relative "operators"
|
2014-04-24 15:43:20 +03:00
|
|
|
|
2014-04-27 15:44:34 +03:00
|
|
|
module Parser
|
2014-04-27 18:13:10 +03:00
|
|
|
|
2014-04-29 16:22:12 +03:00
|
|
|
# obviously a work in progress !!
|
2014-04-27 18:13:10 +03:00
|
|
|
# We "compose" the parser from bits, divide and hopefully conquer
|
|
|
|
|
2014-05-10 11:14:34 +03: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 11:03:23 +03:00
|
|
|
class Crystal < Parslet::Parser
|
2014-04-27 16:30:32 +03:00
|
|
|
include BasicTypes
|
2014-05-27 15:36:51 +03:00
|
|
|
include CompoundTypes
|
2014-04-27 18:13:10 +03:00
|
|
|
include Tokens
|
2014-04-27 21:12:42 +03:00
|
|
|
include Keywords
|
2014-05-12 12:20:31 +03:00
|
|
|
include Control
|
2014-05-10 11:14:34 +03:00
|
|
|
include Expression
|
2014-05-13 21:15:02 +03:00
|
|
|
include CallSite
|
2014-05-11 18:37:26 +03:00
|
|
|
include FunctionDefinition
|
|
|
|
include Operators
|
2014-05-29 15:57:33 +03:00
|
|
|
include ModuleDef
|
2014-04-24 15:43:20 +03:00
|
|
|
|
2014-05-30 10:59:49 +03:00
|
|
|
rule(:root){ (module_definition | class_definition | function_definition | expression | call_site ).repeat }
|
2014-04-24 15:43:20 +03:00
|
|
|
end
|
|
|
|
end
|