dhaka 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/lib/dhaka.rb +44 -0
  2. data/lib/evaluator/evaluator.rb +70 -0
  3. data/lib/grammar/closure_hash.rb +13 -0
  4. data/lib/grammar/grammar.rb +129 -0
  5. data/lib/grammar/grammar_symbol.rb +19 -0
  6. data/lib/grammar/production.rb +14 -0
  7. data/lib/parser/action.rb +51 -0
  8. data/lib/parser/channel.rb +51 -0
  9. data/lib/parser/compiled_parser.rb +35 -0
  10. data/lib/parser/item.rb +37 -0
  11. data/lib/parser/parse_result.rb +26 -0
  12. data/lib/parser/parse_tree.rb +34 -0
  13. data/lib/parser/parser.rb +125 -0
  14. data/lib/parser/parser_methods.rb +10 -0
  15. data/lib/parser/parser_run.rb +35 -0
  16. data/lib/parser/parser_state.rb +66 -0
  17. data/lib/parser/token.rb +15 -0
  18. data/lib/tokenizer/tokenizer.rb +88 -0
  19. data/test/all_tests.rb +11 -0
  20. data/test/arithmetic_evaluator.rb +70 -0
  21. data/test/arithmetic_evaluator_test.rb +55 -0
  22. data/test/arithmetic_grammar.rb +38 -0
  23. data/test/arithmetic_grammar_test.rb +11 -0
  24. data/test/arithmetic_test_methods.rb +11 -0
  25. data/test/arithmetic_tokenizer.rb +43 -0
  26. data/test/arithmetic_tokenizer_test.rb +32 -0
  27. data/test/bracket_grammar.rb +25 -0
  28. data/test/bracket_tokenizer.rb +17 -0
  29. data/test/brackets_test.rb +20 -0
  30. data/test/compiled_arithmetic_parser.rb +252 -0
  31. data/test/compiled_parser_test.rb +71 -0
  32. data/test/evaluator_test.rb +8 -0
  33. data/test/grammar_test.rb +70 -0
  34. data/test/incomplete_arithmetic_evaluator.rb +60 -0
  35. data/test/lalr_but_not_slr_grammar.rb +17 -0
  36. data/test/malformed_grammar.rb +9 -0
  37. data/test/malformed_grammar_test.rb +9 -0
  38. data/test/nullable_grammar.rb +18 -0
  39. data/test/parser_test.rb +168 -0
  40. data/test/rr_conflict_grammar.rb +23 -0
  41. data/test/simple_grammar.rb +24 -0
  42. data/test/sr_conflict_grammar.rb +16 -0
  43. metadata +87 -0
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__)+'/../lib/dhaka'
2
+
3
+ class SimpleGrammar < Dhaka::Grammar
4
+
5
+ for_symbol(Dhaka::START_SYMBOL_NAME) do
6
+ start ['S', '#']
7
+ end
8
+
9
+ for_symbol('S') do
10
+ expression ['E']
11
+ end
12
+
13
+ for_symbol('E') do
14
+ subtraction ['E', '-', 'T']
15
+ term ['T']
16
+ end
17
+
18
+ for_symbol('T') do
19
+ literal ['n']
20
+ parenthetized_expression ['(', 'E', ')']
21
+ end
22
+
23
+ end
24
+
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__)+'/../lib/dhaka'
2
+
3
+ class SRConflictGrammar < Dhaka::Grammar
4
+
5
+ for_symbol(Dhaka::START_SYMBOL_NAME) do
6
+ statement ['statement']
7
+ end
8
+ for_symbol('statement') do
9
+ if_statement ['if_statement']
10
+ end
11
+ for_symbol('if_statement') do
12
+ if_then_statement ['IF', 'expr', 'THEN', 'statement']
13
+ if_then_else_statement ['IF', 'expr', 'THEN', 'statement', 'ELSE', 'statement', 'END']
14
+ end
15
+
16
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: dhaka
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2006-11-26 00:00:00 -05:00
8
+ summary: An LALR1 parser generator written in Ruby
9
+ require_paths:
10
+ - lib
11
+ email: mushfeq dot khan at gmail dot com
12
+ homepage:
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: dhaka
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Mushfeq Khan
31
+ files:
32
+ - lib/dhaka.rb
33
+ - lib/evaluator/evaluator.rb
34
+ - lib/grammar/closure_hash.rb
35
+ - lib/grammar/grammar.rb
36
+ - lib/grammar/grammar_symbol.rb
37
+ - lib/grammar/production.rb
38
+ - lib/parser/action.rb
39
+ - lib/parser/channel.rb
40
+ - lib/parser/compiled_parser.rb
41
+ - lib/parser/item.rb
42
+ - lib/parser/parser.rb
43
+ - lib/parser/parser_methods.rb
44
+ - lib/parser/parser_run.rb
45
+ - lib/parser/parser_state.rb
46
+ - lib/parser/parse_result.rb
47
+ - lib/parser/parse_tree.rb
48
+ - lib/parser/token.rb
49
+ - lib/tokenizer/tokenizer.rb
50
+ - test/all_tests.rb
51
+ - test/arithmetic_evaluator.rb
52
+ - test/arithmetic_evaluator_test.rb
53
+ - test/arithmetic_grammar.rb
54
+ - test/arithmetic_grammar_test.rb
55
+ - test/arithmetic_test_methods.rb
56
+ - test/arithmetic_tokenizer.rb
57
+ - test/arithmetic_tokenizer_test.rb
58
+ - test/brackets_test.rb
59
+ - test/bracket_grammar.rb
60
+ - test/bracket_tokenizer.rb
61
+ - test/compiled_arithmetic_parser.rb
62
+ - test/compiled_parser_test.rb
63
+ - test/evaluator_test.rb
64
+ - test/grammar_test.rb
65
+ - test/incomplete_arithmetic_evaluator.rb
66
+ - test/lalr_but_not_slr_grammar.rb
67
+ - test/malformed_grammar.rb
68
+ - test/malformed_grammar_test.rb
69
+ - test/nullable_grammar.rb
70
+ - test/parser_test.rb
71
+ - test/rr_conflict_grammar.rb
72
+ - test/simple_grammar.rb
73
+ - test/sr_conflict_grammar.rb
74
+ test_files: []
75
+
76
+ rdoc_options: []
77
+
78
+ extra_rdoc_files: []
79
+
80
+ executables: []
81
+
82
+ extensions: []
83
+
84
+ requirements: []
85
+
86
+ dependencies: []
87
+