dhaka 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dhaka.rb +44 -0
- data/lib/evaluator/evaluator.rb +70 -0
- data/lib/grammar/closure_hash.rb +13 -0
- data/lib/grammar/grammar.rb +129 -0
- data/lib/grammar/grammar_symbol.rb +19 -0
- data/lib/grammar/production.rb +14 -0
- data/lib/parser/action.rb +51 -0
- data/lib/parser/channel.rb +51 -0
- data/lib/parser/compiled_parser.rb +35 -0
- data/lib/parser/item.rb +37 -0
- data/lib/parser/parse_result.rb +26 -0
- data/lib/parser/parse_tree.rb +34 -0
- data/lib/parser/parser.rb +125 -0
- data/lib/parser/parser_methods.rb +10 -0
- data/lib/parser/parser_run.rb +35 -0
- data/lib/parser/parser_state.rb +66 -0
- data/lib/parser/token.rb +15 -0
- data/lib/tokenizer/tokenizer.rb +88 -0
- data/test/all_tests.rb +11 -0
- data/test/arithmetic_evaluator.rb +70 -0
- data/test/arithmetic_evaluator_test.rb +55 -0
- data/test/arithmetic_grammar.rb +38 -0
- data/test/arithmetic_grammar_test.rb +11 -0
- data/test/arithmetic_test_methods.rb +11 -0
- data/test/arithmetic_tokenizer.rb +43 -0
- data/test/arithmetic_tokenizer_test.rb +32 -0
- data/test/bracket_grammar.rb +25 -0
- data/test/bracket_tokenizer.rb +17 -0
- data/test/brackets_test.rb +20 -0
- data/test/compiled_arithmetic_parser.rb +252 -0
- data/test/compiled_parser_test.rb +71 -0
- data/test/evaluator_test.rb +8 -0
- data/test/grammar_test.rb +70 -0
- data/test/incomplete_arithmetic_evaluator.rb +60 -0
- data/test/lalr_but_not_slr_grammar.rb +17 -0
- data/test/malformed_grammar.rb +9 -0
- data/test/malformed_grammar_test.rb +9 -0
- data/test/nullable_grammar.rb +18 -0
- data/test/parser_test.rb +168 -0
- data/test/rr_conflict_grammar.rb +23 -0
- data/test/simple_grammar.rb +24 -0
- data/test/sr_conflict_grammar.rb +16 -0
- 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
|
+
|