jievro-parser 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -0
  3. data/Gemfile.lock +3 -1
  4. data/Rakefile +1 -1
  5. data/jievro-parser.gemspec +1 -0
  6. data/lib/jievro/parser/grammar/declaration/constant_declaration.treetop +1 -1
  7. data/lib/jievro/parser/grammar/declaration/function_declaration.treetop +2 -1
  8. data/lib/jievro/parser/grammar/declaration/variable_declaration.treetop +1 -1
  9. data/lib/jievro/parser/grammar/expression/closure_expression.treetop +3 -1
  10. data/lib/jievro/parser/grammar/expression/function_call_expression.treetop +1 -1
  11. data/lib/jievro/parser/grammar/expression/parenthesized_expression.treetop +1 -1
  12. data/lib/jievro/parser/grammar/expression/prefix_expression.treetop +1 -1
  13. data/lib/jievro/parser/grammar/expression/range_expression.treetop +1 -1
  14. data/lib/jievro/parser/grammar/expression/self_expression.treetop +1 -1
  15. data/lib/jievro/parser/grammar/expression/super_expression.treetop +1 -1
  16. data/lib/jievro/parser/grammar/grammar.treetop +1 -1
  17. data/lib/jievro/parser/grammar/identifier.treetop +2 -2
  18. data/lib/jievro/parser/grammar/implicit_parameter_name.treetop +1 -1
  19. data/lib/jievro/parser/grammar/literal/literal_array.treetop +1 -1
  20. data/lib/jievro/parser/grammar/literal/literal_boolean.treetop +2 -2
  21. data/lib/jievro/parser/grammar/literal/literal_decimal_floating_point.treetop +1 -1
  22. data/lib/jievro/parser/grammar/literal/literal_dictionary.treetop +3 -2
  23. data/lib/jievro/parser/grammar/literal/literal_hexadecimal_floating_point.treetop +1 -1
  24. data/lib/jievro/parser/grammar/literal/literal_integer_binary.treetop +1 -1
  25. data/lib/jievro/parser/grammar/literal/literal_integer_decimal.treetop +1 -1
  26. data/lib/jievro/parser/grammar/literal/literal_integer_hexadecimal.treetop +1 -1
  27. data/lib/jievro/parser/grammar/literal/literal_integer_octal.treetop +1 -1
  28. data/lib/jievro/parser/grammar/literal/literal_nil.treetop +1 -1
  29. data/lib/jievro/parser/grammar/literal/literal_string.treetop +3 -3
  30. data/lib/jievro/parser/grammar/statement/branch/if.treetop +1 -1
  31. data/lib/jievro/parser/grammar/statement/loop/do_while.treetop +1 -1
  32. data/lib/jievro/parser/grammar/statement/loop/for.treetop +1 -1
  33. data/lib/jievro/parser/grammar/statement/loop/for_in.treetop +1 -1
  34. data/lib/jievro/parser/grammar/statement/loop/while.treetop +1 -1
  35. data/lib/jievro/parser/grammar/type/type_array.treetop +1 -1
  36. data/lib/jievro/parser/grammar/type/type_dictionary.treetop +1 -1
  37. data/lib/jievro/parser/grammar/wildcard.treetop +1 -1
  38. data/lib/jievro/parser/parse_result.rb +3 -9
  39. data/lib/jievro/parser/string_parser.rb +3 -2
  40. data/lib/jievro/parser/tools/shunting_yard.rb +1 -1
  41. data/lib/jievro/parser/version.rb +1 -1
  42. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9265ff73d1bf35da428218e5880fadd8db1742d4
4
- data.tar.gz: aac8b8c5d9b50f766ab0a0f91f1a633753ab3dc8
3
+ metadata.gz: d56703e726b140d5f670a4612faebbfbf231ec1f
4
+ data.tar.gz: 83a92536b8ee7c04845ba217a70f464258328da6
5
5
  SHA512:
6
- metadata.gz: 2783011135c322c5d83a8b6c5e796705e296c665b7233758c4bb06708a3e97ab8c8ae9fe3df82a5f68859b17e4610a0755103129c4be6963fb8d8b8c7c80ea0f
7
- data.tar.gz: 9ea99720dd29d55207ef5f74f146f9e0de39ea8195b8e552eed504de979e4e88a676c132884bea17d0f19713814aaaf455b4fc6e97969d679ebfb3af32c7ea82
6
+ metadata.gz: 13370ace3ab61ee7218449f6a74e1529cda2b89a00b0c1374f4c23c215a53c4062d4c42fbed6f9006a52d9e6b24f110aca5381dba9ae45f3cd483cbdbcf143b8
7
+ data.tar.gz: b990775579e54f24dac0144200f23d92b682ec0778e819a65463d8456eb88008a7644c30c51f41d13e24884e713995b8653142d44317f0177fc85499408f0f0e
data/.travis.yml CHANGED
@@ -1,3 +1,7 @@
1
1
  language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - 2.2.0
2
6
 
3
7
  script: bundle exec rake test
data/Gemfile.lock CHANGED
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jievro-parser (0.7.0)
4
+ jievro-parser (0.8.0)
5
+ jievro-ast (~> 0.5)
5
6
  treetop (~> 1.6)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
11
  diff-lcs (1.2.5)
12
+ jievro-ast (0.5.0)
11
13
  polyglot (0.3.5)
12
14
  rake (10.4.2)
13
15
  rspec (3.2.0)
data/Rakefile CHANGED
@@ -3,5 +3,5 @@ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:test) do |t|
5
5
  t.ruby_opts = %w(-I lib -I spec)
6
- t.rspec_opts = '--color --format progress'
6
+ t.rspec_opts = '--color --format progress --fail-fast'
7
7
  end
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = '~> 2.0'
20
20
 
21
+ spec.add_runtime_dependency 'jievro-ast', '~> 0.5'
21
22
  spec.add_runtime_dependency 'treetop', '~> 1.6'
22
23
 
23
24
  spec.add_development_dependency 'bundler', '~> 1.9'
@@ -24,7 +24,7 @@ module Kauri
24
24
 
25
25
  pattern_initializer_list.ast.each { |e|
26
26
  ast.push({
27
- node_type: 'constant-declaration',
27
+ __type: 'constant-declaration',
28
28
  pattern: e[:pattern],
29
29
  initializer: e[:initializer]
30
30
  })
@@ -40,7 +40,7 @@ module Kauri
40
40
 
41
41
  [
42
42
  {
43
- node_type: 'function-declaration',
43
+ __type: 'function-declaration',
44
44
  name: name,
45
45
  parameters: parameters,
46
46
  return_type: return_type,
@@ -253,6 +253,7 @@ module Kauri
253
253
  end
254
254
 
255
255
  {
256
+ __type: 'function-declaration-parameter',
256
257
  type: type,
257
258
  local: local,
258
259
  external: external,
@@ -24,7 +24,7 @@ module Kauri
24
24
 
25
25
  pattern_initializer_list.ast.each { |e|
26
26
  ast.push({
27
- node_type: 'variable-declaration',
27
+ __type: 'variable-declaration',
28
28
  pattern: e[:pattern],
29
29
  initializer: e[:initializer]
30
30
  })
@@ -40,7 +40,7 @@ module Kauri
40
40
  def ast
41
41
 
42
42
  ast = {
43
- node_type: 'closure-expression',
43
+ __type: 'closure-expression',
44
44
  body: statement_list.ast
45
45
  }
46
46
 
@@ -111,7 +111,9 @@ module Kauri
111
111
 
112
112
  def ast
113
113
  {
114
+ __type: 'closure-expression-signature',
114
115
  capture: {
116
+ __type: 'closure-expression-capture-specifier',
115
117
  specifier: capture_specifier.ast,
116
118
  expression: expression.ast.first
117
119
  }
@@ -20,7 +20,7 @@ module Kauri
20
20
  def ast
21
21
  [
22
22
  {
23
- node_type: 'function-call-expression',
23
+ __type: 'function-call-expression',
24
24
  callee: callee.ast.first,
25
25
  parameters: parameters.ast
26
26
  }
@@ -134,7 +134,7 @@ module Kauri
134
134
  def ast
135
135
  [
136
136
  {
137
- node_type: 'expression-element',
137
+ __type: 'expression-element',
138
138
  identifier: identifier.ast.first,
139
139
  expression: expression.ast.first
140
140
  }
@@ -13,7 +13,7 @@ module Kauri
13
13
  def ast
14
14
  [
15
15
  {
16
- node_type: 'prefix-expression',
16
+ __type: 'prefix-expression',
17
17
  operator: operator.operator,
18
18
  argument: expression.ast.first
19
19
  }
@@ -27,7 +27,7 @@ module Kauri
27
27
  def ast
28
28
  [
29
29
  {
30
- node_type: 'binary-expression',
30
+ __type: 'binary-expression',
31
31
  operator: range_operator.text_value,
32
32
  left: left.ast.first,
33
33
  right: right.ast.first
@@ -15,7 +15,7 @@ module Kauri
15
15
  def ast
16
16
  [
17
17
  {
18
- node_type: 'self-expression'
18
+ __type: 'self-expression'
19
19
  }
20
20
  ]
21
21
  end
@@ -15,7 +15,7 @@ module Kauri
15
15
  def ast
16
16
  [
17
17
  {
18
- node_type: 'super-expression'
18
+ __type: 'super-expression'
19
19
  }
20
20
  ]
21
21
  end
@@ -61,7 +61,7 @@ module Jievro
61
61
  end
62
62
 
63
63
  {
64
- node_type: 'program',
64
+ __type: 'program',
65
65
  body: body
66
66
  }
67
67
  end
@@ -23,7 +23,7 @@ module Kauri
23
23
  def ast
24
24
  [
25
25
  {
26
- node_type: 'identifier',
26
+ __type: 'identifier',
27
27
  value: text_value
28
28
  }
29
29
  ]
@@ -45,7 +45,7 @@ module Kauri
45
45
  def ast
46
46
  [
47
47
  {
48
- node_type: 'identifier',
48
+ __type: 'identifier',
49
49
  value: regular_identifier.text_value
50
50
  }
51
51
  ]
@@ -15,7 +15,7 @@ module Kauri
15
15
  def ast
16
16
  [
17
17
  {
18
- node_type: 'implicit-parameter-name',
18
+ __type: 'implicit-parameter-name',
19
19
  value: literal_integer_decimal.text_value,
20
20
  }
21
21
  ]
@@ -41,7 +41,7 @@ module Kauri
41
41
 
42
42
  [
43
43
  {
44
- node_type: 'literal-array',
44
+ __type: 'literal-array',
45
45
  values: values
46
46
  }
47
47
  ]
@@ -18,7 +18,7 @@ module Kauri
18
18
  def ast
19
19
  [
20
20
  {
21
- node_type: 'literal-boolean',
21
+ __type: 'literal-boolean',
22
22
  value: true
23
23
  }
24
24
  ]
@@ -39,7 +39,7 @@ module Kauri
39
39
  def ast
40
40
  [
41
41
  {
42
- node_type: 'literal-boolean',
42
+ __type: 'literal-boolean',
43
43
  value: false
44
44
  }
45
45
  ]
@@ -26,7 +26,7 @@ module Kauri
26
26
 
27
27
  [
28
28
  {
29
- node_type: 'literal-double',
29
+ __type: 'literal-double',
30
30
  value: converter.convert(text_value)
31
31
  }
32
32
  ]
@@ -57,7 +57,7 @@ module Kauri
57
57
  ast = items.ast
58
58
  else
59
59
  ast = [{
60
- node_type: 'literal-dictionary',
60
+ __type: 'literal-dictionary',
61
61
  pairs: []
62
62
  }]
63
63
  end
@@ -95,6 +95,7 @@ module Kauri
95
95
  def ast
96
96
  [
97
97
  {
98
+ __type: 'literal-dictionary-pair',
98
99
  key: key.ast.first,
99
100
  value: value.ast.first
100
101
  }
@@ -146,7 +147,7 @@ module Kauri
146
147
 
147
148
  [
148
149
  {
149
- node_type: 'literal-dictionary',
150
+ __type: 'literal-dictionary',
150
151
  pairs: pairs
151
152
  }
152
153
  ]
@@ -24,7 +24,7 @@ module Kauri
24
24
 
25
25
  [
26
26
  {
27
- node_type: 'literal-double',
27
+ __type: 'literal-double',
28
28
  value: converter.convert(text_value)
29
29
  }
30
30
  ]
@@ -20,7 +20,7 @@ module Kauri
20
20
 
21
21
  [
22
22
  {
23
- node_type: 'literal-integer',
23
+ __type: 'literal-integer',
24
24
  value: converter.convert(text_value)
25
25
  }
26
26
  ]
@@ -20,7 +20,7 @@ module Kauri
20
20
 
21
21
  [
22
22
  {
23
- node_type: 'literal-integer',
23
+ __type: 'literal-integer',
24
24
  value: converter.convert(text_value)
25
25
  }
26
26
  ]
@@ -20,7 +20,7 @@ module Kauri
20
20
 
21
21
  [
22
22
  {
23
- node_type: 'literal-integer',
23
+ __type: 'literal-integer',
24
24
  value: converter.convert(text_value)
25
25
  }
26
26
  ]
@@ -20,7 +20,7 @@ module Kauri
20
20
 
21
21
  [
22
22
  {
23
- node_type: 'literal-integer',
23
+ __type: 'literal-integer',
24
24
  value: converter.convert(text_value)
25
25
  }
26
26
  ]
@@ -15,7 +15,7 @@ module Kauri
15
15
  def ast
16
16
  [
17
17
  {
18
- node_type: 'literal-nil'
18
+ __type: 'literal-nil'
19
19
  }
20
20
  ]
21
21
  end
@@ -29,7 +29,7 @@ module Kauri
29
29
  if quoted_text.text_value.empty?
30
30
  ast = [
31
31
  {
32
- node_type: 'literal-string',
32
+ __type: 'literal-string',
33
33
  value: ''
34
34
  }
35
35
  ]
@@ -75,7 +75,7 @@ module Kauri
75
75
  ast[-1][:value] += value
76
76
  else
77
77
  ast.push({
78
- node_type: 'literal-string',
78
+ __type: 'literal-string',
79
79
  value: value
80
80
  })
81
81
  end
@@ -86,7 +86,7 @@ module Kauri
86
86
  if is_interpolated_string
87
87
  ast = [
88
88
  {
89
- node_type: 'interpolated-string',
89
+ __type: 'interpolated-string',
90
90
  value: ast
91
91
  }
92
92
  ]
@@ -20,7 +20,7 @@ module Kauri
20
20
  def ast
21
21
 
22
22
  ast = {
23
- node_type: 'if-statement',
23
+ __type: 'if-statement',
24
24
  condition: condition.ast.first,
25
25
  body: body.ast
26
26
  }
@@ -20,7 +20,7 @@ module Kauri
20
20
  def ast
21
21
  [
22
22
  {
23
- node_type: 'do-while-statement',
23
+ __type: 'do-while-statement',
24
24
  body: body.ast,
25
25
  test: test.ast.first
26
26
  }
@@ -25,7 +25,7 @@ module Kauri
25
25
  body = for_body.ast
26
26
 
27
27
  ast = {
28
- node_type: 'for-statement',
28
+ __type: 'for-statement',
29
29
  init: init
30
30
  }
31
31
 
@@ -22,7 +22,7 @@ module Kauri
22
22
  def ast
23
23
  [
24
24
  {
25
- node_type: 'for-in-statement',
25
+ __type: 'for-in-statement',
26
26
  iterator: iterator.ast.first,
27
27
  collection: collection.ast.first,
28
28
  body: body.ast
@@ -18,7 +18,7 @@ module Kauri
18
18
  def ast
19
19
  [
20
20
  {
21
- node_type: 'while-statement',
21
+ __type: 'while-statement',
22
22
  condition: condition.ast.first,
23
23
  body: body.ast
24
24
  }
@@ -32,7 +32,7 @@ module Kauri
32
32
  def ast
33
33
  [
34
34
  {
35
- node_type: 'array',
35
+ __type: 'array',
36
36
  type: type.ast.first
37
37
  }
38
38
  ]
@@ -47,7 +47,7 @@ module Kauri
47
47
  def ast
48
48
  [
49
49
  {
50
- node_type: 'dictionary',
50
+ __type: 'dictionary',
51
51
  key_type: key_type.ast.first,
52
52
  value_type: value_type.ast.first
53
53
  }
@@ -15,7 +15,7 @@ module Kauri
15
15
  def ast
16
16
  [
17
17
  {
18
- node_type: 'wildcard'
18
+ __type: 'wildcard'
19
19
  }
20
20
  ]
21
21
  end
@@ -1,18 +1,12 @@
1
1
  module Jievro
2
2
  module Parser
3
- class ParseResult
3
+ class ParseResult
4
+ attr_reader :tokens, :ast
5
+
4
6
  def initialize(tokens, ast)
5
7
  @tokens = tokens
6
8
  @ast = ast
7
9
  end
8
-
9
- def tokens
10
- @tokens
11
- end
12
-
13
- def ast
14
- @ast
15
- end
16
10
  end
17
11
  end
18
12
  end
@@ -2,6 +2,7 @@ require 'treetop'
2
2
  require 'polyglot'
3
3
  require 'jievro/parser/grammar/grammar'
4
4
  require 'jievro/parser/parse_result'
5
+ require 'jievro/ast/node'
5
6
 
6
7
  module Jievro
7
8
  module Parser
@@ -12,7 +13,7 @@ module Jievro
12
13
 
13
14
  tokens = []
14
15
  ast = {
15
- node_type: 'program',
16
+ __type: 'program',
16
17
  body: []
17
18
  }
18
19
 
@@ -28,7 +29,7 @@ module Jievro
28
29
  ast = parsed.ast
29
30
  end
30
31
 
31
- Jievro::Parser::ParseResult.new(tokens, ast)
32
+ Jievro::Parser::ParseResult.new(tokens, Jievro::Ast::Node.new(ast))
32
33
  end
33
34
  end
34
35
  end
@@ -17,7 +17,7 @@ module Jievro
17
17
  left = node_stack.pop
18
18
 
19
19
  node_stack.push({
20
- node_type: 'binary-expression',
20
+ __type: 'binary-expression',
21
21
  operator: token,
22
22
  left: left,
23
23
  right: right
@@ -1,5 +1,5 @@
1
1
  module Jievro
2
2
  module Parser
3
- VERSION = '0.7.0'
3
+ VERSION = '0.8.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jievro-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Azzalini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jievro-ast
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: treetop
15
29
  requirement: !ruby/object:Gem::Requirement