kanocc 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/examples/bind.rb +26 -0
- data/examples/calculator.rb +19 -15
- data/examples/doc_calc.rb +42 -0
- data/examples/minipascalsyntax.html +371 -0
- data/examples/ruby_quiz_78.rb +12 -11
- data/lib/kanocc.rb +73 -102
- data/lib/kanocc/earley.rb +262 -217
- data/lib/kanocc/grammar_rule.rb +7 -21
- data/lib/kanocc/nonterminal.rb +67 -65
- data/lib/kanocc/scanner.rb +168 -85
- data/lib/kanocc/token.rb +24 -0
- data/lib/todo +2 -3
- metadata +13 -9
data/lib/kanocc/token.rb
CHANGED
@@ -43,6 +43,14 @@ module Kanocc
|
|
43
43
|
return @@patterns[self] || []
|
44
44
|
end
|
45
45
|
|
46
|
+
def Token.regexps
|
47
|
+
return (@@patterns[self] || []).map {|pattern| pattern[:regexp]}
|
48
|
+
end
|
49
|
+
|
50
|
+
def Token.method(regexp)
|
51
|
+
patterns.find {|pattern| pattern[:regexp] == regexp}[:method_name]
|
52
|
+
end
|
53
|
+
|
46
54
|
def is_a_kanocc_token?
|
47
55
|
return true
|
48
56
|
end
|
@@ -51,6 +59,22 @@ module Kanocc
|
|
51
59
|
return true
|
52
60
|
end
|
53
61
|
|
62
|
+
def Token.match(string_scanner)
|
63
|
+
max_match_len = 0
|
64
|
+
matching_regexp = nil
|
65
|
+
regexps.each do |regexp|
|
66
|
+
if (len = string_scanner.match?(regexp)) and len > max_match_len
|
67
|
+
max_match_len = len
|
68
|
+
matching_regexp = regexp
|
69
|
+
end
|
70
|
+
end
|
71
|
+
if matching_regexp
|
72
|
+
return max_match_len, matching_regexp
|
73
|
+
else
|
74
|
+
return 0, nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
54
78
|
def inspect
|
55
79
|
self.class.name
|
56
80
|
end
|
data/lib/todo
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Scanner.eachToken method
|
1
|
+
document logging
|
2
|
+
look at rules for lists. Looks strange
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanocc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Surlykke
|
@@ -9,7 +9,7 @@ autorequire: kanocc
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-09-30 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -24,18 +24,22 @@ extra_rdoc_files: []
|
|
24
24
|
files:
|
25
25
|
- README
|
26
26
|
- COPYING
|
27
|
-
- lib/kanocc
|
28
27
|
- lib/kanocc.rb
|
29
28
|
- lib/todo
|
29
|
+
- lib/kanocc/token.rb
|
30
|
+
- lib/kanocc/grammar_rule.rb
|
30
31
|
- lib/kanocc/earley.rb
|
31
32
|
- lib/kanocc/scanner.rb
|
32
|
-
- lib/kanocc/grammar_rule.rb
|
33
33
|
- lib/kanocc/nonterminal.rb
|
34
|
-
- lib/kanocc/token.rb
|
35
|
-
- examples/calculator.rb
|
36
34
|
- examples/ruby_quiz_78.rb
|
37
|
-
|
35
|
+
- examples/minipascalsyntax.html
|
36
|
+
- examples/bind.rb
|
37
|
+
- examples/calculator.rb
|
38
|
+
- examples/doc_calc.rb
|
39
|
+
has_rdoc: true
|
38
40
|
homepage: ""
|
41
|
+
licenses: []
|
42
|
+
|
39
43
|
post_install_message:
|
40
44
|
rdoc_options: []
|
41
45
|
|
@@ -56,9 +60,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
60
|
requirements: []
|
57
61
|
|
58
62
|
rubyforge_project:
|
59
|
-
rubygems_version:
|
63
|
+
rubygems_version: 1.3.5
|
60
64
|
signing_key:
|
61
|
-
specification_version:
|
65
|
+
specification_version: 3
|
62
66
|
summary: Kanocc - Kanocc ain't no compiler-compiler. A framework for syntax directed translation
|
63
67
|
test_files: []
|
64
68
|
|