racc 1.4.15-java → 1.4.16-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +22 -515
  3. data/Manifest.txt +3 -9
  4. data/README.ja.rdoc +3 -4
  5. data/README.rdoc +4 -4
  6. data/Rakefile +13 -55
  7. data/bin/racc +2 -4
  8. data/ext/racc/{cparse.c → cparse/cparse.c} +64 -31
  9. data/ext/racc/cparse/extconf.rb +8 -0
  10. data/lib/racc/cparse-jruby.jar +0 -0
  11. data/lib/racc/exception.rb +3 -5
  12. data/lib/racc/grammar.rb +5 -7
  13. data/lib/racc/grammarfileparser.rb +4 -3
  14. data/lib/racc/info.rb +4 -6
  15. data/lib/racc/iset.rb +2 -2
  16. data/lib/racc/logfilegenerator.rb +2 -2
  17. data/lib/racc/parser-text.rb +14 -11
  18. data/lib/racc/parser.rb +14 -11
  19. data/lib/racc/parserfilegenerator.rb +5 -7
  20. data/lib/racc/state.rb +11 -13
  21. data/test/assets/intp.y +4 -4
  22. data/test/assets/mailp.y +27 -27
  23. data/test/assets/mof.y +12 -12
  24. data/test/assets/nullbug2.y +2 -2
  25. data/test/assets/recv.y +20 -20
  26. data/test/assets/syntax.y +1 -1
  27. data/test/assets/twowaysql.y +1 -1
  28. data/test/helper.rb +65 -54
  29. data/test/regress/cadenza +60 -60
  30. data/test/regress/cast +8 -8
  31. data/test/regress/csspool +167 -167
  32. data/test/regress/edtf +115 -115
  33. data/test/regress/huia +75 -75
  34. data/test/regress/journey +12 -12
  35. data/test/regress/liquor +54 -54
  36. data/test/regress/machete +37 -37
  37. data/test/regress/mediacloth +83 -83
  38. data/test/regress/mof +60 -60
  39. data/test/regress/namae +29 -29
  40. data/test/regress/nasl +174 -174
  41. data/test/regress/nokogiri-css +59 -59
  42. data/test/regress/opal +352 -352
  43. data/test/regress/php_serialization +20 -20
  44. data/test/regress/riml +261 -261
  45. data/test/regress/ruby18 +353 -353
  46. data/test/regress/ruby22 +433 -433
  47. data/test/regress/tp_plus +125 -125
  48. data/test/regress/twowaysql +30 -30
  49. data/test/test_chk_y.rb +1 -0
  50. data/test/test_racc_command.rb +5 -24
  51. data/test/test_scan_y.rb +1 -0
  52. data/test/testscanner.rb +1 -1
  53. metadata +8 -75
  54. data/ext/racc/depend +0 -1
  55. data/ext/racc/extconf.rb +0 -7
  56. data/test/assets/bibtex.y +0 -141
  57. data/test/assets/rdblockparser.y +0 -576
  58. data/test/assets/rdinlineparser.y +0 -561
  59. data/test/regress/bibtex +0 -474
  60. data/test/regress/rdblockparser +0 -1061
  61. data/test/regress/rdinlineparser +0 -1243
@@ -35,7 +35,7 @@ rule
35
35
  @field.domain = mb.domain
36
36
  }
37
37
  ;
38
-
38
+
39
39
  datetime : day DIGIT ATOM DIGIT hour zone
40
40
  # 0 1 2 3 4 5
41
41
  # day month year
@@ -44,11 +44,11 @@ rule
44
44
  result = (t + val[4] - val[5]).localtime
45
45
  }
46
46
  ;
47
-
47
+
48
48
  day : /* none */
49
49
  | ATOM ','
50
50
  ;
51
-
51
+
52
52
  hour : DIGIT ':' DIGIT
53
53
  {
54
54
  result = (result.to_i * 60 * 60) + (val[2].to_i * 60)
@@ -60,16 +60,16 @@ rule
60
60
  + val[4].to_i
61
61
  }
62
62
  ;
63
-
63
+
64
64
  zone : ATOM
65
65
  {
66
66
  result = ::TMail.zonestr2i( val[0] ) * 60
67
67
  }
68
68
  ;
69
-
69
+
70
70
  received : from by via with id for recvdatetime
71
71
  ;
72
-
72
+
73
73
  from : /* none */
74
74
  | FROM domain
75
75
  {
@@ -84,28 +84,28 @@ rule
84
84
  @field.from = Address.join( val[1] )
85
85
  }
86
86
  ;
87
-
87
+
88
88
  by : /* none */
89
89
  | BY domain
90
90
  {
91
91
  @field.by = Address.join( val[1] )
92
92
  }
93
93
  ;
94
-
94
+
95
95
  via : /* none */
96
96
  | VIA ATOM
97
97
  {
98
98
  @field.via = val[1]
99
99
  }
100
100
  ;
101
-
101
+
102
102
  with : /* none */
103
103
  | WITH ATOM
104
104
  {
105
105
  @field.with.push val[1]
106
106
  }
107
107
  ;
108
-
108
+
109
109
  id : /* none */
110
110
  | ID msgid
111
111
  {
@@ -116,14 +116,14 @@ rule
116
116
  @field.msgid = val[1]
117
117
  }
118
118
  ;
119
-
119
+
120
120
  for : /* none */
121
121
  | FOR addr
122
122
  {
123
123
  @field.for_ = val[1].address
124
124
  }
125
125
  ;
126
-
126
+
127
127
  recvdatetime
128
128
  : /* none */
129
129
  | ';' datetime
@@ -131,7 +131,7 @@ rule
131
131
  @field.date = val[1]
132
132
  }
133
133
  ;
134
-
134
+
135
135
  returnpath: '<' '>'
136
136
  | routeaddr
137
137
  {
@@ -173,7 +173,7 @@ rule
173
173
  }
174
174
  # | phrase ':' ';' { result = AddressGroup.new( result ) }
175
175
  ;
176
-
176
+
177
177
  routeaddr : '<' route spec '>'
178
178
  {
179
179
  result = val[2]
@@ -184,22 +184,22 @@ rule
184
184
  result = val[1]
185
185
  }
186
186
  ;
187
-
187
+
188
188
  route : at_domains ':'
189
189
  ;
190
-
190
+
191
191
  at_domains: '@' domain { result = [ val[1] ] }
192
192
  | at_domains ',' '@' domain { result.push val[3] }
193
193
  ;
194
-
194
+
195
195
  spec : local '@' domain { result = Address.new( val[0], val[2] ) }
196
196
  | local { result = Address.new( result, nil ) }
197
197
  ;
198
-
198
+
199
199
  local : word { result = val }
200
200
  | local '.' word { result.push val[2] }
201
201
  ;
202
-
202
+
203
203
  domain : domword { result = val }
204
204
  | domain '.' domword { result.push val[2] }
205
205
  ;
@@ -215,11 +215,11 @@ rule
215
215
  result = val.join('')
216
216
  }
217
217
  ;
218
-
218
+
219
219
  phrase : word
220
220
  | phrase word { result << ' ' << val[1] }
221
221
  ;
222
-
222
+
223
223
  word : atom
224
224
  | QUOTED
225
225
  | DIGIT
@@ -228,7 +228,7 @@ rule
228
228
  keys : phrase
229
229
  | keys ',' phrase
230
230
  ;
231
-
231
+
232
232
  enc : word
233
233
  {
234
234
  @field.encrypter = val[0]
@@ -258,7 +258,7 @@ rule
258
258
  @field.sub = ''
259
259
  }
260
260
  ;
261
-
261
+
262
262
  params : /* none */
263
263
  | params ';' TOKEN '=' value
264
264
  {
@@ -281,7 +281,7 @@ rule
281
281
  @field.disposition = val[0]
282
282
  }
283
283
  ;
284
-
284
+
285
285
  disp_params
286
286
  : /* none */
287
287
  | disp_params ';' disp_param
@@ -293,7 +293,7 @@ rule
293
293
  @field.params[ val[0].downcase ] = val[2]
294
294
  }
295
295
  ;
296
-
296
+
297
297
  atom : ATOM
298
298
  | FROM
299
299
  | BY
@@ -302,7 +302,7 @@ rule
302
302
  | ID
303
303
  | FOR
304
304
  ;
305
-
305
+
306
306
  end
307
307
 
308
308
 
@@ -382,7 +382,7 @@ module TMail
382
382
  @scanner.scan @pass_array
383
383
  end
384
384
  end
385
-
385
+
386
386
  def on_error( tok, val, vstack )
387
387
  raise ParseError,
388
388
  "\nparse error in '#{@field.name}' header, on token #{val.inspect}"
@@ -33,7 +33,7 @@ class MOF::Parser
33
33
  octalValue
34
34
  decimalValue
35
35
  hexValue
36
-
36
+
37
37
  rule
38
38
 
39
39
  /* Returns a Hash of filename and MofResult */
@@ -47,7 +47,7 @@ rule
47
47
  result[@name] = @result
48
48
  }
49
49
  ;
50
-
50
+
51
51
  mofProduction
52
52
  : compilerDirective
53
53
  | classDeclaration
@@ -66,7 +66,7 @@ rule
66
66
  * compilerDirective
67
67
  *
68
68
  */
69
-
69
+
70
70
  compilerDirective
71
71
  : "#" PRAGMA INCLUDE pragmaParameters_opt
72
72
  { raise MOF::Helper::Error.new(@name,@lineno,@line,"Missing filename after '#pragma include'") unless val[3]
@@ -107,7 +107,7 @@ rule
107
107
  * classDeclaration
108
108
  *
109
109
  */
110
-
110
+
111
111
  classDeclaration
112
112
  : qualifierList_opt CLASS className alias_opt superClass_opt "{" classFeatures "}" ";"
113
113
  { qualifiers = val[0]
@@ -151,7 +151,7 @@ rule
151
151
  result << val[2] if val[2]
152
152
  }
153
153
  ;
154
-
154
+
155
155
  qualifier
156
156
  : qualifierName qualifierParameter_opt flavor_opt
157
157
  { # Get qualifier decl
@@ -242,7 +242,7 @@ rule
242
242
  result = CIM::Property.new(type,val[2],val[0],val[4])
243
243
  }
244
244
  ;
245
-
245
+
246
246
  referenceDeclaration
247
247
  : qualifierList_opt objectRef referenceName array_opt defaultValue_opt ";"
248
248
  { if val[4]
@@ -308,7 +308,7 @@ rule
308
308
  : /* empty */
309
309
  | parameterList
310
310
  ;
311
-
311
+
312
312
  parameterList
313
313
  : parameter parameters
314
314
  { result = val[1].unshift val[0] }
@@ -367,7 +367,7 @@ rule
367
367
  : /* empty */
368
368
  | defaultValue
369
369
  ;
370
-
370
+
371
371
  defaultValue
372
372
  : "=" initializer
373
373
  { result = val[1] }
@@ -416,7 +416,7 @@ rule
416
416
  | string stringValue
417
417
  { result = val[0] + val[1] }
418
418
  ;
419
-
419
+
420
420
  referenceInitializer
421
421
  : objectHandle
422
422
  | aliasIdentifier
@@ -465,7 +465,7 @@ rule
465
465
  * qualifierDeclaration
466
466
  *
467
467
  */
468
-
468
+
469
469
  qualifierDeclaration
470
470
  /* 0 1 2 3 4 */
471
471
  : QUALIFIER qualifierName qualifierType scope defaultFlavor_opt ";"
@@ -534,7 +534,7 @@ rule
534
534
  * instanceDeclaration
535
535
  *
536
536
  */
537
-
537
+
538
538
  instanceDeclaration
539
539
  : instance ";"
540
540
  ;
@@ -583,7 +583,7 @@ def initialize options = {}
583
583
  @includes = options[:includes] || []
584
584
  @quiet = options[:quiet]
585
585
  @style = options[:style] || :cim # default to style CIM v2.2 syntax
586
-
586
+
587
587
  @lineno = 1
588
588
  @file = nil
589
589
  @iconv = nil
@@ -6,10 +6,10 @@ class A
6
6
  rule
7
7
  targ: operation voidhead
8
8
  | variable
9
-
9
+
10
10
  voidhead : void B
11
11
  void:
12
-
12
+
13
13
  operation: A
14
14
  variable : A
15
15
  end
@@ -4,19 +4,19 @@ rule
4
4
 
5
5
  content: RecvH received
6
6
  ;
7
-
7
+
8
8
  datetime: day
9
9
  ;
10
-
10
+
11
11
  msgid: '<' spec '>';
12
-
12
+
13
13
  day:
14
14
  | ATOM ','
15
15
  ;
16
-
16
+
17
17
  received: recvitem_list recvdatetime
18
18
  ;
19
-
19
+
20
20
  recvitem_list:
21
21
  | recvitem_list recvitem
22
22
  ;
@@ -26,25 +26,25 @@ rule
26
26
  by:
27
27
  | BY domain
28
28
  ;
29
-
29
+
30
30
  via:
31
31
  | VIA ATOM
32
32
  ;
33
-
33
+
34
34
  with: WITH ATOM
35
35
  ;
36
-
36
+
37
37
  for:
38
38
  | FOR addr
39
39
  ;
40
-
40
+
41
41
  recvdatetime:
42
42
  | ';' datetime
43
43
  ;
44
-
44
+
45
45
  addr: mbox | group ;
46
46
 
47
- mboxes: mbox
47
+ mboxes: mbox
48
48
  | mboxes ',' mbox
49
49
  ;
50
50
 
@@ -59,21 +59,21 @@ rule
59
59
  routeaddr: '<' route spec '>'
60
60
  | '<' spec '>'
61
61
  ;
62
-
62
+
63
63
  route: at_domains ':' ;
64
-
65
- at_domains: '@' domain
64
+
65
+ at_domains: '@' domain
66
66
  | at_domains ',' '@' domain
67
67
  ;
68
-
68
+
69
69
  spec: local '@' domain
70
- | local
70
+ | local
71
71
  ;
72
-
72
+
73
73
  local: word
74
74
  | local '.' word
75
75
  ;
76
-
76
+
77
77
  domain: domword
78
78
  | domain '.' domword
79
79
  ;
@@ -86,12 +86,12 @@ rule
86
86
  phrase: word
87
87
  | phrase word
88
88
  ;
89
-
89
+
90
90
  word: atom
91
91
  | QUOTED
92
92
  | DIGIT
93
93
  ;
94
94
 
95
95
  atom: ATOM | FROM | BY | VIA | WITH | ID | FOR ;
96
-
96
+
97
97
  end
@@ -31,7 +31,7 @@ rule
31
31
  print 'cba'
32
32
  }
33
33
  | cont
34
-
34
+
35
35
  cont : A c2 B c2 C
36
36
 
37
37
  c2 : C C C C C
@@ -196,7 +196,7 @@ def parse( io )
196
196
 
197
197
  # @q.push [ false, nil ]
198
198
  @q.push [ false, [@s.pos, nil] ]
199
-
199
+
200
200
  ## call racc's private parse method
201
201
  do_parse
202
202
  end
@@ -1,56 +1,66 @@
1
+ verbose = $VERBOSE
1
2
  $VERBOSE = true
2
- require "minitest/autorun"
3
- require "racc/static"
4
- require "fileutils"
5
- require "tempfile"
6
- require "timeout"
3
+ begin
7
4
 
8
- module Racc
9
- class TestCase < MiniTest::Unit::TestCase
10
- PROJECT_DIR = File.expand_path(File.join(File.dirname(__FILE__), ".."))
5
+ require 'test/unit'
6
+ begin
7
+ require_relative './lib/core_assertions'
8
+ Test::Unit::TestCase.include Test::Unit::CoreAssertions
9
+ rescue LoadError
10
+ end
11
+ require 'racc/static'
12
+ require 'fileutils'
13
+ require 'tempfile'
14
+ require 'timeout'
11
15
 
12
- TEST_DIR = File.join(PROJECT_DIR, "test")
16
+ module Racc
17
+ class TestCase < Test::Unit::TestCase
18
+ PROJECT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
13
19
 
14
- RACC = File.join(PROJECT_DIR, "bin", "racc")
15
- OUT_DIR = File.join(TEST_DIR, "out")
16
- TAB_DIR = File.join(TEST_DIR, "tab") # generated parsers go here
17
- LOG_DIR = File.join(TEST_DIR, "log")
18
- ERR_DIR = File.join(TEST_DIR, "err")
19
- ASSET_DIR = File.join(TEST_DIR, "assets") # test grammars
20
- REGRESS_DIR = File.join(TEST_DIR, "regress") # known-good generated outputs
20
+ test_dir = File.join(PROJECT_DIR, 'test')
21
+ test_dir = File.join(PROJECT_DIR, 'racc') unless File.exist?(test_dir)
22
+ TEST_DIR = test_dir
23
+ racc = File.join(PROJECT_DIR, 'bin', 'racc')
24
+ racc = File.join(PROJECT_DIR, '..', 'libexec', 'racc') unless File.exist?(racc)
25
+ RACC = racc
26
+ ASSET_DIR = File.join(TEST_DIR, 'assets') # test grammars
27
+ REGRESS_DIR = File.join(TEST_DIR, 'regress') # known-good generated outputs
21
28
 
22
29
  INC = [
23
- File.join(PROJECT_DIR, "lib"),
24
- File.join(PROJECT_DIR, "ext"),
25
- ].join(":")
30
+ File.join(PROJECT_DIR, 'lib'),
31
+ File.join(PROJECT_DIR, 'ext'),
32
+ ].join(':')
26
33
 
27
34
  def setup
28
- [OUT_DIR, TAB_DIR, LOG_DIR, ERR_DIR].each do |dir|
29
- FileUtils.mkdir_p(dir)
30
- end
35
+ @TEMP_DIR = Dir.mktmpdir("racc")
36
+ @OUT_DIR = File.join(@TEMP_DIR, 'out')
37
+ @TAB_DIR = File.join(@TEMP_DIR, 'tab') # generated parsers go here
38
+ @LOG_DIR = File.join(@TEMP_DIR, 'log')
39
+ @ERR_DIR = File.join(@TEMP_DIR, 'err')
40
+ FileUtils.mkdir_p([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR])
41
+ FileUtils.cp File.join(TEST_DIR, "src.intp"), @TEMP_DIR
31
42
  end
32
43
 
33
44
  def teardown
34
- [OUT_DIR, TAB_DIR, LOG_DIR, ERR_DIR].each do |dir|
35
- FileUtils.rm_rf(dir)
36
- end
45
+ FileUtils.rm_f(File.join(@TEMP_DIR, "src.intp"))
46
+ FileUtils.rm_rf([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR, @TEMP_DIR])
37
47
  end
38
48
 
39
- def assert_compile(asset, args = [])
40
- file = File.basename(asset, ".y")
49
+ def assert_compile(asset, args = [], **opt)
50
+ file = File.basename(asset, '.y')
41
51
  args = ([args].flatten) + [
42
52
  "#{ASSET_DIR}/#{file}.y",
43
- "-Do",
44
- "-O#{OUT_DIR}/#{file}",
45
- "-o#{TAB_DIR}/#{file}",
53
+ '-Do',
54
+ "-O#{@OUT_DIR}/#{file}",
55
+ "-o#{@TAB_DIR}/#{file}",
46
56
  ]
47
- racc "#{args.join(" ")}"
57
+ racc(*args, **opt)
48
58
  end
49
59
 
50
60
  def assert_debugfile(asset, ok)
51
- file = File.basename(asset, ".y")
52
- Dir.chdir(TEST_DIR) do
53
- File.foreach("log/#{file}.y") do |line|
61
+ file = File.basename(asset, '.y')
62
+ Dir.chdir(@LOG_DIR) do
63
+ File.foreach("#{file}.y") do |line|
54
64
  line.strip!
55
65
  case line
56
66
  when /sr/ then assert_equal "sr#{ok[0]}", line
@@ -59,46 +69,47 @@ module Racc
59
69
  when /ur/ then assert_equal "ur#{ok[3]}", line
60
70
  when /ex/ then assert_equal "ex#{ok[4]}", line
61
71
  else
62
- raise TestFailed, "racc outputs unknown debug report???"
72
+ raise TestFailed, 'racc outputs unknown debug report???'
63
73
  end
64
74
  end
65
75
  end
66
76
  end
67
77
 
68
78
  def assert_exec(asset)
69
- file = File.basename(asset, ".y")
70
- Dir.chdir(TEST_DIR) do
71
- ruby("#{TAB_DIR}/#{file}")
72
- end
79
+ lib_path = File.expand_path("../../lib", __FILE__)
80
+ file = File.basename(asset, '.y')
81
+ ruby "-I#{lib_path}", "#{@TAB_DIR}/#{file}"
73
82
  end
74
83
 
75
84
  def strip_version(source)
76
- source.sub(/This file is automatically generated by Racc \d+\.\d+\.\d+/, "")
85
+ source.sub(/This file is automatically generated by Racc \d+\.\d+\.\d+/, '')
77
86
  end
78
87
 
79
88
  def assert_output_unchanged(asset)
80
- file = File.basename(asset, ".y")
89
+ # racc generates the difference results in GitHub Actions
90
+ omit unless RUBY_PLATFORM =~ /darwin/
91
+
92
+ file = File.basename(asset, '.y')
81
93
 
82
94
  expected = File.read("#{REGRESS_DIR}/#{file}")
83
- actual = File.read("#{TAB_DIR}/#{file}")
84
- result = (strip_version(expected) == strip_version(actual))
95
+ actual = File.read("#{@TAB_DIR}/#{file}")
96
+ result = (strip_version(expected) == strip_version(actual))
85
97
 
86
98
  assert(result, "Output of test/assets/#{file}.y differed from " \
87
- "expectation. Try compiling it and diff with test/regress/#{file}.")
99
+ "expectation. Try compiling it and diff with test/regress/#{file}.")
88
100
  end
89
101
 
90
- def racc(arg)
91
- ruby "-S #{RACC} #{arg}"
102
+ def racc(*arg, **opt)
103
+ lib_path = File.expand_path("../../lib", __FILE__)
104
+ ruby "-I#{lib_path}", "-S", RACC, *arg, **opt
92
105
  end
93
106
 
94
- def ruby(arg)
95
- Dir.chdir(TEST_DIR) do
96
- Tempfile.open "test" do |io|
97
- cmd = "#{ENV["_"] || Gem.ruby} -I #{INC} #{arg} 2>#{io.path}"
98
- result = system(cmd)
99
- assert(result, io.read)
100
- end
101
- end
107
+ def ruby(*arg, **opt)
108
+ assert_ruby_status(["-C", @TEMP_DIR, *arg], **opt)
102
109
  end
103
110
  end
104
111
  end
112
+
113
+ ensure
114
+ $VERBOSE = verbose
115
+ end