ruby-ll 2.0.0-java → 2.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f307cb5b874f4f151092083942884b5077e5fab
4
- data.tar.gz: 1a9dbbcd10bd6898a709aa5759d5f91030272e8f
3
+ metadata.gz: 4f3c66d4523120a5e1f5ef8c6c32f45915c072d8
4
+ data.tar.gz: 49d49c6a297f2e2f5a0ac1514b232e7cfa4253ea
5
5
  SHA512:
6
- metadata.gz: d397ac3dac1792bb4310508aaec7ee448cfe0f09f9fa1072daa5c53f1b8ea290c2ff342897e8edfcced314d5b9fa0715970dccadea8ac0c9f0b23be1dced959b
7
- data.tar.gz: 76771a39c8fdebf2e64f5b0535a019c22ac5aff0907b96f2a8d91ec5d5f054f742aa3fc75dd847cb1c050c1e1a60c79269308a2eb6aa596cd9923479a21b3665
6
+ metadata.gz: f910a5007ee6a672b5b5ac517ed70c82843ace40f44d241a22c039d984b33fea351488eae1af64bfc88d8d41236ad81fc01dae55afb58d2ae0e3fb8371dcc12b
7
+ data.tar.gz: 7f20ee290e31e4c16a08bd1c438c80cadccb722b6096a37154092eff0420e250ca2238aa5f405b4dcd412242993c13d46e15ab3f701fbe802c375e34eb120835
data/README.md CHANGED
@@ -20,9 +20,10 @@ For more information on LL parsing, see
20
20
 
21
21
  ## Features
22
22
 
23
- * Support for detecting first/first and first/follow conflicts
24
- * clang-like error/warning messages to ease debugging parsers
25
- * High performance and a low memory footprint
23
+ * Support for detecting first/first and first/follow conflicts.
24
+ * clang-like error/warning messages to ease debugging parsers.
25
+ * High performance and a low memory footprint.
26
+ * Support for the `*`, `+` and `?` operators.
26
27
 
27
28
  ## Requirements
28
29
 
@@ -326,7 +327,8 @@ It's also an error to re-define an existing rule.
326
327
  ### Operators
327
328
 
328
329
  Grammars can use two operators to define a sequence of terminals/non-terminals:
329
- the star (`*`) and plus (`+`) operators.
330
+ the star (`*`) and plus (`+`) operators. There's also the `?` (question)
331
+ operator which can be used to indicate something as being optional.
330
332
 
331
333
  The star operator indicates that something should occur 0 or more times. Here
332
334
  the "B" identifier could occur 0 times, once, twice or many more times:
@@ -339,6 +341,17 @@ should occur at least once but can also occur, say, 10 times:
339
341
 
340
342
  A = B+;
341
343
 
344
+ The question operator can be used as an alternative to the following pattern:
345
+
346
+ # "A" or "A C"
347
+ A = B A_follow;
348
+
349
+ A_follow = C | _;
350
+
351
+ Using this operator you can simply write the following:
352
+
353
+ A = B C?;
354
+
342
355
  Operators can be applied either to a single terminal/rule or a series of
343
356
  terminals/rules grouped together using parenthesis. For example, both are
344
357
  perfectly valid:
@@ -9,6 +9,7 @@
9
9
  #define T_PLUS 5
10
10
  #define T_ADD_VALUE_STACK 6
11
11
  #define T_APPEND_VALUE_STACK 7
12
+ #define T_QUESTION 8
12
13
 
13
14
  ID id_config_const;
14
15
  ID id_each_token;
@@ -184,6 +185,27 @@ VALUE ll_driver_each_token(VALUE token, VALUE self)
184
185
  }
185
186
  }
186
187
  }
188
+ /* "?" operator */
189
+ else if ( stack_type == T_QUESTION )
190
+ {
191
+ production_i = state->config->table[stack_value][token_id];
192
+
193
+ if ( production_i == T_EOF )
194
+ {
195
+ kv_push(VALUE, state->value_stack, Qnil);
196
+ }
197
+ else
198
+ {
199
+ FOR(rule_i, state->config->rule_lengths[production_i])
200
+ {
201
+ kv_push(
202
+ long,
203
+ state->stack,
204
+ state->config->rules[production_i][rule_i]
205
+ );
206
+ }
207
+ }
208
+ }
187
209
  /*
188
210
  Adds a new array to the value stack that can be used to group operator
189
211
  values together
@@ -36,6 +36,7 @@ public class Driver extends RubyObject
36
36
  private static long T_PLUS = 5;
37
37
  private static long T_ADD_VALUE_STACK = 6;
38
38
  private static long T_APPEND_VALUE_STACK = 7;
39
+ private static long T_QUESTION = 8;
39
40
 
40
41
  /**
41
42
  * The current Ruby runtime.
@@ -200,6 +201,28 @@ public class Driver extends RubyObject
200
201
  }
201
202
  }
202
203
  }
204
+ // "?" operator
205
+ else if ( stack_type == self.T_QUESTION )
206
+ {
207
+ Long production_i = self.config.table
208
+ .get(stack_value.intValue())
209
+ .get(token_id.intValue());
210
+
211
+ if ( production_i == self.T_EOF )
212
+ {
213
+ value_stack.push(context.nil);
214
+ }
215
+ else
216
+ {
217
+ ArrayList<Long> row = self.config.rules
218
+ .get(production_i.intValue());
219
+
220
+ for ( int index = 0; index < row.size(); index++ )
221
+ {
222
+ stack.push(row.get(index));
223
+ }
224
+ }
225
+ }
203
226
  // Adds a new array to the value stack that can be used to
204
227
  // group operator values together
205
228
  else if ( stack_type == self.T_ADD_VALUE_STACK )
Binary file
@@ -16,9 +16,17 @@ module LL
16
16
  :star => 4,
17
17
  :plus => 5,
18
18
  :add_value_stack => 6,
19
- :append_value_stack => 7
19
+ :append_value_stack => 7,
20
+ :question => 8
20
21
  }.freeze
21
22
 
23
+ ##
24
+ # Operators which don't require a value stack.
25
+ #
26
+ # @return [Array]
27
+ #
28
+ SKIP_VALUE_STACK = [:question]
29
+
22
30
  ##
23
31
  # @return [String]
24
32
  #
@@ -167,8 +175,10 @@ module LL
167
175
  row << TYPES[step.type]
168
176
  row << rule_indices[step.receiver]
169
177
 
170
- row << TYPES[:add_value_stack]
171
- row << 0
178
+ unless SKIP_VALUE_STACK.include?(step.type)
179
+ row << TYPES[:add_value_stack]
180
+ row << 0
181
+ end
172
182
  end
173
183
  end
174
184
 
@@ -34,6 +34,8 @@ module LL
34
34
  message = %Q{Unexpected #{token_type} for a "*" operator}
35
35
  when :plus
36
36
  message = %Q{Unexpected #{token_type} for a "+" operator}
37
+ when :question
38
+ message = %Q{Unexpected #{token_type} for a "?" operator}
37
39
  end
38
40
 
39
41
  return message
@@ -362,6 +362,27 @@ module LL
362
362
  return Operator.new(:plus, rule, node.source_line)
363
363
  end
364
364
 
365
+ ##
366
+ # Processes the "?" operator.
367
+ #
368
+ # @param [LL::AST::Node] node
369
+ # @param [LL::CompiledGrammar] compiled_grammar
370
+ # @return [LL::Operator]
371
+ #
372
+ def on_question(node, compiled_grammar)
373
+ steps = lookup_identifiers(node, compiled_grammar)
374
+ name = "_ll_question#{node.source_line.line}#{node.source_line.column}"
375
+ rule = Rule.new(name, node.source_line)
376
+
377
+ rule.add_branch(steps, node.source_line)
378
+
379
+ rule.increment_references
380
+
381
+ compiled_grammar.add_rule(rule)
382
+
383
+ return Operator.new(:question, rule, node.source_line)
384
+ end
385
+
365
386
  private
366
387
 
367
388
  ##
@@ -67,46 +67,46 @@ self._ll_lexer_indicies = [
67
67
  1, 28, 1, 29, 1, 1, 30, 31,
68
68
  32, 33, 1, 1, 1, 1, 25, 25,
69
69
  25, 25, 25, 25, 25, 25, 25, 25,
70
- 34, 35, 1, 36, 1, 1, 1, 25,
70
+ 34, 35, 1, 36, 1, 37, 1, 25,
71
71
  25, 25, 25, 25, 25, 25, 25, 25,
72
72
  25, 25, 25, 25, 25, 25, 25, 25,
73
73
  25, 25, 25, 25, 25, 25, 25, 25,
74
- 25, 1, 1, 1, 1, 37, 1, 25,
74
+ 25, 1, 1, 1, 1, 38, 1, 25,
75
75
  25, 25, 25, 25, 25, 25, 25, 25,
76
76
  25, 25, 25, 25, 25, 25, 25, 25,
77
77
  25, 25, 25, 25, 25, 25, 25, 25,
78
- 25, 38, 39, 1, 1, 1, 25, 40,
79
- 40, 40, 40, 40, 40, 40, 40, 40,
80
- 40, 40, 40, 40, 40, 40, 40, 40,
81
- 40, 40, 40, 40, 40, 40, 40, 40,
82
- 40, 40, 40, 40, 40, 40, 40, 40,
83
- 40, 40, 40, 40, 40, 40, 40, 40,
84
- 40, 40, 40, 40, 40, 40, 40, 25,
78
+ 25, 39, 40, 1, 1, 1, 25, 41,
79
+ 41, 41, 41, 41, 41, 41, 41, 41,
80
+ 41, 41, 41, 41, 41, 41, 41, 41,
81
+ 41, 41, 41, 41, 41, 41, 41, 41,
82
+ 41, 41, 41, 41, 41, 41, 41, 41,
83
+ 41, 41, 41, 41, 41, 41, 41, 41,
84
+ 41, 41, 41, 41, 41, 41, 41, 25,
85
85
  25, 25, 25, 25, 25, 25, 25, 25,
86
- 25, 40, 40, 40, 40, 40, 40, 40,
86
+ 25, 41, 41, 41, 41, 41, 41, 41,
87
87
  25, 25, 25, 25, 25, 25, 25, 25,
88
88
  25, 25, 25, 25, 25, 25, 25, 25,
89
89
  25, 25, 25, 25, 25, 25, 25, 25,
90
- 25, 25, 40, 40, 40, 40, 25, 40,
90
+ 25, 25, 41, 41, 41, 41, 25, 41,
91
91
  25, 25, 25, 25, 25, 25, 25, 25,
92
92
  25, 25, 25, 25, 25, 25, 25, 25,
93
93
  25, 25, 25, 25, 25, 25, 25, 25,
94
- 25, 25, 40, 40, 40, 40, 40, 25,
95
- 41, 28, 43, 42, 42, 42, 42, 42,
96
- 42, 42, 42, 42, 42, 42, 42, 42,
97
- 42, 42, 42, 42, 42, 42, 42, 42,
98
- 42, 42, 42, 42, 42, 42, 42, 42,
99
- 42, 42, 42, 42, 42, 42, 42, 42,
100
- 42, 42, 42, 42, 42, 42, 42, 42,
101
- 42, 42, 42, 42, 42, 42, 42, 42,
102
- 42, 42, 42, 42, 42, 42, 42, 42,
103
- 42, 42, 42, 42, 42, 42, 42, 42,
104
- 42, 42, 42, 42, 42, 42, 42, 42,
105
- 42, 42, 42, 42, 42, 42, 42, 42,
106
- 42, 42, 42, 42, 42, 42, 42, 42,
107
- 42, 42, 42, 42, 42, 42, 42, 42,
108
- 42, 42, 42, 42, 42, 42, 42, 42,
109
- 42, 42, 42, 44, 42, 45, 42, 0
94
+ 25, 25, 41, 41, 41, 41, 41, 25,
95
+ 42, 28, 44, 43, 43, 43, 43, 43,
96
+ 43, 43, 43, 43, 43, 43, 43, 43,
97
+ 43, 43, 43, 43, 43, 43, 43, 43,
98
+ 43, 43, 43, 43, 43, 43, 43, 43,
99
+ 43, 43, 43, 43, 43, 43, 43, 43,
100
+ 43, 43, 43, 43, 43, 43, 43, 43,
101
+ 43, 43, 43, 43, 43, 43, 43, 43,
102
+ 43, 43, 43, 43, 43, 43, 43, 43,
103
+ 43, 43, 43, 43, 43, 43, 43, 43,
104
+ 43, 43, 43, 43, 43, 43, 43, 43,
105
+ 43, 43, 43, 43, 43, 43, 43, 43,
106
+ 43, 43, 43, 43, 43, 43, 43, 43,
107
+ 43, 43, 43, 43, 43, 43, 43, 43,
108
+ 43, 43, 43, 43, 43, 43, 43, 43,
109
+ 43, 43, 43, 45, 43, 46, 43, 0
110
110
  ]
111
111
 
112
112
  class << self
@@ -118,8 +118,8 @@ self._ll_lexer_trans_targs = [
118
118
  6, 22, 8, 9, 10, 22, 12, 13,
119
119
  22, 15, 16, 17, 18, 19, 20, 21,
120
120
  22, 23, 22, 22, 24, 1, 22, 22,
121
- 22, 22, 22, 22, 22, 23, 22, 22,
122
- 22, 22, 25, 25, 25, 25
121
+ 22, 22, 22, 22, 22, 22, 23, 22,
122
+ 22, 22, 22, 25, 25, 25, 25
123
123
  ]
124
124
 
125
125
  class << self
@@ -132,7 +132,7 @@ self._ll_lexer_trans_actions = [
132
132
  3, 0, 0, 0, 0, 0, 0, 0,
133
133
  4, 7, 8, 9, 0, 0, 10, 11,
134
134
  12, 13, 14, 15, 16, 17, 18, 19,
135
- 20, 21, 22, 23, 24, 25
135
+ 20, 21, 22, 23, 24, 25, 26
136
136
  ]
137
137
 
138
138
  class << self
@@ -164,8 +164,8 @@ end
164
164
  self._ll_lexer_eof_trans = [
165
165
  0, 0, 0, 0, 0, 0, 0, 0,
166
166
  0, 0, 0, 0, 0, 0, 0, 0,
167
- 0, 0, 0, 0, 0, 0, 0, 41,
168
- 42, 0
167
+ 0, 0, 0, 0, 0, 0, 0, 42,
168
+ 43, 0
169
169
  ]
170
170
 
171
171
  class << self
@@ -312,13 +312,13 @@ ts = p
312
312
  cs = _ll_lexer_trans_targs[_trans]
313
313
  if _ll_lexer_trans_actions[_trans] != 0
314
314
  case _ll_lexer_trans_actions[_trans]
315
- when 24 then
315
+ when 25 then
316
316
  # line 188 "lib/ll/lexer.rl"
317
317
  begin
318
318
  te = p+1
319
319
  begin brace_count += 1 end
320
320
  end
321
- when 25 then
321
+ when 26 then
322
322
  # line 190 "lib/ll/lexer.rl"
323
323
  begin
324
324
  te = p+1
@@ -338,7 +338,7 @@ te = p+1
338
338
  end
339
339
  end
340
340
  end
341
- when 22 then
341
+ when 23 then
342
342
  # line 206 "lib/ll/lexer.rl"
343
343
  begin
344
344
  te = p+1
@@ -385,7 +385,7 @@ te = p+1
385
385
  te = p+1
386
386
  begin emit(:T_SEMICOLON, ts, te) end
387
387
  end
388
- when 19 then
388
+ when 20 then
389
389
  # line 223 "lib/ll/lexer.rl"
390
390
  begin
391
391
  te = p+1
@@ -403,20 +403,26 @@ te = p+1
403
403
  te = p+1
404
404
  begin emit(:T_STAR, ts, te) end
405
405
  end
406
- when 10 then
406
+ when 17 then
407
407
  # line 227 "lib/ll/lexer.rl"
408
408
  begin
409
+ te = p+1
410
+ begin emit(:T_QUESTION, ts, te) end
411
+ end
412
+ when 10 then
413
+ # line 228 "lib/ll/lexer.rl"
414
+ begin
409
415
  te = p+1
410
416
  begin emit(:T_LPAREN, ts, te) end
411
417
  end
412
418
  when 11 then
413
- # line 228 "lib/ll/lexer.rl"
419
+ # line 229 "lib/ll/lexer.rl"
414
420
  begin
415
421
  te = p+1
416
422
  begin emit(:T_RPAREN, ts, te) end
417
423
  end
418
- when 18 then
419
- # line 230 "lib/ll/lexer.rl"
424
+ when 19 then
425
+ # line 231 "lib/ll/lexer.rl"
420
426
  begin
421
427
  te = p+1
422
428
  begin
@@ -429,26 +435,26 @@ te = p+1
429
435
  cs = 25;
430
436
  end
431
437
  end
432
- when 21 then
438
+ when 22 then
433
439
  # line 213 "lib/ll/lexer.rl"
434
440
  begin
435
441
  te = p
436
442
  p = p - 1; end
437
- when 20 then
443
+ when 21 then
438
444
  # line 1 "NONE"
439
445
  begin
440
446
  case act
441
447
  when 16 then
442
448
  begin begin p = ((te))-1; end
443
449
  emit(:T_EPSILON, ts, te) end
444
- when 22 then
450
+ when 23 then
445
451
  begin begin p = ((te))-1; end
446
452
 
447
453
  emit(:T_IDENT, ts, te)
448
454
  end
449
455
  end
450
456
  end
451
- when 23 then
457
+ when 24 then
452
458
  # line 148 "lib/ll/lexer.rl"
453
459
  begin
454
460
 
@@ -482,7 +488,7 @@ te = p+1
482
488
  begin
483
489
  te = p+1
484
490
  end
485
- when 17 then
491
+ when 18 then
486
492
  # line 1 "NONE"
487
493
  begin
488
494
  te = p+1
@@ -497,8 +503,8 @@ te = p+1
497
503
  end
498
504
  # line 168 "lib/ll/lexer.rl"
499
505
  begin
500
- act = 22; end
501
- # line 501 "lib/ll/lexer.rb"
506
+ act = 23; end
507
+ # line 507 "lib/ll/lexer.rb"
502
508
  end
503
509
  end
504
510
  end
@@ -508,7 +514,7 @@ act = 22; end
508
514
  # line 1 "NONE"
509
515
  begin
510
516
  ts = nil; end
511
- # line 511 "lib/ll/lexer.rb"
517
+ # line 517 "lib/ll/lexer.rb"
512
518
  end
513
519
 
514
520
  if cs == 0
@@ -600,7 +606,7 @@ end
600
606
  end
601
607
 
602
608
 
603
- # line 242 "lib/ll/lexer.rl"
609
+ # line 243 "lib/ll/lexer.rl"
604
610
 
605
611
  end # Lexer
606
612
  end # Oga
@@ -21,119 +21,112 @@ class Parser < LL::Driver
21
21
  :T_SEMICOLON, # 11
22
22
  :T_STAR, # 12
23
23
  :T_PLUS, # 13
24
- :T_LPAREN, # 14
25
- :T_RPAREN, # 15
24
+ :T_QUESTION, # 14
25
+ :T_LPAREN, # 15
26
+ :T_RPAREN, # 16
26
27
  ].freeze
27
28
 
28
29
  CONFIG.rules = [
29
30
  [3, 0, 0, 1], # 0
30
- [3, 1, 2, 0], # 1
31
- [3, 2, 0, 1, 0, 2], # 2
32
- [3, 3, 2, 0], # 3
33
- [3, 4, 0, 23], # 4
34
- [3, 5, 0, 3], # 5
35
- [3, 6, 0, 5], # 6
36
- [3, 7, 0, 6], # 7
37
- [3, 8, 0, 7], # 8
38
- [3, 9, 1, 11, 0, 4, 0, 10, 1, 2], # 9
39
- [3, 10, 0, 4, 0, 10, 1, 8, 1, 8], # 10
40
- [3, 11, 2, 0], # 11
41
- [3, 12, 1, 11, 0, 8, 1, 3], # 12
42
- [3, 13, 0, 20, 1, 4], # 13
43
- [3, 14, 0, 20, 1, 5], # 14
44
- [3, 15, 0, 9, 0, 10], # 15
45
- [3, 16, 0, 8], # 16
46
- [3, 17, 2, 0], # 17
47
- [3, 18, 1, 6], # 18
48
- [3, 19, 0, 12, 0, 13], # 19
49
- [3, 20, 0, 15, 1, 15, 0, 8, 1, 14], # 20
50
- [3, 21, 0, 11], # 21
51
- [3, 22, 2, 0], # 22
52
- [3, 23, 0, 14, 0, 10], # 23
53
- [3, 24, 0, 15], # 24
54
- [3, 25, 2, 0], # 25
55
- [3, 26, 1, 13], # 26
56
- [3, 27, 1, 12], # 27
57
- [3, 28, 0, 11], # 28
58
- [3, 29, 0, 17], # 29
59
- [3, 30, 1, 10], # 30
60
- [3, 31, 0, 19, 0, 16], # 31
61
- [3, 32, 0, 20], # 32
62
- [3, 33, 2, 0], # 33
63
- [3, 34, 1, 1], # 34
64
- [3, 35, 0, 22, 0, 18], # 35
65
- [3, 36, 0, 21, 1, 9], # 36
66
- [3, 37, 2, 0], # 37
67
- [3, 38, 1, 11, 0, 21, 1, 7, 0, 10], # 38
31
+ [3, 1, 4, 19, 6, 0], # 1
32
+ [3, 2, 0, 18], # 2
33
+ [3, 3, 0, 3], # 3
34
+ [3, 4, 0, 5], # 4
35
+ [3, 5, 0, 6], # 5
36
+ [3, 6, 0, 7], # 6
37
+ [3, 7, 1, 11, 4, 20, 6, 0, 0, 9, 1, 2], # 7
38
+ [3, 8, 0, 9, 1, 8, 1, 8], # 8
39
+ [3, 9, 1, 11, 0, 8, 1, 3], # 9
40
+ [3, 10, 0, 15, 1, 4], # 10
41
+ [3, 11, 0, 15, 1, 5], # 11
42
+ [3, 12, 5, 21, 6, 0], # 12
43
+ [3, 13, 1, 6], # 13
44
+ [3, 14, 8, 22, 0, 9], # 14
45
+ [3, 15, 0, 11, 1, 16, 0, 8, 1, 15], # 15
46
+ [3, 16, 1, 13], # 16
47
+ [3, 17, 1, 12], # 17
48
+ [3, 18, 1, 14], # 18
49
+ [3, 19, 5, 23, 6, 0], # 19
50
+ [3, 20, 0, 13], # 20
51
+ [3, 21, 1, 10], # 21
52
+ [3, 22, 8, 24, 0, 12], # 22
53
+ [3, 23, 1, 1], # 23
54
+ [3, 24, 4, 25, 6, 0, 0, 14], # 24
55
+ [3, 25, 0, 14, 1, 9], # 25
56
+ [3, 26, 1, 11, 0, 16, 1, 7, 0, 9], # 26
57
+ [3, 27, 0, 2], # 27
58
+ [3, 28, 0, 4], # 28
59
+ [3, 29, 0, 9], # 29
60
+ [3, 30, 0, 11], # 30
61
+ [3, 31, 0, 10], # 31
62
+ [3, 32, 0, 15], # 32
63
+ [3, 33, 0, 17], # 33
68
64
  ].freeze
69
65
 
70
66
  CONFIG.table = [
71
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], # 0
72
- [3, 3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3], # 1
73
- [-1, -1, 5, 6, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 2
74
- [-1, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 3
75
- [11, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11], # 4
76
- [-1, -1, -1, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 5
77
- [-1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 6
78
- [-1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 7
79
- [-1, -1, -1, -1, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 8
80
- [17, 17, 17, 17, 17, 17, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17], # 9
81
- [-1, -1, -1, -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 10
82
- [-1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1, -1, -1, -1, 20, -1], # 11
83
- [22, 22, 22, 22, 22, 22, 21, 22, 22, 22, 22, 22, 22, 22, 21, 22], # 12
84
- [-1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 13
85
- [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 24, 25, 25], # 14
86
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 26, -1, -1], # 15
87
- [-1, -1, -1, -1, -1, -1, 28, -1, -1, -1, 29, -1, -1, -1, 28, -1], # 16
88
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, -1, -1, -1, -1, -1], # 17
89
- [-1, -1, -1, -1, -1, -1, 31, -1, -1, -1, 31, -1, -1, -1, 31, -1], # 18
90
- [33, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33], # 19
91
- [-1, 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 20
92
- [-1, -1, -1, -1, -1, -1, 35, -1, -1, -1, 35, -1, -1, -1, 35, -1], # 21
93
- [37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 37, 37, 37, 37, 37, 37], # 22
94
- [-1, -1, -1, -1, -1, -1, 38, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 23
67
+ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], # 0
68
+ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], # 1
69
+ [-1, -1, 3, 4, 5, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 2
70
+ [-1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 3
71
+ [-1, -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1], # 4
72
+ [-1, -1, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 5
73
+ [-1, -1, -1, -1, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 6
74
+ [-1, -1, -1, -1, -1, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 7
75
+ [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], # 8
76
+ [-1, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 9
77
+ [-1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1], # 10
78
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 16, 18, -1, -1], # 11
79
+ [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 19, 19, 19, 19, 19, 19], # 12
80
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, -1, -1, -1, -1, -1, -1], # 13
81
+ [22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22], # 14
82
+ [-1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 15
83
+ [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24], # 16
84
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, 25, -1, -1, -1, -1, -1, -1, -1], # 17
85
+ [-1, -1, -1, -1, -1, -1, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 18
86
+ [-1, -1, 27, 27, 27, 27, 27, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 19
87
+ [-1, -1, -1, -1, -1, -1, -1, -1, 28, -1, -1, -1, -1, -1, -1, -1, -1], # 20
88
+ [-1, -1, -1, -1, -1, -1, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 21
89
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 30, 30, -1, -1], # 22
90
+ [-1, -1, -1, -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, -1, -1, 31, -1], # 23
91
+ [-1, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 24
92
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1], # 25
95
93
  ].freeze
96
94
 
97
95
  CONFIG.actions = [
98
96
  [:_rule_0, 1], # 0
99
- [:_rule_1, 0], # 1
100
- [:_rule_2, 2], # 2
101
- [:_rule_3, 0], # 3
97
+ [:_rule_1, 1], # 1
98
+ [:_rule_2, 1], # 2
99
+ [:_rule_3, 1], # 3
102
100
  [:_rule_4, 1], # 4
103
101
  [:_rule_5, 1], # 5
104
102
  [:_rule_6, 1], # 6
105
- [:_rule_7, 1], # 7
106
- [:_rule_8, 1], # 8
107
- [:_rule_9, 4], # 9
108
- [:_rule_10, 4], # 10
109
- [:_rule_11, 0], # 11
110
- [:_rule_12, 3], # 12
111
- [:_rule_13, 2], # 13
103
+ [:_rule_7, 4], # 7
104
+ [:_rule_8, 3], # 8
105
+ [:_rule_9, 3], # 9
106
+ [:_rule_10, 2], # 10
107
+ [:_rule_11, 2], # 11
108
+ [:_rule_12, 1], # 12
109
+ [:_rule_13, 1], # 13
112
110
  [:_rule_14, 2], # 14
113
- [:_rule_15, 2], # 15
111
+ [:_rule_15, 4], # 15
114
112
  [:_rule_16, 1], # 16
115
- [:_rule_17, 0], # 17
113
+ [:_rule_17, 1], # 17
116
114
  [:_rule_18, 1], # 18
117
- [:_rule_19, 2], # 19
118
- [:_rule_20, 4], # 20
115
+ [:_rule_19, 1], # 19
116
+ [:_rule_20, 1], # 20
119
117
  [:_rule_21, 1], # 21
120
- [:_rule_22, 0], # 22
121
- [:_rule_23, 2], # 23
122
- [:_rule_24, 1], # 24
123
- [:_rule_25, 0], # 25
124
- [:_rule_26, 1], # 26
118
+ [:_rule_22, 2], # 22
119
+ [:_rule_23, 1], # 23
120
+ [:_rule_24, 2], # 24
121
+ [:_rule_25, 2], # 25
122
+ [:_rule_26, 4], # 26
125
123
  [:_rule_27, 1], # 27
126
124
  [:_rule_28, 1], # 28
127
125
  [:_rule_29, 1], # 29
128
126
  [:_rule_30, 1], # 30
129
- [:_rule_31, 2], # 31
127
+ [:_rule_31, 1], # 31
130
128
  [:_rule_32, 1], # 32
131
- [:_rule_33, 0], # 33
132
- [:_rule_34, 1], # 34
133
- [:_rule_35, 2], # 35
134
- [:_rule_36, 2], # 36
135
- [:_rule_37, 0], # 37
136
- [:_rule_38, 4], # 38
129
+ [:_rule_33, 1], # 33
137
130
  ].freeze
138
131
 
139
132
  ##
@@ -181,15 +174,15 @@ class Parser < LL::Driver
181
174
  end
182
175
 
183
176
  def _rule_1(val)
184
- s(:grammar)
177
+ val[0]
185
178
  end
186
179
 
187
180
  def _rule_2(val)
188
- [val[0], *val[1]]
181
+ val[0]
189
182
  end
190
183
 
191
184
  def _rule_3(val)
192
- val
185
+ val[0]
193
186
  end
194
187
 
195
188
  def _rule_4(val)
@@ -205,157 +198,137 @@ class Parser < LL::Driver
205
198
  end
206
199
 
207
200
  def _rule_7(val)
208
- val[0]
201
+
202
+ s(:name, [val[1], *val[2]], :source_line => val[0].source_line)
203
+
209
204
  end
210
205
 
211
206
  def _rule_8(val)
212
- val[0]
207
+ val[2]
213
208
  end
214
209
 
215
210
  def _rule_9(val)
216
211
 
217
- s(:name, [val[1], *val[2]], :source_line => val[0].source_line)
212
+ s(:terminals, val[1], :source_line => val[0].source_line)
218
213
 
219
214
  end
220
215
 
221
216
  def _rule_10(val)
222
- [val[2], *val[3]]
217
+
218
+ s(:inner, [val[1]], :source_line => val[0].source_line)
219
+
223
220
  end
224
221
 
225
222
  def _rule_11(val)
226
- val
223
+
224
+ s(:header, [val[1]], :source_line => val[0].source_line)
225
+
227
226
  end
228
227
 
229
228
  def _rule_12(val)
230
-
231
- s(:terminals, val[1], :source_line => val[0].source_line)
232
-
229
+ val[0]
233
230
  end
234
231
 
235
232
  def _rule_13(val)
236
233
 
237
- s(:inner, [val[1]], :source_line => val[0].source_line)
234
+ s(:ident, [val[0].value], :source_line => val[0].source_line)
238
235
 
239
236
  end
240
237
 
241
238
  def _rule_14(val)
242
239
 
243
- s(:header, [val[1]], :source_line => val[0].source_line)
240
+ val[1] ? s(val[1][0], [val[0]], :source_line => val[1][1]) : val[0]
244
241
 
245
242
  end
246
243
 
247
244
  def _rule_15(val)
248
- [val[0], *val[1]]
245
+
246
+ s(val[3][0], val[1], :source_line => val[0].source_line)
247
+
249
248
  end
250
249
 
251
250
  def _rule_16(val)
252
- val[0]
251
+ [:plus, val[0].source_line]
253
252
  end
254
253
 
255
254
  def _rule_17(val)
256
- val
255
+ [:star, val[0].source_line]
257
256
  end
258
257
 
259
258
  def _rule_18(val)
260
-
261
- s(:ident, [val[0].value], :source_line => val[0].source_line)
262
-
259
+ [:question, val[0].source_line]
263
260
  end
264
261
 
265
262
  def _rule_19(val)
266
- [val[0], *val[1]]
263
+
264
+ s(:steps, val[0], :source_line => val[0][0].source_line)
265
+
267
266
  end
268
267
 
269
268
  def _rule_20(val)
270
269
 
271
- [s(val[3][0], val[1], :source_line => val[0].source_line)]
270
+ s(:steps, [val[0]], :source_line => val[0].source_line)
272
271
 
273
272
  end
274
273
 
275
274
  def _rule_21(val)
276
- val[0]
275
+ s(:epsilon, [], :source_line => val[0].source_line)
277
276
  end
278
277
 
279
278
  def _rule_22(val)
280
- val
279
+
280
+ steps = [val[0]]
281
+
282
+ steps << val[1] if val[1]
283
+
284
+ s(:branch, steps, :source_line => val[0].source_line)
285
+
281
286
  end
282
287
 
283
288
  def _rule_23(val)
284
-
285
- val[1] ? s(val[1][0], [val[0]], :source_line => val[1][1]) : val[0]
286
-
289
+ s(:ruby, [val[0].value], :source_line => val[0].source_line)
287
290
  end
288
291
 
289
292
  def _rule_24(val)
290
- val[0]
293
+ [val[0], *val[1]]
291
294
  end
292
295
 
293
296
  def _rule_25(val)
294
- nil
297
+ val[1]
295
298
  end
296
299
 
297
300
  def _rule_26(val)
298
- [:plus, val[0].source_line]
301
+
302
+ s(:rule, [val[0], *val[2]], :source_line => val[0].source_line)
303
+
299
304
  end
300
305
 
301
306
  def _rule_27(val)
302
- [:star, val[0].source_line]
307
+ val[0]
303
308
  end
304
309
 
305
310
  def _rule_28(val)
306
-
307
- s(:steps, val[0], :source_line => val[0][0].source_line)
308
-
311
+ val[0]
309
312
  end
310
313
 
311
314
  def _rule_29(val)
312
-
313
- s(:steps, [val[0]], :source_line => val[0].source_line)
314
-
315
+ val[0]
315
316
  end
316
317
 
317
318
  def _rule_30(val)
318
- s(:epsilon, [], :source_line => val[0].source_line)
319
+ val[0]
319
320
  end
320
321
 
321
322
  def _rule_31(val)
322
-
323
- steps = [val[0]]
324
-
325
- steps << val[1] if val[1]
326
-
327
- s(:branch, steps, :source_line => val[0].source_line)
328
-
323
+ val[0]
329
324
  end
330
325
 
331
326
  def _rule_32(val)
332
- val[0]
327
+ val[0]
333
328
  end
334
329
 
335
330
  def _rule_33(val)
336
- nil
337
- end
338
-
339
- def _rule_34(val)
340
- s(:ruby, [val[0].value], :source_line => val[0].source_line)
341
- end
342
-
343
- def _rule_35(val)
344
- [val[0], *val[1]]
345
- end
346
-
347
- def _rule_36(val)
348
- val[1]
349
- end
350
-
351
- def _rule_37(val)
352
- val
353
- end
354
-
355
- def _rule_38(val)
356
-
357
- s(:rule, [val[0], *val[2]], :source_line => val[0].source_line)
358
-
331
+ val[0]
359
332
  end
360
333
  end
361
334
  end
@@ -1,3 +1,3 @@
1
1
  module LL
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
3
3
  end # LL
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ll
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - Yorick Peterse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast