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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: depager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.b20160729
4
+ version: 0.3.0.b20250423
5
5
  platform: ruby
6
6
  authors:
7
7
  - maita
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-29 00:00:00.000000000 Z
11
+ date: 2025-04-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A self extensible parser generator.
14
14
  email:
@@ -18,8 +18,14 @@ executables:
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - ".rubocop.yml"
22
+ - ".simplecov"
23
+ - Gemfile
24
+ - LICENSE.gpl
25
+ - Manifest.txt
21
26
  - README.en
22
27
  - README.ja
28
+ - Rakefile
23
29
  - bin/depager
24
30
  - data/depager/misc/depager-mode.el
25
31
  - examples/action_pl0d/pl0d.action.dr
@@ -50,45 +56,45 @@ files:
50
56
  - examples/rie_pl0/orig_ex/exnorw.pl0
51
57
  - examples/rie_pl0/pl0.rie.dr
52
58
  - examples/rie_pl0/test.pl0
53
- - examples/sample_calc/calc.action.dr
54
- - examples/sample_calc/calc.ast.action.dr
55
- - examples/sample_calc/calc.ast.dr
56
- - examples/sample_calc/calc.cst.dr
57
- - examples/sample_calc/calc.dr
58
- - examples/sample_calc/calc.lex.dr
59
- - examples/sample_calc/calc_prec.action.dr
60
- - examples/sample_calc/test.calc
61
59
  - examples/slex_test/divreg.slex.dr
62
60
  - examples/slex_test/ljoin.slex.dr
63
61
  - examples/slex_test/test.divreg
64
62
  - examples/slex_test/test.ljoin
63
+ - examples/tiny_calc/calc.action.dr
64
+ - examples/tiny_calc/calc.ast.action.dr
65
+ - examples/tiny_calc/calc.ast.dr
66
+ - examples/tiny_calc/calc.cst.dr
67
+ - examples/tiny_calc/calc.dr
68
+ - examples/tiny_calc/calc.lex.dr
69
+ - examples/tiny_calc/calc_prec.action.dr
70
+ - examples/tiny_calc/test.calc
65
71
  - lib/depager.rb
72
+ - lib/depager/cli.rb
66
73
  - lib/depager/grammar.rb
67
74
  - lib/depager/lr.rb
68
75
  - lib/depager/parser.rb
69
- - lib/depager/ruby/plugins/_rie_debug.rb
70
- - lib/depager/ruby/plugins/action.rb
71
- - lib/depager/ruby/plugins/ast.dr
72
- - lib/depager/ruby/plugins/ast.rb
73
- - lib/depager/ruby/plugins/cst.dr
74
- - lib/depager/ruby/plugins/cst.rb
75
- - lib/depager/ruby/plugins/lex.dr
76
- - lib/depager/ruby/plugins/lex.rb
77
- - lib/depager/ruby/plugins/rie.dr
78
- - lib/depager/ruby/plugins/rie.rb
79
- - lib/depager/ruby/plugins/slex.dr
80
- - lib/depager/ruby/plugins/slex.rb
81
- - lib/depager/ruby/plugins/srp.rb
76
+ - lib/depager/plugins/_rie_debug.rb
77
+ - lib/depager/plugins/action.rb
78
+ - lib/depager/plugins/ast.dr
79
+ - lib/depager/plugins/ast.rb
80
+ - lib/depager/plugins/cst.dr
81
+ - lib/depager/plugins/cst.rb
82
+ - lib/depager/plugins/lex.dr
83
+ - lib/depager/plugins/lex.rb
84
+ - lib/depager/plugins/rie.dr
85
+ - lib/depager/plugins/rie.rb
86
+ - lib/depager/plugins/slex.dr
87
+ - lib/depager/plugins/slex.rb
88
+ - lib/depager/plugins/srp.rb
82
89
  - lib/depager/ruby/templates/extension_lalr_master.erb
83
90
  - lib/depager/ruby/templates/extension_lalr_slave.erb
84
91
  - lib/depager/ruby/templates/single_lalr_parser.erb
85
92
  - lib/depager/utils.rb
86
93
  - lib/depager/version.rb
87
- homepage: http://depager.rubyforge.org
88
- licenses:
89
- - GPL-3.0
94
+ homepage:
95
+ licenses: []
90
96
  metadata: {}
91
- post_install_message:
97
+ post_install_message:
92
98
  rdoc_options: []
93
99
  require_paths:
94
100
  - lib
@@ -96,16 +102,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
102
  requirements:
97
103
  - - ">="
98
104
  - !ruby/object:Gem::Version
99
- version: '0'
105
+ version: 3.0.0
100
106
  required_rubygems_version: !ruby/object:Gem::Requirement
101
107
  requirements:
102
108
  - - ">"
103
109
  - !ruby/object:Gem::Version
104
110
  version: 1.3.1
105
111
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.6.4
108
- signing_key:
112
+ rubygems_version: 3.4.20
113
+ signing_key:
109
114
  specification_version: 4
110
- summary: Depager is a self extensible parser generator.
115
+ summary: A self extensible parser generator.
111
116
  test_files: []
@@ -1,35 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'pp'
3
- class Depager::RieExtension
4
- module Nodes
5
- def self.defnode name, *args
6
- code = ''; args.each_with_index{|a, x|
7
- code << "def #{a};@_values[#{x}];end; def #{a}=(v);@_values[#{x}]=v;end;"
8
- }; module_eval %{
9
- class #{name}; attr_accessor :lineno, :_values; #{code}
10
- def self.[] *args ; self.new *args ; end
11
- def initialize n, *as; @lineno, @_values = n, as; end
12
- def inspect ; "<#{name}:\#{@_values.inspect}>"; end
13
- def pretty_print q ; q.group(1, "<#{name}:", ">"){ q.pp @_values }; end
14
- end
15
- } # end of eval
16
- end
17
- defnode :N_THREAD, :targets, :excepts
18
- defnode :N_TRANSFER, :targets, :excepts
19
- defnode :N_EXCEPT, :let_or_ids
20
- defnode :N_LET, :atoc, :expr, :state
21
- defnode :N_ACTION, :expr
22
- defnode :N_ATOC, :sym_name, :attr_name, :rx
23
-
24
- class N_ATOC
25
- def inspect
26
- name = sym_name == '$' ? '$'+$grammar.symname($grammar[rx].lhs) : sym_name
27
- "<N_ATOC:#{[name, attr_name, rx].inspect}>"
28
- end
29
- def pretty_print q
30
- name = sym_name == '$' ? '$'+$grammar.symname($grammar[rx].lhs) : sym_name rescue nil
31
- q.group(1, "<N_ATOC:", ">"){ q.pp [name, attr_name, rx] }
32
- end
33
- end
34
- end
35
- end
@@ -1,53 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'plugins/action.rb'
3
-
4
- class Depager::ActionExtension < Depager::Extension
5
- def init_extension
6
- @action_code = ''
7
- @on_reduce = []
8
- end
9
-
10
- def term_extension
11
- g_parser.outer_code <<
12
- generate_action_decorator_code(@on_reduce, @action_code)
13
- end
14
-
15
- def pre_rule_list
16
- if g_parser.original_line =~ /^%ACTION\{\s*$/
17
- while line = file.gets
18
- break if line =~ /^%\}\s*$/
19
- @action_code << line
20
- end
21
- g_parser.update_context ''
22
- end
23
- end
24
-
25
- def post_rhs
26
- if g_parser.line =~ /\s*\{/
27
- @original_line, @line = g_parser.original_line, g_parser.line
28
- lineno = g_parser.file.lineno
29
- code, d = modify_action_code(parse_block)
30
- n = g_parser.rules.size - 1
31
- @action_code <<
32
- expand_inline_code(code, lineno, :wrap => "def _act_#{n} val", :delta => d)
33
- g_parser.update_context @line
34
- @on_reduce[n] = ":_act_#{n}"
35
- end
36
- end
37
-
38
- def modify_action_code code
39
- let_code = ""
40
- if g_parser.rhs_names.size > 0
41
- let_code = g_parser.rhs_names.map do |name|
42
- if name =~ /[a-zA-Z][a-zA-Z0-9_]*/
43
- "_#{name}"
44
- else
45
- '_'
46
- end
47
- end
48
- let_code = " #{let_code.join(', ')}, = *val \n"
49
- end
50
- return let_code << code, 1
51
- end
52
- end
53
-
@@ -1,56 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- class Depager::LALR::ShiftReducePrinter < Depager::LALR::AdvancedParser
3
- def initialize inside
4
- super
5
- end
6
-
7
- def dumpstack stack
8
- result = ''
9
- stack.each_with_index do |v, x|
10
- result += if x % 2 == 0
11
- "(#{v}) "
12
- else
13
- if v[1] == :NT
14
- "#{int_to_nonterm[v[0]]}:#{v[1..-1].inspect} "
15
- elsif int_to_term[v[0]].class == String
16
- "'#{int_to_term[v[0]]}':#{v[1..-1].inspect}"
17
- else
18
- "#{int_to_term[v[0]]}:#{v[1..-1].inspect} "
19
- end
20
- end
21
- end
22
- result
23
- end
24
-
25
- def after_shift
26
- st0 = stack[stack.size - 3]
27
- st = stack.last
28
- sh = int_to_term[stack[stack.size - 2][0]]
29
- la = int_to_term[lookahead[0]]
30
- warn "LA:<#{la}> shift:<#{sh}> state:#{st0}->#{st}"
31
- warn "LINE:<#{basis.line}>"
32
- warn dumpstack(stack) + "\n"
33
- end
34
-
35
- def after_reduce
36
- st = stack.last
37
- re = int_to_nonterm[stack[stack.size - 2][0]]
38
- la = int_to_term[lookahead[0]]
39
- warn "LA:<#{la}> reduce:<#{re}> state: ->#{st}"
40
- warn "LINE:<#{basis.line}>"
41
- warn dumpstack(stack) + "\n"
42
- end
43
-
44
- def after_accept
45
- warn "acc."
46
- end
47
-
48
- def after_error
49
- st = stack.last
50
- re = int_to_nonterm[stack[stack.size - 2][0]]
51
- la = int_to_term[lookahead[0]]
52
- warn "LA:<#{la}> last_state:#{st}"
53
- warn "LINE:<#{basis.line}>"
54
- warn dumpstack(stack) + "\n"
55
- end
56
- end
File without changes