From 5261edbd30558c6bc59bb952b9edac73e285f5d6 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 27 Aug 2015 21:01:12 +0300 Subject: [PATCH] change to citrus wip --- lib/parser/salama.rb | 62 +++++++++++++++++++++---------------------- lib/salama-reader.rb | 4 +-- salama-reader.gemspec | 2 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/parser/salama.rb b/lib/parser/salama.rb index aa66b55..37dde92 100644 --- a/lib/parser/salama.rb +++ b/lib/parser/salama.rb @@ -1,38 +1,38 @@ -require_relative "basic_types" -require_relative "compound_types" -require_relative "tokens" -require_relative "keywords" -require_relative "control" -require_relative "expression" -require_relative "call_site" -require_relative "function_definition" -require_relative "module_definition" -require_relative "operators" +#require_relative "basic_types" +#require_relative "compound_types" +#require_relative "tokens" +#require_relative "keywords" +#require_relative "control" +#require_relative "expression" +#require_relative "call_site" +#require_relative "function_definition" +#require_relative "module_definition" +#require_relative "operators" + +require 'ast/expression' module Parser - + # obviously a work in progress !! # We "compose" the parser from bits, divide and hopefully conquer - - # 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 - class Salama < Parslet::Parser - include BasicTypes - include CompoundTypes - include Tokens - include Keywords - include Control - include Expression - include CallSite - include FunctionDefinition - include Operators - include ModuleDef + Citrus.require "parser/basic" + Citrus.require "parser/keywords" - rule(:root_body) {(module_definition | class_definition | function_definition | expression | - operator_expression | call_site | basic_type | hash_constant | array_constant )} - rule(:root) { root_body.repeat.as(:expression_list) } - end +# class Salama < Parslet::Parser +# include BasicTypes +# include CompoundTypes +# include Tokens +# include Keywords +# include Control +# include Expression +# include CallSite +# include FunctionDefinition +# include Operators +# include ModuleDef + +# rule(:root_body) {(module_definition | class_definition | function_definition | expression | +# operator_expression | call_site | basic_type | hash_constant | array_constant )} +# rule(:root) { root_body.repeat.as(:expression_list) } +# end end diff --git a/lib/salama-reader.rb b/lib/salama-reader.rb index 2c37050..e4333fd 100644 --- a/lib/salama-reader.rb +++ b/lib/salama-reader.rb @@ -1,3 +1,3 @@ -require 'parslet' +require 'citrus' require 'parser/salama' -require 'parser/transform' +#require 'parser/transform' diff --git a/salama-reader.gemspec b/salama-reader.gemspec index a74146e..8540213 100644 --- a/salama-reader.gemspec +++ b/salama-reader.gemspec @@ -13,6 +13,6 @@ Gem::Specification.new do |s| s.require_paths = ['lib'] s.summary = 'Ruby parser for the salama machine' - s.add_dependency 'parslet', '~> 1.7.0' + s.add_dependency 'citrus', '~> 3.0.3' end