depager 0.3.0.b20160729 → 0.3.0.b20250423

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.
Files changed (63) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +44 -0
  3. data/.simplecov +5 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.gpl +339 -0
  6. data/Manifest.txt +73 -0
  7. data/README.en +4 -3
  8. data/README.ja +4 -47
  9. data/Rakefile +31 -0
  10. data/bin/depager +3 -38
  11. data/examples/action_pl0d/pl0d.action.dr +4 -4
  12. data/examples/action_pl0d/test.pl0ds +2 -3
  13. data/examples/c89/c89.dr +4 -4
  14. data/examples/c89/test.c89 +1 -1
  15. data/examples/extension/astdf.rb +4 -5
  16. data/examples/extension/atree.dr +3 -3
  17. data/examples/extension/calc.atree.dr +4 -4
  18. data/examples/extension/calc.simple_action.dr +3 -3
  19. data/examples/extension/paction.dr +3 -3
  20. data/examples/extension/pactiontest.dr +3 -3
  21. data/examples/extension/simple_action.rb +26 -24
  22. data/examples/pl0d/pl0ds.dr +5 -5
  23. data/examples/pl0d/test.pl0ds +2 -2
  24. data/examples/rie_calc/calc.rie.dr +4 -4
  25. data/examples/rie_dcuse/dcuse.rie.dr +4 -4
  26. data/examples/rie_pl0/pl0.rie.dr +3 -3
  27. data/examples/slex_test/divreg.slex.dr +5 -5
  28. data/examples/slex_test/ljoin.slex.dr +5 -5
  29. data/examples/{sample_calc → tiny_calc}/calc.action.dr +4 -4
  30. data/examples/{sample_calc → tiny_calc}/calc.ast.action.dr +20 -9
  31. data/examples/{sample_calc → tiny_calc}/calc.ast.dr +19 -7
  32. data/examples/{sample_calc → tiny_calc}/calc.cst.dr +12 -7
  33. data/examples/{sample_calc → tiny_calc}/calc.dr +1 -1
  34. data/examples/{sample_calc → tiny_calc}/calc.lex.dr +2 -2
  35. data/examples/{sample_calc → tiny_calc}/calc_prec.action.dr +4 -4
  36. data/lib/depager/cli.rb +44 -0
  37. data/lib/depager/grammar.rb +72 -75
  38. data/lib/depager/lr.rb +169 -154
  39. data/lib/depager/parser.rb +90 -103
  40. data/lib/depager/plugins/_rie_debug.rb +63 -0
  41. data/lib/depager/plugins/action.rb +47 -0
  42. data/lib/depager/{ruby/plugins → plugins}/ast.dr +20 -17
  43. data/lib/depager/{ruby/plugins → plugins}/ast.rb +266 -304
  44. data/lib/depager/{ruby/plugins → plugins}/cst.dr +18 -16
  45. data/lib/depager/{ruby/plugins → plugins}/cst.rb +152 -148
  46. data/lib/depager/{ruby/plugins → plugins}/lex.dr +7 -7
  47. data/lib/depager/{ruby/plugins → plugins}/lex.rb +72 -69
  48. data/lib/depager/{ruby/plugins → plugins}/rie.dr +12 -10
  49. data/lib/depager/{ruby/plugins → plugins}/rie.rb +224 -263
  50. data/lib/depager/{ruby/plugins → plugins}/slex.dr +13 -14
  51. data/lib/depager/{ruby/plugins → plugins}/slex.rb +183 -194
  52. data/lib/depager/plugins/srp.rb +46 -0
  53. data/lib/depager/ruby/templates/extension_lalr_master.erb +6 -12
  54. data/lib/depager/ruby/templates/extension_lalr_slave.erb +31 -17
  55. data/lib/depager/ruby/templates/single_lalr_parser.erb +35 -26
  56. data/lib/depager/utils.rb +56 -46
  57. data/lib/depager/version.rb +1 -2
  58. data/lib/depager.rb +166 -176
  59. metadata +38 -33
  60. data/lib/depager/ruby/plugins/_rie_debug.rb +0 -35
  61. data/lib/depager/ruby/plugins/action.rb +0 -53
  62. data/lib/depager/ruby/plugins/srp.rb +0 -56
  63. /data/examples/{sample_calc → tiny_calc}/test.calc +0 -0
@@ -1,9 +1,8 @@
1
1
  %defext Depager::StatefulLexerExtension
2
- %extend Depager::Depager::Lexer ('plugins/lex.rb')
3
- %extend Depager::Depager::Action ('plugins/action.rb')
2
+ %extend Depager::Depager::Lexer ('depager/plugins/lex.rb')
3
+ %extend Depager::Depager::Action ('depager/plugins/action.rb')
4
4
  %decorate @Action
5
- #%decorate Depager::LALR::ShiftReducePrinter ('plugins/srp.rb')
6
- %expanded_code_delimiter DEPAGER_EXPANDED_CODE
5
+ #%decorate Depager::LALR::ShiftReducePrinter ('depager/plugins/srp.rb')
7
6
  %inner{
8
7
  attr_accessor :ins, :code, :optval
9
8
  def init_extension
@@ -14,11 +13,11 @@
14
13
  end
15
14
 
16
15
  def term_extension
17
- @action_code << %{
16
+ @action_code << <<-CODE
18
17
  def after_error
19
18
  warn "StatefulLex: lex_state==\#{@basis.lex_state}" if Depager.debug_mode?
20
19
  end
21
- }
20
+ CODE
22
21
  g_parser.outer_code <<
23
22
  generate_action_decorator_code(@on_reduce, @action_code)
24
23
  end
@@ -53,11 +52,11 @@
53
52
  else
54
53
  end
55
54
  end
56
- @action_code << %{
55
+ @action_code << <<-CODE
57
56
  def #{m_name} val
58
57
  #{codes.join("\n ")}
59
58
  end
60
- }
59
+ CODE
61
60
  end
62
61
  @ins.clear
63
62
  end
@@ -104,7 +103,7 @@
104
103
  else
105
104
  'raise RuntimeError, "must not happen #{@line}"'
106
105
  end
107
- ll << %{
106
+ ll << <<-CODE
108
107
  def lex_#{m}(&block)
109
108
  case @line
110
109
  #{l}
@@ -112,9 +111,9 @@
112
111
  #{else_code}
113
112
  end
114
113
  end
115
- }; #code
114
+ CODE
116
115
  end
117
- g_parser.inner_code << ll << %{
116
+ g_parser.inner_code << ll << <<-CODE
118
117
  attr_accessor :lex_state, :lex_context
119
118
  def lex(&block)
120
119
  @lex_state ||= :START
@@ -126,7 +125,7 @@
126
125
  end while @original_line = @line = file.gets
127
126
  yield nil, nil
128
127
  end
129
- }; #code
128
+ CODE
130
129
  }
131
130
  ;
132
131
  mode_list:
@@ -147,11 +146,11 @@
147
146
  lexact:
148
147
  lexlist opt_noskip ACTION
149
148
  {
150
- %{
149
+ <<-CODE
151
150
  when #{_lexlist.join(', ')}
152
151
  #{ _opt_noskip ? '#' : "@line = $'" }
153
152
  #{ _ACTION.value }
154
- }; #code
153
+ CODE
155
154
  }
156
155
  ;
157
156
  opt_noskip: