koi-reference-parser 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/README.rdoc +4 -0
  2. data/VERSION +1 -1
  3. data/lib/parser/koi-reference-parser.treetop +58 -45
  4. data/lib/parser/parser.rb +2 -17
  5. data/lib/parser/syntax_nodes.rb +0 -9
  6. data/test/{parser/functional → functional}/function_call_as_argument.rb +1 -1
  7. data/test/{parser/functional → functional}/simple_program_test.rb +1 -1
  8. data/test/helpers/assert_assigns.rb +9 -0
  9. data/test/helpers/assert_assigns_expression.rb +10 -0
  10. data/test/helpers/assert_expression.rb +11 -0
  11. data/test/helpers/assert_identifier.rb +6 -0
  12. data/test/test_helper.rb +1 -0
  13. data/test/unit/assignment/assignment_of_hash_value_test.rb +19 -0
  14. data/test/{parser/unit/hash_accessor_test.rb → unit/assignment/assignment_to_hash_test.rb} +2 -14
  15. data/test/unit/assignment/boolean_assignment_test.rb +17 -0
  16. data/test/unit/assignment/float_assignment_test.rb +22 -0
  17. data/test/unit/assignment/function_call_assignment_test.rb +12 -0
  18. data/test/unit/assignment/function_definition_test.rb +12 -0
  19. data/test/unit/assignment/hash_literal_assignment_test.rb +27 -0
  20. data/test/unit/assignment/integer_assignment_test.rb +22 -0
  21. data/test/unit/assignment/nil_assignment_test.rb +12 -0
  22. data/test/unit/assignment/string_assignment_test.rb +17 -0
  23. data/test/unit/expressions/addition_expression_test.rb +27 -0
  24. data/test/{parser/unit → unit/expressions}/compound_expression_test.rb +0 -0
  25. data/test/unit/expressions/division_expression_test.rb +27 -0
  26. data/test/unit/expressions/equality_expression_test.rb +27 -0
  27. data/test/unit/expressions/greater_than_expression_test.rb +27 -0
  28. data/test/unit/expressions/inequality_expression_test.rb +27 -0
  29. data/test/unit/expressions/less_than_expression_test.rb +27 -0
  30. data/test/unit/expressions/multiplication_expression_test.rb +27 -0
  31. data/test/unit/expressions/subtraction_expression_test.rb +27 -0
  32. data/test/{parser/unit → unit/flow_control}/if_test.rb +0 -0
  33. data/test/{parser/unit → unit/flow_control}/unless_test.rb +0 -0
  34. data/test/{parser/unit → unit/functions}/function_call_test.rb +0 -0
  35. data/test/{parser/unit → unit/functions}/function_definition_test.rb +0 -0
  36. data/test/unit/identifier_test.rb +37 -0
  37. data/test/{parser/unit → unit}/statement_test.rb +1 -1
  38. data/test/{parser/unit → unit}/syntax_node_to_hash_test.rb +1 -1
  39. metadata +67 -29
  40. data/test/parser/unit/assignment_test.rb +0 -115
  41. data/test/parser/unit/identifier_test.rb +0 -55
  42. data/test/parser/unit/simple_expression_test.rb +0 -212
@@ -0,0 +1,22 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class IntegerAssignmentTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "assignment of integer" do
8
+ tree = Parser.parse('test = 1')
9
+ assert_assigns_expression(IntegerLiteral, '1', tree)
10
+ end
11
+
12
+ test "assignment of explicitly positive integer" do
13
+ tree = Parser.parse('test = +1')
14
+ assert_assigns_expression(IntegerLiteral, '+1', tree)
15
+ end
16
+
17
+ test "assignment of explicitly negative integer" do
18
+ tree = Parser.parse('test = -1')
19
+ assert_assigns_expression(IntegerLiteral, '-1', tree)
20
+ end
21
+
22
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class NilAssignmentTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "assignment of nil" do
8
+ tree = Parser.parse('test = nil')
9
+ assert_assigns_expression(NilLiteral, nil, tree)
10
+ end
11
+
12
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class StringAssignmentTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "assignment of string" do
8
+ tree = Parser.parse('test = "test_string"')
9
+ assert_assigns_expression(StringLiteral, '"test_string"', tree)
10
+ end
11
+
12
+ test "assignment of string containing escaped quote" do
13
+ tree = Parser.parse('test = "test_\"string"')
14
+ assert_assigns_expression(StringLiteral, '"test_\"string"', tree)
15
+ end
16
+
17
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class AdditionExpressionTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse simple addition expression with integers" do
8
+ tree = Parser.parse('test = 1 + 1')
9
+ assert_expression(tree, AdditiveExpression, AdditionOperator)
10
+ end
11
+
12
+ test "should parse simple addition expression with floats" do
13
+ tree = Parser.parse('test = 1.0 + 1.0')
14
+ assert_expression(tree, AdditiveExpression, AdditionOperator)
15
+ end
16
+
17
+ test "should parse simple addition expression with strings" do
18
+ tree = Parser.parse('test = "1" + "1"')
19
+ assert_expression(tree, AdditiveExpression, AdditionOperator)
20
+ end
21
+
22
+ test "should parse simple addition expression with identifiers" do
23
+ tree = Parser.parse('test = test1 + test2')
24
+ assert_expression(tree, AdditiveExpression, AdditionOperator)
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class DivisionExpressionTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse simple division expression with integers" do
8
+ tree = Parser.parse('test = 1 / 1')
9
+ assert_expression(tree, MultitiveExpression, DivisionOperator)
10
+ end
11
+
12
+ test "should parse simple division expression with floats" do
13
+ tree = Parser.parse('test = 1.0 / 1.0')
14
+ assert_expression(tree, MultitiveExpression, DivisionOperator)
15
+ end
16
+
17
+ test "should parse simple division expression with strings" do
18
+ tree = Parser.parse('test = "1" / "1"')
19
+ assert_expression(tree, MultitiveExpression, DivisionOperator)
20
+ end
21
+
22
+ test "should parse simple division expression with identifiers" do
23
+ tree = Parser.parse('test = test1 / test2')
24
+ assert_expression(tree, MultitiveExpression, DivisionOperator)
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class EqualityExpressionTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse simple equality expression with integers" do
8
+ tree = Parser.parse('test = 1 == 1')
9
+ assert_expression(tree, ComparativeExpression, EqualityOperator)
10
+ end
11
+
12
+ test "should parse simple equality expression with floats" do
13
+ tree = Parser.parse('test = 1.0 == 1.0')
14
+ assert_expression(tree, ComparativeExpression, EqualityOperator)
15
+ end
16
+
17
+ test "should parse simple equality expression with strings" do
18
+ tree = Parser.parse('test = "1" == "1"')
19
+ assert_expression(tree, ComparativeExpression, EqualityOperator)
20
+ end
21
+
22
+ test "should parse simple equality expression with identifiers" do
23
+ tree = Parser.parse('test = test1 == test2')
24
+ assert_expression(tree, ComparativeExpression, EqualityOperator)
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class GreaterThanExpressionTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse simple 'greater than' expression with integers" do
8
+ tree = Parser.parse('test = 1 > 1')
9
+ assert_expression(tree, ComparativeExpression, GreaterThanOperator)
10
+ end
11
+
12
+ test "should parse simple 'greater than' expression with floats" do
13
+ tree = Parser.parse('test = 1.0 > 1.0')
14
+ assert_expression(tree, ComparativeExpression, GreaterThanOperator)
15
+ end
16
+
17
+ test "should parse simple 'greater than' expression with strings" do
18
+ tree = Parser.parse('test = "1" > "1"')
19
+ assert_expression(tree, ComparativeExpression, GreaterThanOperator)
20
+ end
21
+
22
+ test "should parse simple 'greater than' expression with identifiers" do
23
+ tree = Parser.parse('test = test1 > test2')
24
+ assert_expression(tree, ComparativeExpression, GreaterThanOperator)
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class InequalityExpressionTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse simple inequality expression with integers" do
8
+ tree = Parser.parse('test = 1 != 1')
9
+ assert_expression(tree, ComparativeExpression, InequalityOperator)
10
+ end
11
+
12
+ test "should parse simple inequality expression with floats" do
13
+ tree = Parser.parse('test = 1.0 != 1.0')
14
+ assert_expression(tree, ComparativeExpression, InequalityOperator)
15
+ end
16
+
17
+ test "should parse simple inequality expression with strings" do
18
+ tree = Parser.parse('test = "1" != "1"')
19
+ assert_expression(tree, ComparativeExpression, InequalityOperator)
20
+ end
21
+
22
+ test "should parse simple inequality expression with identifiers" do
23
+ tree = Parser.parse('test = test1 != test2')
24
+ assert_expression(tree, ComparativeExpression, InequalityOperator)
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class LessThanExpressionTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse simple 'less than' expression with integers" do
8
+ tree = Parser.parse('test = 1 < 1')
9
+ assert_expression(tree, ComparativeExpression, LessThanOperator)
10
+ end
11
+
12
+ test "should parse simple 'less than' expression with floats" do
13
+ tree = Parser.parse('test = 1.0 < 1.0')
14
+ assert_expression(tree, ComparativeExpression, LessThanOperator)
15
+ end
16
+
17
+ test "should parse simple 'less than' expression with strings" do
18
+ tree = Parser.parse('test = "1" < "1"')
19
+ assert_expression(tree, ComparativeExpression, LessThanOperator)
20
+ end
21
+
22
+ test "should parse simple 'less than' expression with identifiers" do
23
+ tree = Parser.parse('test = test1 < test2')
24
+ assert_expression(tree, ComparativeExpression, LessThanOperator)
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class MultiplicationExpressionTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse simple multiplication expression with integers" do
8
+ tree = Parser.parse('test = 1 * 1')
9
+ assert_expression(tree, MultitiveExpression, MultiplicationOperator)
10
+ end
11
+
12
+ test "should parse simple multiplication expression with floats" do
13
+ tree = Parser.parse('test = 1.0 * 1.0')
14
+ assert_expression(tree, MultitiveExpression, MultiplicationOperator)
15
+ end
16
+
17
+ test "should parse simple multiplication expression with strings" do
18
+ tree = Parser.parse('test = "1" * "1"')
19
+ assert_expression(tree, MultitiveExpression, MultiplicationOperator)
20
+ end
21
+
22
+ test "should parse simple multiplication expression with identifiers" do
23
+ tree = Parser.parse('test = test1 * test2')
24
+ assert_expression(tree, MultitiveExpression, MultiplicationOperator)
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class SubtractionExpressionTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse simple subtraction expression with integers" do
8
+ tree = Parser.parse('test = 1 - 1')
9
+ assert_expression(tree, AdditiveExpression, SubtractionOperator)
10
+ end
11
+
12
+ test "should parse simple subtraction expression with floats" do
13
+ tree = Parser.parse('test = 1.0 - 1.0')
14
+ assert_expression(tree, AdditiveExpression, SubtractionOperator)
15
+ end
16
+
17
+ test "should parse simple subtraction expression with strings" do
18
+ tree = Parser.parse('test = "1" - "1"')
19
+ assert_expression(tree, AdditiveExpression, SubtractionOperator)
20
+ end
21
+
22
+ test "should parse simple subtraction expression with identifiers" do
23
+ tree = Parser.parse('test = test1 - test2')
24
+ assert_expression(tree, AdditiveExpression, SubtractionOperator)
25
+ end
26
+
27
+ end
@@ -0,0 +1,37 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
+
3
+ class FunctionCallTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse all lowercase identifier" do
8
+ tree = Parser.parse('test = "test"')
9
+ assert_identifier(tree)
10
+ end
11
+
12
+ test "should parse identifier with trailing numeral" do
13
+ tree = Parser.parse('test1 = "test"')
14
+ assert_identifier(tree)
15
+ end
16
+
17
+ test "should parse identifier with leading capital letter" do
18
+ tree = Parser.parse('Test = "test"')
19
+ assert_identifier(tree)
20
+ end
21
+
22
+ test "should parse identifier that contains an underscore" do
23
+ tree = Parser.parse('test_test = "test"')
24
+ assert_identifier(tree)
25
+ end
26
+
27
+ test "should parse single character identifier" do
28
+ tree = Parser.parse('x = "test"')
29
+ assert_identifier(tree)
30
+ end
31
+
32
+ test "should parse identifier with leading $" do
33
+ tree = Parser.parse('$test = "test"')
34
+ assert_identifier(tree)
35
+ end
36
+
37
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
2
 
3
3
  class StatementTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
2
 
3
3
  class SyntaxNodeToHashTest < Test::Unit::TestCase
4
4
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Gough
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-31 00:00:00 -04:00
17
+ date: 2010-09-01 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -51,21 +51,40 @@ files:
51
51
  - lib/parser/parser.rb
52
52
  - lib/parser/syntax_node_extensions.rb
53
53
  - lib/parser/syntax_nodes.rb
54
- - test/parser/functional/function_call_as_argument.rb
55
- - test/parser/functional/simple_program_test.rb
56
- - test/parser/unit/assignment_test.rb
57
- - test/parser/unit/compound_expression_test.rb
58
- - test/parser/unit/function_call_test.rb
59
- - test/parser/unit/function_definition_test.rb
60
- - test/parser/unit/hash_accessor_test.rb
61
- - test/parser/unit/identifier_test.rb
62
- - test/parser/unit/if_test.rb
63
- - test/parser/unit/simple_expression_test.rb
64
- - test/parser/unit/statement_test.rb
65
- - test/parser/unit/syntax_node_to_hash_test.rb
66
- - test/parser/unit/unless_test.rb
54
+ - test/functional/function_call_as_argument.rb
55
+ - test/functional/simple_program_test.rb
56
+ - test/helpers/assert_assigns.rb
57
+ - test/helpers/assert_assigns_expression.rb
58
+ - test/helpers/assert_expression.rb
59
+ - test/helpers/assert_identifier.rb
67
60
  - test/setup/test_unit_extensions.rb
68
61
  - test/test_helper.rb
62
+ - test/unit/assignment/assignment_of_hash_value_test.rb
63
+ - test/unit/assignment/assignment_to_hash_test.rb
64
+ - test/unit/assignment/boolean_assignment_test.rb
65
+ - test/unit/assignment/float_assignment_test.rb
66
+ - test/unit/assignment/function_call_assignment_test.rb
67
+ - test/unit/assignment/function_definition_test.rb
68
+ - test/unit/assignment/hash_literal_assignment_test.rb
69
+ - test/unit/assignment/integer_assignment_test.rb
70
+ - test/unit/assignment/nil_assignment_test.rb
71
+ - test/unit/assignment/string_assignment_test.rb
72
+ - test/unit/expressions/addition_expression_test.rb
73
+ - test/unit/expressions/compound_expression_test.rb
74
+ - test/unit/expressions/division_expression_test.rb
75
+ - test/unit/expressions/equality_expression_test.rb
76
+ - test/unit/expressions/greater_than_expression_test.rb
77
+ - test/unit/expressions/inequality_expression_test.rb
78
+ - test/unit/expressions/less_than_expression_test.rb
79
+ - test/unit/expressions/multiplication_expression_test.rb
80
+ - test/unit/expressions/subtraction_expression_test.rb
81
+ - test/unit/flow_control/if_test.rb
82
+ - test/unit/flow_control/unless_test.rb
83
+ - test/unit/functions/function_call_test.rb
84
+ - test/unit/functions/function_definition_test.rb
85
+ - test/unit/identifier_test.rb
86
+ - test/unit/statement_test.rb
87
+ - test/unit/syntax_node_to_hash_test.rb
69
88
  has_rdoc: true
70
89
  homepage: http://github.com/aarongough/koi-reference-parser
71
90
  licenses: []
@@ -101,18 +120,37 @@ signing_key:
101
120
  specification_version: 3
102
121
  summary: A reference parser for the Koi language.
103
122
  test_files:
104
- - test/parser/functional/function_call_as_argument.rb
105
- - test/parser/functional/simple_program_test.rb
106
- - test/parser/unit/assignment_test.rb
107
- - test/parser/unit/compound_expression_test.rb
108
- - test/parser/unit/function_call_test.rb
109
- - test/parser/unit/function_definition_test.rb
110
- - test/parser/unit/hash_accessor_test.rb
111
- - test/parser/unit/identifier_test.rb
112
- - test/parser/unit/if_test.rb
113
- - test/parser/unit/simple_expression_test.rb
114
- - test/parser/unit/statement_test.rb
115
- - test/parser/unit/syntax_node_to_hash_test.rb
116
- - test/parser/unit/unless_test.rb
123
+ - test/functional/function_call_as_argument.rb
124
+ - test/functional/simple_program_test.rb
125
+ - test/helpers/assert_assigns.rb
126
+ - test/helpers/assert_assigns_expression.rb
127
+ - test/helpers/assert_expression.rb
128
+ - test/helpers/assert_identifier.rb
117
129
  - test/setup/test_unit_extensions.rb
118
130
  - test/test_helper.rb
131
+ - test/unit/assignment/assignment_of_hash_value_test.rb
132
+ - test/unit/assignment/assignment_to_hash_test.rb
133
+ - test/unit/assignment/boolean_assignment_test.rb
134
+ - test/unit/assignment/float_assignment_test.rb
135
+ - test/unit/assignment/function_call_assignment_test.rb
136
+ - test/unit/assignment/function_definition_test.rb
137
+ - test/unit/assignment/hash_literal_assignment_test.rb
138
+ - test/unit/assignment/integer_assignment_test.rb
139
+ - test/unit/assignment/nil_assignment_test.rb
140
+ - test/unit/assignment/string_assignment_test.rb
141
+ - test/unit/expressions/addition_expression_test.rb
142
+ - test/unit/expressions/compound_expression_test.rb
143
+ - test/unit/expressions/division_expression_test.rb
144
+ - test/unit/expressions/equality_expression_test.rb
145
+ - test/unit/expressions/greater_than_expression_test.rb
146
+ - test/unit/expressions/inequality_expression_test.rb
147
+ - test/unit/expressions/less_than_expression_test.rb
148
+ - test/unit/expressions/multiplication_expression_test.rb
149
+ - test/unit/expressions/subtraction_expression_test.rb
150
+ - test/unit/flow_control/if_test.rb
151
+ - test/unit/flow_control/unless_test.rb
152
+ - test/unit/functions/function_call_test.rb
153
+ - test/unit/functions/function_definition_test.rb
154
+ - test/unit/identifier_test.rb
155
+ - test/unit/statement_test.rb
156
+ - test/unit/syntax_node_to_hash_test.rb