llip 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/MIT-LICENSE +21 -0
- data/Manifest.txt +45 -0
- data/README.txt +148 -0
- data/Rakefile +66 -0
- data/examples/ariteval/ariteval.rb +132 -0
- data/examples/ariteval/evaluator.rb +61 -0
- data/examples/ariteval/exp.rb +104 -0
- data/lib/llip.rb +6 -0
- data/lib/llip/abstract_parser.rb +170 -0
- data/lib/llip/abstract_scanner.rb +83 -0
- data/lib/llip/buffer.rb +35 -0
- data/lib/llip/llip_error.rb +43 -0
- data/lib/llip/parser.rb +93 -0
- data/lib/llip/production_compiler.rb +168 -0
- data/lib/llip/production_specification.rb +79 -0
- data/lib/llip/recursive_production_compiler.rb +35 -0
- data/lib/llip/regexp_abstract_scanner.rb +116 -0
- data/lib/llip/regexp_parser.rb +197 -0
- data/lib/llip/regexp_scanner.rb +33 -0
- data/lib/llip/regexp_specification.rb +210 -0
- data/lib/llip/token.rb +47 -0
- data/lib/llip/visitable.rb +37 -0
- data/spec/ariteval/ariteval_spec.rb +111 -0
- data/spec/ariteval/evaluator_spec.rb +106 -0
- data/spec/ariteval/exp_spec.rb +232 -0
- data/spec/llip/abstract_parser_spec.rb +273 -0
- data/spec/llip/abstract_scanner_spec.rb +152 -0
- data/spec/llip/buffer_spec.rb +60 -0
- data/spec/llip/llip_error_spec.rb +77 -0
- data/spec/llip/parser_spec.rb +163 -0
- data/spec/llip/production_compiler_spec.rb +271 -0
- data/spec/llip/production_specification_spec.rb +75 -0
- data/spec/llip/recursive_production_compiler_spec.rb +86 -0
- data/spec/llip/regexp_abstract_scanner_spec.rb +320 -0
- data/spec/llip/regexp_parser_spec.rb +265 -0
- data/spec/llip/regexp_scanner_spec.rb +40 -0
- data/spec/llip/regexp_specification_spec.rb +734 -0
- data/spec/llip/token_spec.rb +70 -0
- data/spec/llip/visitable_spec.rb +38 -0
- data/spec/spec_helper.rb +10 -0
- metadata +110 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'token'
|
3
|
+
|
4
|
+
describe "A token" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@token = Token.new(:my_type,"my value")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have a name" do
|
11
|
+
@token.should respond_to(:type)
|
12
|
+
@token.name.should == :my_type
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have a value" do
|
16
|
+
@token.should respond_to(:value)
|
17
|
+
@token.value.should == "my value"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can be coerced to a string" do
|
21
|
+
@token.should respond_to(:to_str)
|
22
|
+
@token.should respond_to(:to_s)
|
23
|
+
|
24
|
+
@token.to_s.should == "my value"
|
25
|
+
@token.to_str.should == "my value"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "can be a value = nil and it must respond correctly to nil?" do
|
29
|
+
@token = Token.new(:my_type,nil)
|
30
|
+
@token.should be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have :nil,nil as default values for type,value" do
|
34
|
+
@token = Token.new
|
35
|
+
@token.value.should == nil
|
36
|
+
@token.name.should == :nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should behave correctly when called ==" do
|
40
|
+
t2 = Token.new(:my_type,"my value")
|
41
|
+
@token.should == t2
|
42
|
+
|
43
|
+
@token.should == "my value"
|
44
|
+
|
45
|
+
@token.should == :my_type
|
46
|
+
|
47
|
+
@token.should == :everything
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be matched with a regexp" do
|
51
|
+
(@token =~ /.*value/).should_not be_nil
|
52
|
+
(@token !~ /.*value/).should == false
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have a line attribute, which is initialized to -1" do
|
56
|
+
@token.should respond_to(:line)
|
57
|
+
@token.line.should == -1
|
58
|
+
|
59
|
+
lambda { @token = Token.new(:my_type, "my value", 5) }.should_not raise_error
|
60
|
+
@token.line.should == 5
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should have a char attribute, which is initialized to -1" do
|
64
|
+
@token.should respond_to(:char)
|
65
|
+
@token.char.should == -1
|
66
|
+
|
67
|
+
lambda { @token = Token.new(:my_type, "my value", 5,7) }.should_not raise_error
|
68
|
+
@token.char.should == 7
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'visitable'
|
3
|
+
|
4
|
+
class TempClass
|
5
|
+
include Visitable
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "A class including Visitable" do
|
9
|
+
before :each do
|
10
|
+
@instance = TempClass.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it { @instance.should respond_to(:accept) }
|
14
|
+
|
15
|
+
it "should call the visitor's class method for the class" do
|
16
|
+
visitor = mock "Visitor"
|
17
|
+
visitor.should_receive(:visit_temp_class).and_return(:a_symbol)
|
18
|
+
@instance.accept(visitor).should == :a_symbol
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class ChildTempClass < TempClass
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "A child of a class including Visitable" do
|
26
|
+
before :each do
|
27
|
+
@instance = ChildTempClass.new
|
28
|
+
end
|
29
|
+
|
30
|
+
it { @instance.should respond_to(:accept) }
|
31
|
+
|
32
|
+
it "should call the visitor's class method for the class" do
|
33
|
+
visitor = mock "Visitor"
|
34
|
+
visitor.should_receive(:visit_child_temp_class).and_return(:another_symbol)
|
35
|
+
@instance.accept(visitor).should == :another_symbol
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: llip
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2007-06-09 00:00:00 +02:00
|
8
|
+
summary: LLIP is a tool to geneate a LL(k) parser.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: matteo.collina@gmail.com
|
12
|
+
homepage: http://llip.rubyforge.org
|
13
|
+
rubyforge_project: llip
|
14
|
+
description: The LL(k) Interpreted Parser (llip) is an automated tool to easily create an LL(k) parser and the related scanner without the need of generating anything. Everything is done on the fly through a simple DSL. == A Little comparrison against other tools Tools like JavaCC, ANTLR, Coco/R and others use an external description file which they compile into the destination code. This file it's usually written using a complex product related language. Using Ruby metaprogramming, a parser generator can go one step further. In fact, the llip gem gives you the possibility to write a parser writing only Ruby code.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
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
|
+
- Matteo Collina
|
31
|
+
files:
|
32
|
+
- History.txt
|
33
|
+
- MIT-LICENSE
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
- Rakefile
|
37
|
+
- examples/ariteval
|
38
|
+
- examples/ariteval/ariteval.rb
|
39
|
+
- examples/ariteval/evaluator.rb
|
40
|
+
- examples/ariteval/exp.rb
|
41
|
+
- lib/llip
|
42
|
+
- lib/llip.rb
|
43
|
+
- lib/llip/abstract_parser.rb
|
44
|
+
- lib/llip/abstract_scanner.rb
|
45
|
+
- lib/llip/buffer.rb
|
46
|
+
- lib/llip/llip_error.rb
|
47
|
+
- lib/llip/parser.rb
|
48
|
+
- lib/llip/production_compiler.rb
|
49
|
+
- lib/llip/production_specification.rb
|
50
|
+
- lib/llip/recursive_production_compiler.rb
|
51
|
+
- lib/llip/regexp_abstract_scanner.rb
|
52
|
+
- lib/llip/regexp_parser.rb
|
53
|
+
- lib/llip/regexp_scanner.rb
|
54
|
+
- lib/llip/regexp_specification.rb
|
55
|
+
- lib/llip/token.rb
|
56
|
+
- lib/llip/visitable.rb
|
57
|
+
- spec/ariteval
|
58
|
+
- spec/ariteval/ariteval_spec.rb
|
59
|
+
- spec/ariteval/evaluator_spec.rb
|
60
|
+
- spec/ariteval/exp_spec.rb
|
61
|
+
- spec/llip
|
62
|
+
- spec/llip/abstract_parser_spec.rb
|
63
|
+
- spec/llip/abstract_scanner_spec.rb
|
64
|
+
- spec/llip/buffer_spec.rb
|
65
|
+
- spec/llip/llip_error_spec.rb
|
66
|
+
- spec/llip/parser_spec.rb
|
67
|
+
- spec/llip/production_compiler_spec.rb
|
68
|
+
- spec/llip/production_specification_spec.rb
|
69
|
+
- spec/llip/recursive_production_compiler_spec.rb
|
70
|
+
- spec/llip/regexp_abstract_scanner_spec.rb
|
71
|
+
- spec/llip/regexp_parser_spec.rb
|
72
|
+
- spec/llip/regexp_scanner_spec.rb
|
73
|
+
- spec/llip/regexp_specification_spec.rb
|
74
|
+
- spec/llip/token_spec.rb
|
75
|
+
- spec/llip/visitable_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
test_files: []
|
78
|
+
|
79
|
+
rdoc_options:
|
80
|
+
- --main
|
81
|
+
- README.txt
|
82
|
+
extra_rdoc_files:
|
83
|
+
- History.txt
|
84
|
+
- Manifest.txt
|
85
|
+
- README.txt
|
86
|
+
executables: []
|
87
|
+
|
88
|
+
extensions: []
|
89
|
+
|
90
|
+
requirements: []
|
91
|
+
|
92
|
+
dependencies:
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rspec
|
95
|
+
version_requirement:
|
96
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.0.0
|
101
|
+
version:
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: hoe
|
104
|
+
version_requirement:
|
105
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.1
|
110
|
+
version:
|