sexpr 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/CHANGELOG.md +16 -0
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +14 -14
  4. data/Rakefile +0 -4
  5. data/examples/bool_expr/bool_expr.rb +1 -95
  6. data/lib/sexpr/grammar/matching.rb +3 -3
  7. data/lib/sexpr/grammar/parsing.rb +1 -1
  8. data/lib/sexpr/grammar/tagging.rb +16 -13
  9. data/lib/sexpr/loader.rb +1 -0
  10. data/lib/sexpr/matcher.rb +3 -2
  11. data/lib/sexpr/matcher/many.rb +16 -1
  12. data/lib/sexpr/matcher/non_terminal.rb +31 -0
  13. data/lib/sexpr/matcher/rule.rb +3 -6
  14. data/lib/sexpr/node.rb +1 -1
  15. data/lib/sexpr/parser.rb +1 -1
  16. data/lib/sexpr/processor.rb +11 -1
  17. data/lib/sexpr/processor/helper.rb +1 -1
  18. data/lib/sexpr/processor/sexpr_coercions.rb +6 -14
  19. data/lib/sexpr/rewriter.rb +0 -8
  20. data/lib/sexpr/version.rb +3 -3
  21. data/sexpr.gemspec +3 -3
  22. data/sexpr.noespec +13 -6
  23. data/spec/integration/bool_expr/test_not_push.rb +38 -0
  24. data/spec/integration/bool_expr/test_parsing.rb +15 -0
  25. data/spec/integration/bool_expr/test_tagging.rb +25 -0
  26. data/spec/integration/bool_expr/test_validation.rb +15 -0
  27. data/spec/{test_readme_examples.rb → integration/test_readme_examples.rb} +0 -0
  28. data/spec/spec_helper.rb +1 -1
  29. data/spec/unit/grammar/matching/test_compile_rule.rb +55 -0
  30. data/spec/{grammar → unit/grammar}/matching/test_compile_rule_defn.rb +0 -0
  31. data/spec/unit/grammar/matching/test_compile_rules.rb +45 -0
  32. data/spec/{grammar → unit/grammar}/options/test_install_parser.rb +0 -0
  33. data/spec/{grammar → unit/grammar}/options/test_install_path.rb +0 -0
  34. data/spec/{grammar → unit/grammar}/options/test_install_root.rb +0 -0
  35. data/spec/{grammar → unit/grammar}/tagging/test_looks_a_sexpr.rb +0 -0
  36. data/spec/{grammar → unit/grammar}/tagging/test_mod2rulename.rb +0 -0
  37. data/spec/{grammar → unit/grammar}/tagging/test_rule2modname.rb +0 -0
  38. data/spec/{grammar → unit/grammar}/tagging/test_tag_sexpr.rb +0 -0
  39. data/spec/unit/grammar/tagging/test_tagging_module_for.rb +72 -0
  40. data/spec/{grammar → unit/grammar}/test_new.rb +0 -0
  41. data/spec/{grammar → unit/grammar}/test_parse.rb +0 -0
  42. data/spec/{grammar → unit/grammar}/test_sexpr.rb +0 -0
  43. data/spec/{matcher → unit/matcher}/alternative/test_eat.rb +1 -1
  44. data/spec/{matcher → unit/matcher}/alternative/test_match_q.rb +0 -0
  45. data/spec/{matcher → unit/matcher}/many/test_eat.rb +0 -0
  46. data/spec/{matcher → unit/matcher}/many/test_initialize.rb +0 -0
  47. data/spec/{matcher → unit/matcher}/many/test_match_q.rb +0 -0
  48. data/spec/unit/matcher/non_terminal/test_eat.rb +31 -0
  49. data/spec/unit/matcher/non_terminal/test_match_q.rb +32 -0
  50. data/spec/{matcher → unit/matcher}/reference/test_eat.rb +0 -0
  51. data/spec/{matcher → unit/matcher}/reference/test_match_q.rb +0 -0
  52. data/spec/unit/matcher/rule/test_eat.rb +17 -0
  53. data/spec/unit/matcher/rule/test_match_q.rb +17 -0
  54. data/spec/{matcher → unit/matcher}/sequence/test_eat.rb +0 -0
  55. data/spec/{matcher → unit/matcher}/sequence/test_match_q.rb +0 -0
  56. data/spec/{matcher → unit/matcher}/terminal/test_eat.rb +1 -1
  57. data/spec/{matcher → unit/matcher}/terminal/test_match_q.rb +0 -0
  58. data/spec/{matcher → unit/matcher}/terminal/test_terminal_match.rb +0 -0
  59. data/spec/{node → unit/node}/test_sexpr_body.rb +0 -0
  60. data/spec/{node → unit/node}/test_sexpr_copy.rb +0 -0
  61. data/spec/{node → unit/node}/test_sexpr_type.rb +0 -0
  62. data/spec/{node → unit/node}/test_tracking_markers.rb +0 -0
  63. data/spec/{parser → unit/parser}/citrus/test_new.rb +0 -0
  64. data/spec/{parser → unit/parser}/citrus/test_parse.rb +0 -0
  65. data/spec/{parser → unit/parser}/citrus/test_recognize.rb +0 -0
  66. data/spec/{parser → unit/parser}/citrus/test_registration.rb +0 -0
  67. data/spec/{parser → unit/parser}/citrus/test_to_sexpr.rb +0 -0
  68. data/spec/{parser → unit/parser}/test_factor.rb +0 -0
  69. data/spec/{parser → unit/parser}/test_input_text.rb +0 -0
  70. data/spec/{processor → unit/processor}/helper/test_call.rb +0 -0
  71. data/spec/{processor → unit/processor}/test_apply.rb +0 -0
  72. data/spec/{processor → unit/processor}/test_build_helper_chain.rb +0 -0
  73. data/spec/{processor → unit/processor}/test_call.rb +0 -0
  74. data/spec/unit/processor/test_grammar.rb +56 -0
  75. data/spec/{processor → unit/processor}/test_helper.rb +0 -0
  76. data/spec/{processor → unit/processor}/test_sexpr_coercions.rb +6 -2
  77. data/spec/{processor → unit/processor}/test_use.rb +0 -0
  78. data/spec/{rewriter → unit/rewriter}/test_copy_and_apply.rb +0 -0
  79. data/spec/{test_load.rb → unit/test_load.rb} +3 -2
  80. data/spec/{test_rewriter.rb → unit/test_rewriter.rb} +0 -0
  81. data/spec/{test_sexpr.rb → unit/test_sexpr.rb} +1 -1
  82. data/tasks/gem.rake +9 -4
  83. data/tasks/test.rake +26 -0
  84. metadata +163 -117
  85. data/spec/grammar/matching/test_compile_rule.rb +0 -23
  86. data/spec/matcher/rule/test_eat.rb +0 -21
  87. data/spec/matcher/rule/test_match_q.rb +0 -24
  88. data/tasks/spec_test.rake +0 -71
  89. data/tasks/unit_test.rake +0 -76
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
- module Sexpr
3
- module Grammar
4
- describe Matching, "compile_rule" do
5
- include Matching
6
-
7
- it 'keep alternatives unchanged' do
8
- compile_rule(:hello, Matcher::Alternative.new([]) ).should be_a(Matcher::Alternative)
9
- end
10
-
11
- it 'keep terminals unchanged' do
12
- compile_rule(:hello, Matcher::Terminal.new(true) ).should be_a(Matcher::Terminal)
13
- end
14
-
15
- it 'keep creates a Rule englobing sequences' do
16
- compiled = compile_rule(:hello, Matcher::Sequence.new([]) )
17
- compiled.should be_a(Matcher::Rule)
18
- compiled.name.should eq(:hello)
19
- end
20
-
21
- end
22
- end
23
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
- module Sexpr::Matcher
3
- describe Rule, "eat" do
4
-
5
- let(:defn){ Sequence.new [Terminal.new(/^[a-z]+$/)] }
6
- let(:rule){ Rule.new :hello, defn }
7
-
8
- it 'returns the trailing array when match' do
9
- rule.eat([[:hello, "world"], "!"]).should eq(["!"])
10
- end
11
-
12
- it 'returns nil when not match' do
13
- rule.eat([:hello, "world"]).should be_nil
14
- rule.eat([:hello]).should be_nil
15
- rule.eat([]).should be_nil
16
- rule.eat([[]]).should be_nil
17
- rule.eat([nil]).should be_nil
18
- end
19
-
20
- end
21
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
- module Sexpr::Matcher
3
- describe Rule, 'match?' do
4
-
5
- let(:defn){ Sequence.new [Terminal.new(/^[a-z]+$/)] }
6
- let(:rule){ Rule.new :hello, defn }
7
-
8
- it 'returns true on match' do
9
- rule.should be_match([:hello, "hello"])
10
- end
11
-
12
- it 'returns false on partial match' do
13
- rule.should_not be_match([:hello, "hello", "world"])
14
- end
15
-
16
- it 'returns false on no match' do
17
- rule.should_not be_match(["hello"])
18
- rule.should_not be_match([:hello, 12])
19
- rule.should_not be_match([])
20
- rule.should_not be_match(nil)
21
- end
22
-
23
- end
24
- end
@@ -1,71 +0,0 @@
1
- # Installs a rake task for for running examples written using rspec.
2
- #
3
- # This file installs the 'rake spec_test' (aliased as 'rake spec') as well as
4
- # extends 'rake test' to run spec tests, if any. It is automatically generated
5
- # by Noe from your .noespec file, and should therefore be configured there,
6
- # under the variables/rake_tasks/spec_test entry, as illustrated below:
7
- #
8
- # variables:
9
- # rake_tasks:
10
- # spec_test:
11
- # pattern: spec/**/*_spec.rb
12
- # verbose: true
13
- # rspec_opts: [--color, --backtrace]
14
- # ...
15
- #
16
- # If you have specific needs requiring manual intervention on this file,
17
- # don't forget to set safe-override to false in your noe specification:
18
- #
19
- # template-info:
20
- # manifest:
21
- # tasks/spec_test.rake:
22
- # safe-override: false
23
- #
24
- # This file has been written to conform to RSpec v2.4.0. More information about
25
- # rspec and options of the rake task defined below can be found on
26
- # http://relishapp.com/rspec
27
- #
28
- begin
29
- require "rspec/core/rake_task"
30
- desc "Run RSpec code examples"
31
- RSpec::Core::RakeTask.new(:spec_test) do |t|
32
- # Glob pattern to match files.
33
- t.pattern = "spec/**/test_*.rb"
34
-
35
- # Whether or not to fail Rake when an error occurs (typically when
36
- # examples fail).
37
- t.fail_on_error = true
38
-
39
- # A message to print to stderr when there are failures.
40
- t.failure_message = nil
41
-
42
- # Use verbose output. If this is set to true, the task will print the
43
- # executed spec command to stdout.
44
- t.verbose = true
45
-
46
- # Use rcov for code coverage?
47
- t.rcov = false
48
-
49
- # Path to rcov.
50
- t.rcov_path = "rcov"
51
-
52
- # Command line options to pass to rcov. See 'rcov --help' about this
53
- t.rcov_opts = []
54
-
55
- # Command line options to pass to ruby. See 'ruby --help' about this
56
- t.ruby_opts = []
57
-
58
- # Path to rspec
59
- t.rspec_path = "rspec"
60
-
61
- # Command line options to pass to rspec. See 'rspec --help' about this
62
- t.rspec_opts = ["--color", "--backtrace"]
63
- end
64
- rescue LoadError => ex
65
- task :spec_test do
66
- abort 'rspec is not available. In order to run spec, you must: gem install rspec'
67
- end
68
- ensure
69
- task :spec => [:spec_test]
70
- task :test => [:spec_test]
71
- end
@@ -1,76 +0,0 @@
1
- # Installs a rake task for for running unit tests.
2
- #
3
- # This file installs the 'rake unit_test' and extends 'rake test' to run unit
4
- # tests, if any. It is automatically generated by Noe from your .noespec file,
5
- # and should therefore be configured there, under the variables/rake_tasks/unit_test
6
- # entry, as illustrated below:
7
- #
8
- # variables:
9
- # rake_tasks:
10
- # unit_test:
11
- # pattern: test/test*.rb
12
- # verbose: false
13
- # warning: false
14
- # ...
15
- #
16
- # If you have specific needs requiring manual intervention on this file,
17
- # don't forget to set safe-override to false in your noe specification:
18
- #
19
- # template-info:
20
- # manifest:
21
- # tasks/unit_test.rake:
22
- # safe-override: false
23
- #
24
- # More info about the TestTask and its options can be found on
25
- # http://rake.rubyforge.org/classes/Rake/TestTask.html
26
- #
27
- begin
28
- require 'rake/testtask'
29
- desc "Run unit tests"
30
- Rake::TestTask.new(:unit_test) do |t|
31
-
32
- # List of directories to added to $LOAD_PATH before running the
33
- # tests. (default is 'lib')
34
- t.libs = ["lib"]
35
-
36
- # True if verbose test output desired. (default is false)
37
- t.verbose = false
38
-
39
- # Test options passed to the test suite. An explicit TESTOPTS=opts
40
- # on the command line will override this. (default is NONE)
41
- t.options = nil
42
-
43
- # Request that the tests be run with the warning flag set.
44
- # E.g. warning=true implies "ruby -w" used to run the tests.
45
- t.warning = false
46
-
47
- # Glob pattern to match test files. (default is 'test/test*.rb')
48
- t.pattern = "test/test_*.rb"
49
-
50
- # Style of test loader to use. Options are:
51
- #
52
- # * :rake -- Rake provided test loading script (default).
53
- # * :testrb -- Ruby provided test loading script.
54
- # * :direct -- Load tests using command line loader.
55
- #
56
- t.loader = :rake
57
-
58
- # Array of commandline options to pass to ruby when running test
59
- # loader.
60
- t.ruby_opts = []
61
-
62
- # Explicitly define the list of test files to be included in a
63
- # test. +list+ is expected to be an array of file names (a
64
- # FileList is acceptable). If both +pattern+ and +test_files+ are
65
- # used, then the list of test files is the union of the two.
66
- t.test_files = nil
67
-
68
- end
69
- rescue LoadError => ex
70
- task :unit_test do
71
- abort "rake/testtask does not seem available...\n #{ex.message}"
72
- end
73
- ensure
74
- desc "Run all tests"
75
- task :test => [:unit_test]
76
- end