From 50eb4b2842814299577641a762199498bd4b10d4 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 00:24:18 +0200 Subject: [PATCH 01/19] Rename "README.txt" to "README.md". --- README.txt => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.txt => README.md (100%) diff --git a/README.txt b/README.md similarity index 100% rename from README.txt rename to README.md From d98f69dcb5796ca9334c83c8f4d96581dc960a4e Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 00:28:45 +0200 Subject: [PATCH 02/19] Use public 'bitescript' gem. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 41aa74a..178c196 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org/" -gem 'bitescript', '>= 0.1.2', :path => '../bitescript' +gem 'bitescript', '>= 0.1.2' gem 'mirah', '>= 0.1', :path => '../mirah' gem 'rake' \ No newline at end of file From eb9db0f4412bab630a7b1a75dab95f776f983d71 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 00:50:15 +0200 Subject: [PATCH 03/19] Work around mirahc compiler bug. --- mmeta/ast.mirah | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmeta/ast.mirah b/mmeta/ast.mirah index 9d5c319..cfae142 100644 --- a/mmeta/ast.mirah +++ b/mmeta/ast.mirah @@ -107,7 +107,7 @@ class Ast < AbstractList; implements Cloneable @children.add(index - 1, child) end - def remove(index:int) + def remove(index:int):void # aid compiler in determining the return type. FIXME: Aiding the compiler should not be necessary here. if index == 0 raise IllegalArgumentException, "Can't remove child #{index}." end From 919c3deb155216906f72b2e43acfe4253130133f Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 02:06:05 +0200 Subject: [PATCH 04/19] Rename MMetaCompiler#Token to MMetaCompiler#AToken, as MMetaCompiler.Token resolves to BaseParser$Token, and this creates a conflict. --- boot/compiler.mirah | 8 ++++---- boot/compiler.mmeta | 2 +- boot/parser.mmeta | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/boot/compiler.mirah b/boot/compiler.mirah index 4735363..5737c09 100644 --- a/boot/compiler.mirah +++ b/boot/compiler.mirah @@ -779,7 +779,7 @@ class MMetaCompiler < BaseParser - def Token + def AToken #throws RuleFailure begin _start = _pos; name = nil @@ -796,7 +796,7 @@ class MMetaCompiler < BaseParser end end rescue RuleFailure => ex - ex.last = 'Token' + ex.last = 'AToken' raise ex end end @@ -1736,7 +1736,7 @@ class MMetaCompiler < BaseParser return Act() if (r == "Act") return Pred() if (r == "Pred") return SynPred() if (r == "SynPred") - return Token() if (r == "Token") + return AToken() if (r == "AToken") return TokenRange() if (r == "TokenRange") return TLit() if (r == "TLit") return Or() if (r == "Or") @@ -1778,7 +1778,7 @@ class MMetaCompiler < BaseParser return true if (r == "Act") return true if (r == "Pred") return true if (r == "SynPred") - return true if (r == "Token") + return true if (r == "AToken") return true if (r == "TokenRange") return true if (r == "TLit") return true if (r == "Or") diff --git a/boot/compiler.mmeta b/boot/compiler.mmeta index d44900e..a13b8a4 100644 --- a/boot/compiler.mmeta +++ b/boot/compiler.mmeta @@ -195,7 +195,7 @@ public parser MMetaCompiler { render('syn_pred') }; - Token: name=_ { + AToken: name=_ { "_lex(Tokens.t#{name})" }; TokenRange: first=_ last=_ { diff --git a/boot/parser.mmeta b/boot/parser.mmeta index f55eb69..7ed004f 100644 --- a/boot/parser.mmeta +++ b/boot/parser.mmeta @@ -80,7 +80,7 @@ public parser MMetaParser { synPredTail : ."|" (synPred | expr4); token : "$" n=name { n }; tokens : a=token (.".." . b=token { [:TokenRange, a, b]} - | { [:Token, a]} + | { [:AToken, a]} ); expr : xs=listOf(:expr4,"|") { [:Or] + xs } ; From 64bda36c594bd12212f657b95cfee29e03369a74 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 02:22:37 +0200 Subject: [PATCH 05/19] Do not emit "throws" statements. They seem to be removed from the Mirah language. --- boot/templates/parser.xtm | 2 +- boot/templates/rule.xtm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boot/templates/parser.xtm b/boot/templates/parser.xtm index d3a36cb..ced2210 100644 --- a/boot/templates/parser.xtm +++ b/boot/templates/parser.xtm @@ -8,7 +8,7 @@ class {{PARSER}} < {{SUPERCLASS}} end def _error(expected:String) - throws RuleFailure + #throws RuleFailure @error.last = expected unless ''.equals(expected) raise @error end diff --git a/boot/templates/rule.xtm b/boot/templates/rule.xtm index aaec751..1d59087 100644 --- a/boot/templates/rule.xtm +++ b/boot/templates/rule.xtm @@ -1,6 +1,6 @@ def {{RULE}}{{ARGS}}{{#CAST}}:{{CAST}}{{/CAST}} - throws RuleFailure{{#DEBUG}} + #throws RuleFailure{{#DEBUG}} _enter('{{RULE}}'){{/DEBUG}}{{#SCOPE_VARS}} __saved_{{SIMPLE_NAME}} = {{NAME}}{{/SCOPE_VARS}} begin From 1f683f6c8e58a8c03e050e6af5307664e40cce14 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:02:13 +0200 Subject: [PATCH 06/19] Emit "package" statement if a jpackage has been available. --- boot/compiler.mmeta | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boot/compiler.mmeta b/boot/compiler.mmeta index a13b8a4..6807820 100644 --- a/boot/compiler.mmeta +++ b/boot/compiler.mmeta @@ -376,6 +376,9 @@ public parser MMetaCompiler { File: xs=trans* { "# generated by mmeta on #{Date.new}\n" + "# do not modify, instead edit original .mmeta file\n" + + "\n" + + "#{@jpackage ? @jpackage : ""}\n" + + "\n" + "import java.util.ArrayList\n" + "import java.util.Date\n" + "import java.util.List\n" + From fa534b09a68b942f22bd823a3982b38c22b2e717 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:02:36 +0200 Subject: [PATCH 07/19] Set JPACKAGE variable. --- boot/compiler.mmeta | 1 + 1 file changed, 1 insertion(+) diff --git a/boot/compiler.mmeta b/boot/compiler.mmeta index 6807820..5d8dbde 100644 --- a/boot/compiler.mmeta +++ b/boot/compiler.mmeta @@ -349,6 +349,7 @@ public parser MMetaCompiler { end @dict.setVariable(:PARSER, @name) @dict.setVariable(:SUPERCLASS, @sname) + @dict.setVariable(:JPACKAGE, @jpackage) List(xs).each do |expr| @dict = dict.addSection(:BODY) add_expr(:BODY, expr) From 6b4335afcb79c4eed1d36c3b467c4301d6d56907 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:44:39 +0200 Subject: [PATCH 08/19] Update bootstrap. --- boot/compiler.mirah | 4 ++++ boot/parser.mirah | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/boot/compiler.mirah b/boot/compiler.mirah index 5737c09..db24a99 100644 --- a/boot/compiler.mirah +++ b/boot/compiler.mirah @@ -1295,6 +1295,7 @@ class MMetaCompiler < BaseParser end @dict.setVariable(:PARSER, @name) @dict.setVariable(:SUPERCLASS, @sname) + @dict.setVariable(:JPACKAGE, @jpackage) List(xs).each do |expr| @dict = dict.addSection(:BODY) add_expr(:BODY, expr) @@ -1532,6 +1533,9 @@ class MMetaCompiler < BaseParser "# generated by mmeta on #{Date.new}\n" + "# do not modify, instead edit original .mmeta file\n" + + "\n" + + "#{@jpackage ? @jpackage : ""}\n" + + "\n" + "import java.util.ArrayList\n" + "import java.util.Date\n" + "import java.util.List\n" + diff --git a/boot/parser.mirah b/boot/parser.mirah index 9b23c3b..34520b8 100644 --- a/boot/parser.mirah +++ b/boot/parser.mirah @@ -46,8 +46,8 @@ class MMetaParser < BaseParser as1 = ArrayList.new begin while true do - - _lj= begin + _li = Object( + begin _p0 = _pos begin begin # not @@ -64,7 +64,7 @@ class MMetaParser < BaseParser raise ex end end - _li = Object(_lj) + ) as1.add(_li) end rescue RuleFailure; end @@ -2411,7 +2411,7 @@ class MMetaParser < BaseParser end end rescue RuleFailure - ["Token", a] + ["AToken", a] end rescue RuleFailure => ex self._pos = _p142 From c01b71eaa0e72ba81a1465f4f5c812d94663f394 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:04:47 +0200 Subject: [PATCH 09/19] Compile from the correct test directory. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index e942cfc..91a6812 100644 --- a/Rakefile +++ b/Rakefile @@ -67,7 +67,7 @@ namespace :test do ant.javac :srcDir => 'build/test', :classpath => 'dist/mmeta-runtime.jar', :debug => true - mirahc 'test', + mirahc 'build/test', :dir=>'build', :dest=>'build', :options=>[ From fd0d1904e25023837e19b471f63de6a99234fb83 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:21:57 +0200 Subject: [PATCH 10/19] Support for methods with return types. --- boot/compiler.mmeta | 3 ++- boot/parser.mmeta | 4 ++-- boot/templates/method.xtm | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/boot/compiler.mmeta b/boot/compiler.mmeta index 5d8dbde..c50a58f 100644 --- a/boot/compiler.mmeta +++ b/boot/compiler.mmeta @@ -359,10 +359,11 @@ public parser MMetaCompiler { b }; - Method: name=_ args=_ body=_ ismacro=_ { + Method: name=_ args=_ returntypeopt=_ body=_ ismacro=_ { add_dict @dict.setVariable(:NAME, name.toString) @dict.setVariable(:ARGS, args.toString) + @dict.setVariable(:RETURNTYPEOPT, returntypeopt.toString) @dict.showSection(:MACRO) if ismacro add_expr(:BODY, body) render('method') diff --git a/boot/parser.mmeta b/boot/parser.mmeta index 7ed004f..0ef2bb5 100644 --- a/boot/parser.mmeta +++ b/boot/parser.mmeta @@ -115,9 +115,9 @@ public parser MMetaParser { { join(qs, " ") } ; - method : m=(k("macro").)? k("def") . s=("self." | {""})! n=name! (."(" as=(~")" _)* ")"| {""})! ."{" bs=cbraces* "}" + method : m=(k("macro").)? k("def") . s=("self." | {""})! n=name! (."(" as=(~")" _)* ")" (returntypeopt=(":" name))?| {""})! ."{" bs=cbraces* "}" { - ["Method", "#{s}#{n}", "#{join(as)}", "#{join(bs)}", m] + ["Method", "#{s}#{n}", "#{join(as)}", "#{returntypeopt ? ":#{returntypeopt}" : ""}", "#{join(bs)}", m] } ; jimport : stm=k("import") ! xs=(~oneOf(";\n") _)* ";"? diff --git a/boot/templates/method.xtm b/boot/templates/method.xtm index 4844b28..86bd2e4 100644 --- a/boot/templates/method.xtm +++ b/boot/templates/method.xtm @@ -1,3 +1,3 @@ -{{#MACRO}}macro {{/MACRO}}def {{NAME}}({{ARGS}}) +{{#MACRO}}macro {{/MACRO}}def {{NAME}}({{ARGS}}){{RETURNTYPEOPT}} {{>BODY}} end From 65487015e48d3625b0ec7fd35ab4955b4891effa Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:47:28 +0200 Subject: [PATCH 11/19] Update bootstrap. --- boot/compiler.mirah | 8 +- boot/parser.mirah | 307 ++++++++++++++++++++++++-------------------- 2 files changed, 178 insertions(+), 137 deletions(-) diff --git a/boot/compiler.mirah b/boot/compiler.mirah index db24a99..fe5535e 100644 --- a/boot/compiler.mirah +++ b/boot/compiler.mirah @@ -1,6 +1,8 @@ # generated by mmeta on Mon May 23 17:32:45 PDT 2011 # do not modify, instead edit original .mmeta file + package mmeta + import java.util.ArrayList import java.util.Date import java.util.List @@ -1321,7 +1323,7 @@ class MMetaCompiler < BaseParser def Method #throws RuleFailure begin - _start = _pos; name = nil; args = nil; body = nil; ismacro = nil; c = nil + _start = _pos; name = nil; args = nil; returntypeopt = nil; body = nil; ismacro = nil; c = nil begin begin _p39 = _pos @@ -1332,6 +1334,9 @@ class MMetaCompiler < BaseParser args = ( self._any() ) + returntypeopt = ( + self._any() + ) body = ( self._any() ) @@ -1343,6 +1348,7 @@ class MMetaCompiler < BaseParser add_dict @dict.setVariable(:NAME, name.toString) @dict.setVariable(:ARGS, args.toString) + @dict.setVariable(:RETURNTYPEOPT, returntypeopt.toString) @dict.showSection(:MACRO) if ismacro add_expr(:BODY, body) render('method') diff --git a/boot/parser.mirah b/boot/parser.mirah index 34520b8..d6e7cef 100644 --- a/boot/parser.mirah +++ b/boot/parser.mirah @@ -1,6 +1,8 @@ # generated by mmeta on Mon May 23 17:32:44 PDT 2011 # do not modify, instead edit original .mmeta file + package mmeta + import java.util.ArrayList import java.util.Date import java.util.List @@ -3379,13 +3381,13 @@ class MMetaParser < BaseParser def method #throws RuleFailure begin - _start = _pos; m = nil; s = nil; n = nil; as = nil; bs = nil + _start = _pos; m = nil; s = nil; n = nil; as = nil; returntypeopt = nil; bs = nil _t = _sretrieve("MMetaParser.method") return _t unless _t == BaseParser.NOT_MEMOIZED begin _t2 = ( begin - _p219 = _pos + _p222 = _pos begin m = ( begin # optional @@ -3419,18 +3421,18 @@ class MMetaParser < BaseParser ) begin begin - _p218 = _pos + _p221 = _pos begin n = ( self.name() ) begin begin - _p217 = _pos + _p220 = _pos begin begin begin - _p212 = _pos + _p215 = _pos begin ws() if _string.startsWith("(", _pos) @@ -3480,8 +3482,37 @@ class MMetaParser < BaseParser else raise @error end + begin # optional + begin + _p214 = _pos + begin + returntypeopt = ( + begin + _p213 = _pos + begin + if _string.startsWith(":", _pos) + self._pos += 1 + ":" + else + raise @error + end + self.name() + rescue RuleFailure => ex + self._pos = _p213 + raise ex + end + end + ) + rescue RuleFailure => ex + self._pos = _p214 + raise ex + end + end + rescue RuleFailure + nil + end rescue RuleFailure => ex - self._pos = _p212 + self._pos = _p215 raise ex end end @@ -3490,7 +3521,7 @@ class MMetaParser < BaseParser end begin begin - _p216 = _pos + _p219 = _pos begin ws() if _string.startsWith("{", _pos) @@ -3501,16 +3532,16 @@ class MMetaParser < BaseParser end bs = ( begin - as214 = ArrayList.new + as217 = ArrayList.new begin while true do _li = Object( self.cbraces() ) - as214.add(_li) + as217.add(_li) end rescue RuleFailure; end - as214 + as217 end ) if _string.startsWith("}", _pos) @@ -3519,9 +3550,13 @@ class MMetaParser < BaseParser else raise @error end - ["Method", "#{s}#{n}", "#{join(as)}", "#{join(bs)}", m] + begin + + ["Method", "#{s}#{n}", "#{join(as)}", "#{returntypeopt ? ":#{returntypeopt}" : ""}", "#{join(bs)}", m] + + end rescue RuleFailure => ex - self._pos = _p216 + self._pos = _p219 raise ex end end @@ -3529,7 +3564,7 @@ class MMetaParser < BaseParser raise SyntaxError.new("", @error.last, _pos, _string, _list) end rescue RuleFailure => ex - self._pos = _p217 + self._pos = _p220 raise ex end end @@ -3537,7 +3572,7 @@ class MMetaParser < BaseParser raise SyntaxError.new("", @error.last, _pos, _string, _list) end rescue RuleFailure => ex - self._pos = _p218 + self._pos = _p221 raise ex end end @@ -3545,7 +3580,7 @@ class MMetaParser < BaseParser raise SyntaxError.new("", @error.last, _pos, _string, _list) end rescue RuleFailure => ex - self._pos = _p219 + self._pos = _p222 raise ex end end @@ -3573,23 +3608,23 @@ class MMetaParser < BaseParser begin _t2 = ( begin - _p224 = _pos + _p227 = _pos begin stm = ( self.k("import") ) begin begin - _p223 = _pos + _p226 = _pos begin xs = ( begin - as221 = ArrayList.new + as224 = ArrayList.new begin while true do _li = Object( begin - _p220 = _pos + _p223 = _pos begin begin # not self.oneOf(";\n") @@ -3601,15 +3636,15 @@ class MMetaParser < BaseParser end self._any() rescue RuleFailure => ex - self._pos = _p220 + self._pos = _p223 raise ex end end ) - as221.add(_li) + as224.add(_li) end rescue RuleFailure; end - as221 + as224 end ) begin # optional @@ -3624,7 +3659,7 @@ class MMetaParser < BaseParser end ["Import", "#{stm}#{join(xs)}"] rescue RuleFailure => ex - self._pos = _p223 + self._pos = _p226 raise ex end end @@ -3632,7 +3667,7 @@ class MMetaParser < BaseParser raise SyntaxError.new("", @error.last, _pos, _string, _list) end rescue RuleFailure => ex - self._pos = _p224 + self._pos = _p227 raise ex end end @@ -3660,23 +3695,23 @@ class MMetaParser < BaseParser begin _t2 = ( begin - _p229 = _pos + _p232 = _pos begin stm = ( self.k("package") ) begin begin - _p228 = _pos + _p231 = _pos begin xs = ( begin - as226 = ArrayList.new + as229 = ArrayList.new begin while true do _li = Object( begin - _p225 = _pos + _p228 = _pos begin begin # not self.oneOf(";\n") @@ -3688,15 +3723,15 @@ class MMetaParser < BaseParser end self._any() rescue RuleFailure => ex - self._pos = _p225 + self._pos = _p228 raise ex end end ) - as226.add(_li) + as229.add(_li) end rescue RuleFailure; end - as226 + as229 end ) begin # optional @@ -3711,7 +3746,7 @@ class MMetaParser < BaseParser end ["Package", "#{stm}#{join(xs)}"] rescue RuleFailure => ex - self._pos = _p228 + self._pos = _p231 raise ex end end @@ -3719,7 +3754,7 @@ class MMetaParser < BaseParser raise SyntaxError.new("", @error.last, _pos, _string, _list) end rescue RuleFailure => ex - self._pos = _p229 + self._pos = _p232 raise ex end end @@ -3747,7 +3782,7 @@ class MMetaParser < BaseParser begin _t2 = ( begin - _p237 = _pos + _p240 = _pos begin q = ( self.qualifiers() @@ -3756,16 +3791,16 @@ class MMetaParser < BaseParser self.k("class") begin begin - _p236 = _pos + _p239 = _pos begin xs = ( begin - as232 = ArrayList.new + as235 = ArrayList.new begin while true do _li = Object( begin - _p231 = _pos + _p234 = _pos begin begin # not if _string.startsWith("{", _pos) @@ -3782,15 +3817,15 @@ class MMetaParser < BaseParser end self._any() rescue RuleFailure => ex - self._pos = _p231 + self._pos = _p234 raise ex end end ) - as232.add(_li) + as235.add(_li) end rescue RuleFailure; end - as232 + as235 end ) if _string.startsWith("{", _pos) @@ -3801,16 +3836,16 @@ class MMetaParser < BaseParser end bs = ( begin - as234 = ArrayList.new + as237 = ArrayList.new begin while true do _li = Object( self.cbraces() ) - as234.add(_li) + as237.add(_li) end rescue RuleFailure; end - as234 + as237 end ) if _string.startsWith("}", _pos) @@ -3821,7 +3856,7 @@ class MMetaParser < BaseParser end ["Class", q, " class #{join(xs)}", "#{join(bs)}"] rescue RuleFailure => ex - self._pos = _p236 + self._pos = _p239 raise ex end end @@ -3829,7 +3864,7 @@ class MMetaParser < BaseParser raise SyntaxError.new("", @error.last, _pos, _string, _list) end rescue RuleFailure => ex - self._pos = _p237 + self._pos = _p240 raise ex end end @@ -3858,23 +3893,23 @@ class MMetaParser < BaseParser _t2 = ( begin begin - _p238 = _pos + _p241 = _pos begin ws() self.method() rescue RuleFailure => ex - self._pos = _p238 + self._pos = _p241 raise ex end end rescue RuleFailure begin - _p239 = _pos + _p242 = _pos begin ws() self.rule() rescue RuleFailure => ex - self._pos = _p239 + self._pos = _p242 raise ex end end @@ -3903,7 +3938,7 @@ class MMetaParser < BaseParser begin _t2 = ( begin - _p248 = _pos + _p251 = _pos begin ws() m = ( @@ -3917,7 +3952,7 @@ class MMetaParser < BaseParser self.k("parser") begin begin - _p247 = _pos + _p250 = _pos begin ws() n = ( @@ -3927,13 +3962,13 @@ class MMetaParser < BaseParser sn = ( begin begin - _p242 = _pos + _p245 = _pos begin begin self.k("extends") rescue RuleFailure begin - _p241 = _pos + _p244 = _pos begin ws() if _string.startsWith("<", _pos) @@ -3943,7 +3978,7 @@ class MMetaParser < BaseParser raise @error end rescue RuleFailure => ex - self._pos = _p241 + self._pos = _p244 raise ex end end @@ -3951,18 +3986,18 @@ class MMetaParser < BaseParser ws() self.name() rescue RuleFailure => ex - self._pos = _p242 + self._pos = _p245 raise ex end end rescue RuleFailure begin - _p243 = _pos + _p246 = _pos begin self.empty() "BaseParser" rescue RuleFailure => ex - self._pos = _p243 + self._pos = _p246 raise ex end end @@ -3977,16 +4012,16 @@ class MMetaParser < BaseParser end rs = ( begin - as245 = ArrayList.new + as248 = ArrayList.new begin while true do _li = Object( self.ruleMethod() ) - as245.add(_li) + as248.add(_li) end rescue RuleFailure; end - as245 + as248 end ) ws() @@ -4012,7 +4047,7 @@ class MMetaParser < BaseParser raise SyntaxError.new("", @error.last, _pos, _string, _list) end rescue RuleFailure => ex - self._pos = _p247 + self._pos = _p250 raise ex end end @@ -4020,7 +4055,7 @@ class MMetaParser < BaseParser raise SyntaxError.new("", @error.last, _pos, _string, _list) end rescue RuleFailure => ex - self._pos = _p248 + self._pos = _p251 raise ex end end @@ -4048,7 +4083,7 @@ class MMetaParser < BaseParser begin _t2 = ( begin - _p249 = _pos + _p252 = _pos begin p = ( ws() @@ -4070,7 +4105,7 @@ class MMetaParser < BaseParser ) ["Line", "#{join(p)}", l] rescue RuleFailure => ex - self._pos = _p249 + self._pos = _p252 raise ex end end @@ -4099,27 +4134,27 @@ class MMetaParser < BaseParser _t2 = ( begin begin - _p251 = _pos + _p254 = _pos begin ls = ( begin - as250 = ArrayList.new + as253 = ArrayList.new begin while true do _li = Object( self.line() ) - as250.add(_li) + as253.add(_li) end rescue RuleFailure; end - as250 + as253 end ) ws() self.end() concat(["File"], ls) rescue RuleFailure => ex - self._pos = _p251 + self._pos = _p254 raise ex end end @@ -4349,7 +4384,7 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p253 = _pos + _p256 = _pos begin r = ( self._any() @@ -4357,7 +4392,7 @@ class MMetaPass < BaseParser raise @error unless ( hasRule(r) ) begin begin - _p252 = _pos + _p255 = _pos begin x = ( self.apply(r) @@ -4365,7 +4400,7 @@ class MMetaPass < BaseParser self.end() x rescue RuleFailure => ex - self._pos = _p252 + self._pos = _p255 raise ex end end @@ -4373,7 +4408,7 @@ class MMetaPass < BaseParser raise SyntaxError.new("", @error.last, _pos, _string, _list) end rescue RuleFailure => ex - self._pos = _p253 + self._pos = _p256 raise ex end end @@ -4402,7 +4437,7 @@ class MMetaPass < BaseParser _t2 = ( begin begin - _p254 = _pos + _p257 = _pos begin begin _t = _listBegin() @@ -4416,7 +4451,7 @@ class MMetaPass < BaseParser end x rescue RuleFailure => ex - self._pos = _p254 + self._pos = _p257 raise ex end end @@ -4447,25 +4482,25 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p256 = _pos + _p259 = _pos begin xs = ( begin - as255 = ArrayList.new + as258 = ArrayList.new begin while true do _li = Object( self.trans() ) - as255.add(_li) + as258.add(_li) end rescue RuleFailure; end - as255 + as258 end ) concat(["Or"], xs) rescue RuleFailure => ex - self._pos = _p256 + self._pos = _p259 raise ex end end @@ -4493,25 +4528,25 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p258 = _pos + _p261 = _pos begin xs = ( begin - as257 = ArrayList.new + as260 = ArrayList.new begin while true do _li = Object( self.trans() ) - as257.add(_li) + as260.add(_li) end rescue RuleFailure; end - as257 + as260 end ) concat(["And"], xs) rescue RuleFailure => ex - self._pos = _p258 + self._pos = _p261 raise ex end end @@ -4539,14 +4574,14 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p259 = _pos + _p262 = _pos begin x = ( self.trans() ) ["Not", x] rescue RuleFailure => ex - self._pos = _p259 + self._pos = _p262 raise ex end end @@ -4574,14 +4609,14 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p260 = _pos + _p263 = _pos begin x = ( self.trans() ) ["Many", x] rescue RuleFailure => ex - self._pos = _p260 + self._pos = _p263 raise ex end end @@ -4609,14 +4644,14 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p261 = _pos + _p264 = _pos begin x = ( self.trans() ) ["Many1", x] rescue RuleFailure => ex - self._pos = _p261 + self._pos = _p264 raise ex end end @@ -4644,14 +4679,14 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p262 = _pos + _p265 = _pos begin x = ( self.trans() ) ["Peek", x] rescue RuleFailure => ex - self._pos = _p262 + self._pos = _p265 raise ex end end @@ -4679,14 +4714,14 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p263 = _pos + _p266 = _pos begin x = ( self.trans() ) ["List", x] rescue RuleFailure => ex - self._pos = _p263 + self._pos = _p266 raise ex end end @@ -4714,7 +4749,7 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p264 = _pos + _p267 = _pos begin n = ( self._any() @@ -4724,7 +4759,7 @@ class MMetaPass < BaseParser ) ["Set", n, x] rescue RuleFailure => ex - self._pos = _p264 + self._pos = _p267 raise ex end end @@ -4752,7 +4787,7 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p265 = _pos + _p268 = _pos begin n = ( self._any() @@ -4768,7 +4803,7 @@ class MMetaPass < BaseParser ) ["Rule", n, args, x, anno] rescue RuleFailure => ex - self._pos = _p265 + self._pos = _p268 raise ex end end @@ -4796,25 +4831,25 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p267 = _pos + _p270 = _pos begin xs = ( begin - as266 = ArrayList.new + as269 = ArrayList.new begin while true do _li = Object( self.trans() ) - as266.add(_li) + as269.add(_li) end rescue RuleFailure; end - as266 + as269 end ) concat(["SynPred"], xs) rescue RuleFailure => ex - self._pos = _p267 + self._pos = _p270 raise ex end end @@ -4842,7 +4877,7 @@ class MMetaPass < BaseParser begin _t2 = ( begin - _p268 = _pos + _p271 = _pos begin m = ( self._any() @@ -4852,7 +4887,7 @@ class MMetaPass < BaseParser ) ["Error", m, x] rescue RuleFailure => ex - self._pos = _p268 + self._pos = _p271 raise ex end end @@ -4881,7 +4916,7 @@ class MMetaPass < BaseParser _t2 = ( begin begin - _p269 = _pos + _p272 = _pos begin r = ( self.destruct() @@ -4889,14 +4924,14 @@ class MMetaPass < BaseParser self.end() r rescue RuleFailure => ex - self._pos = _p269 + self._pos = _p272 raise ex end end rescue RuleFailure begin begin - _p270 = _pos + _p273 = _pos begin r = ( self._any() @@ -4904,32 +4939,32 @@ class MMetaPass < BaseParser self.end() r rescue RuleFailure => ex - self._pos = _p270 + self._pos = _p273 raise ex end end rescue RuleFailure begin - _p272 = _pos + _p275 = _pos begin r = ( begin - as271 = ArrayList.new + as274 = ArrayList.new begin while true do _li = Object( self._any() ) - as271.add(_li) + as274.add(_li) end rescue RuleFailure; end - as271 + as274 end ) self.end() r rescue RuleFailure => ex - self._pos = _p272 + self._pos = _p275 raise ex end end @@ -5016,7 +5051,7 @@ class MMetaAndOrOpt < MMetaPass _t2 = ( begin begin - _p273 = _pos + _p276 = _pos begin x = ( self.trans() @@ -5025,13 +5060,13 @@ class MMetaAndOrOpt < MMetaPass self.setChanged() x rescue RuleFailure => ex - self._pos = _p273 + self._pos = _p276 raise ex end end rescue RuleFailure begin - _p274 = _pos + _p277 = _pos begin xs = ( self.transInside("And") @@ -5039,7 +5074,7 @@ class MMetaAndOrOpt < MMetaPass self.end() concat(["And"], xs) rescue RuleFailure => ex - self._pos = _p274 + self._pos = _p277 raise ex end end @@ -5069,7 +5104,7 @@ class MMetaAndOrOpt < MMetaPass _t2 = ( begin begin - _p275 = _pos + _p278 = _pos begin x = ( self.trans() @@ -5078,13 +5113,13 @@ class MMetaAndOrOpt < MMetaPass self.setChanged() x rescue RuleFailure => ex - self._pos = _p275 + self._pos = _p278 raise ex end end rescue RuleFailure begin - _p276 = _pos + _p279 = _pos begin xs = ( self.transInside("Or") @@ -5092,7 +5127,7 @@ class MMetaAndOrOpt < MMetaPass self.end() concat(["Or"], xs) rescue RuleFailure => ex - self._pos = _p276 + self._pos = _p279 raise ex end end @@ -5118,20 +5153,20 @@ class MMetaAndOrOpt < MMetaPass _start = _pos; xs = nil; ys = nil; x = nil begin begin - _p278 = _pos + _p281 = _pos begin begin _t = _listBegin() begin begin - _p277 = _pos + _p280 = _pos begin self.sym(s) xs = ( self.transInside(s) ) rescue RuleFailure => ex - self._pos = _p277 + self._pos = _p280 raise ex end end @@ -5145,14 +5180,14 @@ class MMetaAndOrOpt < MMetaPass self.setChanged() concat(xs, ys) rescue RuleFailure => ex - self._pos = _p278 + self._pos = _p281 raise ex end end rescue RuleFailure begin begin - _p279 = _pos + _p282 = _pos begin x = ( self.trans() @@ -5162,7 +5197,7 @@ class MMetaAndOrOpt < MMetaPass ) concat([x], xs) rescue RuleFailure => ex - self._pos = _p279 + self._pos = _p282 raise ex end end @@ -5218,7 +5253,7 @@ class MMetaOptimizer < BaseParser _t2 = ( begin begin - _p281 = _pos + _p284 = _pos begin _sym("Parser") p = ( @@ -5232,16 +5267,16 @@ class MMetaOptimizer < BaseParser ) rs = ( begin - as280 = ArrayList.new + as283 = ArrayList.new begin while true do _li = Object( self.optimizeRule() ) - as280.add(_li) + as283.add(_li) end rescue RuleFailure; end - as280 + as283 end ) self.end() @@ -5257,7 +5292,7 @@ class MMetaOptimizer < BaseParser end rescue RuleFailure => ex - self._pos = _p281 + self._pos = _p284 raise ex end end @@ -5288,7 +5323,7 @@ class MMetaOptimizer < BaseParser begin _t2 = ( begin - _p282 = _pos + _p285 = _pos begin r = ( self._any() @@ -5304,7 +5339,7 @@ class MMetaOptimizer < BaseParser end rescue RuleFailure => ex - self._pos = _p282 + self._pos = _p285 raise ex end end From 0afea5acd9e1be583ef3a291cd91f62b32aa0796 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:26:36 +0200 Subject: [PATCH 12/19] Update return type expressions to modern Mirah. --- boot/compiler.mmeta | 3 +-- test/Mirah.mmeta | 3 +-- test/MirahCalculator.mmeta | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/boot/compiler.mmeta b/boot/compiler.mmeta index c50a58f..46c0a3f 100644 --- a/boot/compiler.mmeta +++ b/boot/compiler.mmeta @@ -9,8 +9,7 @@ import hapax.TemplateResourceLoader public parser MMetaCompiler { - def self.main(args:String[]) { - returns void + def self.main(args:String[]):void { if args.length < 1 puts "MMetaCompiler [output]" System.exit(2) diff --git a/test/Mirah.mmeta b/test/Mirah.mmeta index a4521f8..ea8cd66 100644 --- a/test/Mirah.mmeta +++ b/test/Mirah.mmeta @@ -716,8 +716,7 @@ parser MirahParser { return builder.toString } - def self.main(args:String[]) { - returns void + def self.main(args:String[]):void { parser = MirahParser.new code = parse_args(args) begin diff --git a/test/MirahCalculator.mmeta b/test/MirahCalculator.mmeta index 09ec5f6..1b4f8df 100644 --- a/test/MirahCalculator.mmeta +++ b/test/MirahCalculator.mmeta @@ -1,8 +1,7 @@ package test; parser Calculator2 { - def self.main(args:String[]) { - returns void + def self.main(args:String[]):void { parser = Calculator2.new # BaseParser.tracing = true ast = parser.parse(args[0]) From 83f3bcc8052f94ecd54794eddb5a92ba6b52a233 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:49:04 +0200 Subject: [PATCH 13/19] Update bootstrap. --- boot/compiler.mirah | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boot/compiler.mirah b/boot/compiler.mirah index fe5535e..d8d0423 100644 --- a/boot/compiler.mirah +++ b/boot/compiler.mirah @@ -39,7 +39,8 @@ class MMetaCompiler < BaseParser end - def self.main(args:String[]): void + def self.main(args:String[]):void + if args.length < 1 puts "MMetaCompiler [output]" System.exit(2) From 62c87052382bd74deef7d7067e93f4ee8ab553ec Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:58:55 +0200 Subject: [PATCH 14/19] Use ISO8601 timestamps. --- boot/compiler.mmeta | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/boot/compiler.mmeta b/boot/compiler.mmeta index 46c0a3f..f7eeb30 100644 --- a/boot/compiler.mmeta +++ b/boot/compiler.mmeta @@ -2,6 +2,7 @@ package mmeta; import java.util.* import java.io.File +import java.text.SimpleDateFormat import hapax.TemplateCache import hapax.TemplateDataDictionary import hapax.TemplateDictionary @@ -98,6 +99,12 @@ public parser MMetaCompiler { @methods = ArrayList.new @rules = ArrayList.new } + + def timestamp_string { + dateFormat = SimpleDateFormat.new("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + return dateFormat.format(Date.new); + } def addLocal(n:Object) { s = String(n).intern @@ -375,7 +382,7 @@ public parser MMetaCompiler { Line: ws=_ x=trans { ws.toString + x.toString } ; File: xs=trans* { - "# generated by mmeta on #{Date.new}\n" + + "# generated by mmeta on #{timestamp_string}\n" + "# do not modify, instead edit original .mmeta file\n" + "\n" + "#{@jpackage ? @jpackage : ""}\n" + From fe28f2a53f966c1e03d0f372dceb150784abaada Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 03:59:29 +0200 Subject: [PATCH 15/19] Update bootstrap. --- boot/compiler.mirah | 15 +++++++++++++-- boot/parser.mirah | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/boot/compiler.mirah b/boot/compiler.mirah index d8d0423..5f4f325 100644 --- a/boot/compiler.mirah +++ b/boot/compiler.mirah @@ -1,4 +1,4 @@ -# generated by mmeta on Mon May 23 17:32:45 PDT 2011 +# generated by mmeta on 2015-07-21T01:58:09Z # do not modify, instead edit original .mmeta file package mmeta @@ -14,6 +14,8 @@ import java.util.* import java.io.File +import java.text.SimpleDateFormat + import hapax.TemplateCache import hapax.TemplateDataDictionary @@ -150,6 +152,15 @@ class MMetaCompiler < BaseParser end + def timestamp_string() + + dateFormat = SimpleDateFormat.new("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + return dateFormat.format(Date.new); + + end + + def addLocal(n:Object) s = String(n).intern @@ -1538,7 +1549,7 @@ class MMetaCompiler < BaseParser ) begin - "# generated by mmeta on #{Date.new}\n" + + "# generated by mmeta on #{timestamp_string}\n" + "# do not modify, instead edit original .mmeta file\n" + "\n" + "#{@jpackage ? @jpackage : ""}\n" + diff --git a/boot/parser.mirah b/boot/parser.mirah index d6e7cef..055c946 100644 --- a/boot/parser.mirah +++ b/boot/parser.mirah @@ -1,4 +1,4 @@ -# generated by mmeta on Mon May 23 17:32:44 PDT 2011 +# generated by mmeta on 2015-07-21T01:58:08Z # do not modify, instead edit original .mmeta file package mmeta From e427bb11f0f2e8b84b97a2685e48620b960ca37e Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 05:31:56 +0200 Subject: [PATCH 16/19] Look for newlines in BaseParser#_str. --- mmeta/BaseParser.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mmeta/BaseParser.java b/mmeta/BaseParser.java index f24f402..fd76013 100644 --- a/mmeta/BaseParser.java +++ b/mmeta/BaseParser.java @@ -524,7 +524,11 @@ public Object _str(String s) throws RuleFailure { return _error("'"+ s +"'"); } for (int i = 0; i < s.length(); i++) { - if (s.charAt(i) != _chars[p++]) { + char c = _chars[p++]; + if (c == '\n' /*|| (c == '\r' && _cpeek() != '\n')*/) { + note_newline(p); + } + if (s.charAt(i) != c) { _exit(ERROR); return _error("'"+ s +"'"); } From ddd4521670a5730e06db5d8c9e5177da208dbda8 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 05:32:52 +0200 Subject: [PATCH 17/19] Remove "throws" clauses completely. --- boot/templates/parser.xtm | 1 - boot/templates/rule.xtm | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/boot/templates/parser.xtm b/boot/templates/parser.xtm index ced2210..f7ac2a4 100644 --- a/boot/templates/parser.xtm +++ b/boot/templates/parser.xtm @@ -8,7 +8,6 @@ class {{PARSER}} < {{SUPERCLASS}} end def _error(expected:String) - #throws RuleFailure @error.last = expected unless ''.equals(expected) raise @error end diff --git a/boot/templates/rule.xtm b/boot/templates/rule.xtm index 1d59087..7dd1b5e 100644 --- a/boot/templates/rule.xtm +++ b/boot/templates/rule.xtm @@ -1,6 +1,6 @@ def {{RULE}}{{ARGS}}{{#CAST}}:{{CAST}}{{/CAST}} - #throws RuleFailure{{#DEBUG}} + {{#DEBUG}} _enter('{{RULE}}'){{/DEBUG}}{{#SCOPE_VARS}} __saved_{{SIMPLE_NAME}} = {{NAME}}{{/SCOPE_VARS}} begin From 861d7aae6d262b18ef8ad1685e6e6f4e032f35b7 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Tue, 21 Jul 2015 05:33:41 +0200 Subject: [PATCH 18/19] Update bootstrap. --- boot/compiler.mirah | 77 +++++++++++----------- boot/parser.mirah | 154 +++++++++++++++++++++----------------------- 2 files changed, 113 insertions(+), 118 deletions(-) diff --git a/boot/compiler.mirah b/boot/compiler.mirah index 5f4f325..7c7bf76 100644 --- a/boot/compiler.mirah +++ b/boot/compiler.mirah @@ -35,7 +35,6 @@ class MMetaCompiler < BaseParser end def _error(expected:String) - #throws RuleFailure @error.last = expected unless ''.equals(expected) raise @error end @@ -191,7 +190,7 @@ class MMetaCompiler < BaseParser def destruct - #throws RuleFailure + begin _start = _pos; t = nil; r = nil begin @@ -223,7 +222,7 @@ class MMetaCompiler < BaseParser def trans - #throws RuleFailure + __saved_dict = @dict begin _start = _pos; r = nil @@ -257,7 +256,7 @@ class MMetaCompiler < BaseParser def HList - #throws RuleFailure + begin _start = _pos; ls = nil begin @@ -300,7 +299,7 @@ class MMetaCompiler < BaseParser def HConcat - #throws RuleFailure + begin _start = _pos; l = nil; r = nil begin @@ -327,7 +326,7 @@ class MMetaCompiler < BaseParser def HStr - #throws RuleFailure + begin _start = _pos; c = nil begin @@ -351,7 +350,7 @@ class MMetaCompiler < BaseParser def HLit - #throws RuleFailure + begin _start = _pos; c = nil begin @@ -375,7 +374,7 @@ class MMetaCompiler < BaseParser def Node - #throws RuleFailure + begin _start = _pos; n = nil; ls = nil begin @@ -443,7 +442,7 @@ class MMetaCompiler < BaseParser def Error - #throws RuleFailure + begin _start = _pos; msg = nil; body = nil begin @@ -477,7 +476,7 @@ class MMetaCompiler < BaseParser def Set - #throws RuleFailure + begin _start = _pos; n = nil; x = nil begin @@ -512,7 +511,7 @@ class MMetaCompiler < BaseParser def Str - #throws RuleFailure + begin _start = _pos; s = nil begin @@ -538,7 +537,7 @@ class MMetaCompiler < BaseParser def Sym - #throws RuleFailure + begin _start = _pos; s = nil begin @@ -562,7 +561,7 @@ class MMetaCompiler < BaseParser def App - #throws RuleFailure + begin _start = _pos; rule = nil; args = nil begin @@ -638,7 +637,7 @@ class MMetaCompiler < BaseParser def Dot - #throws RuleFailure + begin _start = _pos "ws()" @@ -651,7 +650,7 @@ class MMetaCompiler < BaseParser def SAct - #throws RuleFailure + begin _start = _pos; expr = nil begin @@ -675,7 +674,7 @@ class MMetaCompiler < BaseParser def Act - #throws RuleFailure + begin _start = _pos; expr = nil begin @@ -705,7 +704,7 @@ class MMetaCompiler < BaseParser def Pred - #throws RuleFailure + begin _start = _pos; expr = nil begin @@ -737,7 +736,7 @@ class MMetaCompiler < BaseParser def SynPred - #throws RuleFailure + begin _start = _pos; pred = nil; body = nil; tail = nil begin @@ -794,7 +793,7 @@ class MMetaCompiler < BaseParser def AToken - #throws RuleFailure + begin _start = _pos; name = nil begin @@ -818,7 +817,7 @@ class MMetaCompiler < BaseParser def TokenRange - #throws RuleFailure + begin _start = _pos; first = nil; last = nil begin @@ -854,7 +853,7 @@ class MMetaCompiler < BaseParser def TLit - #throws RuleFailure + begin _start = _pos; name = nil begin @@ -885,7 +884,7 @@ class MMetaCompiler < BaseParser def Or - #throws RuleFailure + begin _start = _pos; xs = nil begin @@ -940,7 +939,7 @@ class MMetaCompiler < BaseParser def And - #throws RuleFailure + begin _start = _pos; ts = nil begin @@ -1006,7 +1005,7 @@ class MMetaCompiler < BaseParser def Many - #throws RuleFailure + begin _start = _pos; x = nil begin @@ -1032,7 +1031,7 @@ class MMetaCompiler < BaseParser def Many1 - #throws RuleFailure + begin _start = _pos; x = nil begin @@ -1058,7 +1057,7 @@ class MMetaCompiler < BaseParser def Opt - #throws RuleFailure + begin _start = _pos; x = nil begin @@ -1088,7 +1087,7 @@ class MMetaCompiler < BaseParser def Not - #throws RuleFailure + begin _start = _pos; x = nil begin @@ -1118,7 +1117,7 @@ class MMetaCompiler < BaseParser def Peek - #throws RuleFailure + begin _start = _pos; x = nil begin @@ -1149,7 +1148,7 @@ class MMetaCompiler < BaseParser def List - #throws RuleFailure + begin _start = _pos; x = nil begin @@ -1179,7 +1178,7 @@ class MMetaCompiler < BaseParser def Rule - #throws RuleFailure + begin _start = _pos; name = nil; args = nil; body = nil; annotations = nil begin @@ -1268,7 +1267,7 @@ class MMetaCompiler < BaseParser def Parser - #throws RuleFailure + begin _start = _pos; p = nil; n = nil; s = nil; xs = nil begin @@ -1333,7 +1332,7 @@ class MMetaCompiler < BaseParser def Method - #throws RuleFailure + begin _start = _pos; name = nil; args = nil; returntypeopt = nil; body = nil; ismacro = nil; c = nil begin @@ -1394,7 +1393,7 @@ class MMetaCompiler < BaseParser def Field - #throws RuleFailure + begin _start = _pos; c = nil begin @@ -1418,7 +1417,7 @@ class MMetaCompiler < BaseParser def Package - #throws RuleFailure + begin _start = _pos; c = nil begin @@ -1444,7 +1443,7 @@ class MMetaCompiler < BaseParser def Import - #throws RuleFailure + begin _start = _pos; c = nil begin @@ -1468,7 +1467,7 @@ class MMetaCompiler < BaseParser def Class - #throws RuleFailure + begin _start = _pos; q = nil; d = nil; c = nil begin @@ -1498,7 +1497,7 @@ class MMetaCompiler < BaseParser def Line - #throws RuleFailure + begin _start = _pos; ws = nil; x = nil begin @@ -1527,7 +1526,7 @@ class MMetaCompiler < BaseParser def File - #throws RuleFailure + begin _start = _pos; xs = nil begin @@ -1575,7 +1574,7 @@ class MMetaCompiler < BaseParser def start - #throws RuleFailure + begin _start = _pos; r = nil begin diff --git a/boot/parser.mirah b/boot/parser.mirah index 055c946..eca28bb 100644 --- a/boot/parser.mirah +++ b/boot/parser.mirah @@ -22,7 +22,6 @@ class MMetaParser < BaseParser end def _error(expected:String) - #throws RuleFailure @error.last = expected unless ''.equals(expected) raise @error end @@ -37,7 +36,7 @@ class MMetaParser < BaseParser def fromTo(x:String, y:String) - #throws RuleFailure + begin _start = _pos begin @@ -87,7 +86,7 @@ class MMetaParser < BaseParser def sp - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.sp") @@ -123,7 +122,7 @@ class MMetaParser < BaseParser def ws - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.ws") @@ -162,7 +161,7 @@ class MMetaParser < BaseParser def listOf(e:String, s:String) - #throws RuleFailure + begin _start = _pos; f = nil; rs = nil begin @@ -225,7 +224,7 @@ class MMetaParser < BaseParser def nameFirst - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.nameFirst") @@ -258,7 +257,7 @@ class MMetaParser < BaseParser def nameRest - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.nameRest") @@ -286,7 +285,7 @@ class MMetaParser < BaseParser def name - #throws RuleFailure + begin _start = _pos; f = nil; rs = nil _t = _sretrieve("MMetaParser.name") @@ -337,7 +336,7 @@ class MMetaParser < BaseParser def rulename - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.rulename") @@ -385,7 +384,7 @@ class MMetaParser < BaseParser def varname - #throws RuleFailure + begin _start = _pos; p = nil; n = nil _t = _sretrieve("MMetaParser.varname") @@ -432,7 +431,7 @@ class MMetaParser < BaseParser def hex - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.hex") @@ -456,7 +455,7 @@ class MMetaParser < BaseParser def echar - #throws RuleFailure + begin _start = _pos; c = nil _t = _sretrieve("MMetaParser.echar") @@ -515,7 +514,7 @@ class MMetaParser < BaseParser def tsString - #throws RuleFailure + begin _start = _pos; xs = nil _t = _sretrieve("MMetaParser.tsString") @@ -596,7 +595,7 @@ class MMetaParser < BaseParser def dollar - #throws RuleFailure + begin _start = _pos; xs = nil; n = nil _t = _sretrieve("MMetaParser.dollar") @@ -675,7 +674,7 @@ class MMetaParser < BaseParser def dollarstring - #throws RuleFailure + begin _start = _pos; xs = nil _t = _sretrieve("MMetaParser.dollarstring") @@ -760,7 +759,7 @@ class MMetaParser < BaseParser def string - #throws RuleFailure + begin _start = _pos; s = nil _t = _sretrieve("MMetaParser.string") @@ -795,7 +794,7 @@ class MMetaParser < BaseParser def number - #throws RuleFailure + begin _start = _pos; sign = nil; ds = nil _t = _sretrieve("MMetaParser.number") @@ -863,7 +862,7 @@ class MMetaParser < BaseParser def symbol - #throws RuleFailure + begin _start = _pos; s = nil; c = nil _t = _sretrieve("MMetaParser.symbol") @@ -977,7 +976,7 @@ class MMetaParser < BaseParser def k(keyword:String) - #throws RuleFailure + begin _start = _pos begin @@ -1011,7 +1010,7 @@ class MMetaParser < BaseParser def error - #throws RuleFailure + begin _start = _pos; msg = nil; b = nil _t = _sretrieve("MMetaParser.error") @@ -1060,7 +1059,7 @@ class MMetaParser < BaseParser def any - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.any") @@ -1098,7 +1097,7 @@ class MMetaParser < BaseParser def wsdot - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.wsdot") @@ -1136,7 +1135,7 @@ class MMetaParser < BaseParser def args - #throws RuleFailure + begin _start = _pos; as = nil _t = _sretrieve("MMetaParser.args") @@ -1209,7 +1208,7 @@ class MMetaParser < BaseParser def application - #throws RuleFailure + begin _start = _pos; r = nil; as = nil _t = _sretrieve("MMetaParser.application") @@ -1283,7 +1282,7 @@ class MMetaParser < BaseParser def fname - #throws RuleFailure + begin _start = _pos; x = nil; t = nil; n = nil _t = _sretrieve("MMetaParser.fname") @@ -1349,7 +1348,7 @@ class MMetaParser < BaseParser def parens - #throws RuleFailure + begin _start = _pos; x = nil _t = _sretrieve("MMetaParser.parens") @@ -1427,7 +1426,7 @@ class MMetaParser < BaseParser def dotted_name - #throws RuleFailure + begin _start = _pos; h = nil; t = nil; l = nil _t = _sretrieve("MMetaParser.dotted_name") @@ -1498,7 +1497,7 @@ class MMetaParser < BaseParser def rewrite_expr - #throws RuleFailure + begin _start = _pos; n = nil; p = nil; c = nil; cl = nil; s = nil; xs = nil _t = _sretrieve("MMetaParser.rewrite_expr") @@ -1723,7 +1722,7 @@ class MMetaParser < BaseParser def simplehost - #throws RuleFailure + begin _start = _pos; rs = nil; ls = nil; x = nil _t = _sretrieve("MMetaParser.simplehost") @@ -1784,7 +1783,7 @@ class MMetaParser < BaseParser def simplehost1 - #throws RuleFailure + begin _start = _pos; xs = nil; num = nil; s = nil; n = nil _t = _sretrieve("MMetaParser.simplehost1") @@ -1933,7 +1932,7 @@ class MMetaParser < BaseParser def cbraces - #throws RuleFailure + begin _start = _pos; xs = nil _t = _sretrieve("MMetaParser.cbraces") @@ -2018,7 +2017,7 @@ class MMetaParser < BaseParser def semAction - #throws RuleFailure + begin _start = _pos; s = nil; xs = nil _t = _sretrieve("MMetaParser.semAction") @@ -2150,7 +2149,7 @@ class MMetaParser < BaseParser def semPred - #throws RuleFailure + begin _start = _pos; xs = nil _t = _sretrieve("MMetaParser.semPred") @@ -2220,7 +2219,7 @@ class MMetaParser < BaseParser def synPred - #throws RuleFailure + begin _start = _pos; p = nil; e = nil; t = nil _t = _sretrieve("MMetaParser.synPred") @@ -2294,7 +2293,7 @@ class MMetaParser < BaseParser def synPredTail - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.synPredTail") @@ -2337,7 +2336,7 @@ class MMetaParser < BaseParser def token - #throws RuleFailure + begin _start = _pos; n = nil _t = _sretrieve("MMetaParser.token") @@ -2378,7 +2377,7 @@ class MMetaParser < BaseParser def tokens - #throws RuleFailure + begin _start = _pos; a = nil; b = nil _t = _sretrieve("MMetaParser.tokens") @@ -2436,7 +2435,7 @@ class MMetaParser < BaseParser def expr - #throws RuleFailure + begin _start = _pos; xs = nil _t = _sretrieve("MMetaParser.expr") @@ -2471,7 +2470,7 @@ class MMetaParser < BaseParser def expr4 - #throws RuleFailure + begin _start = _pos; xs = nil _t = _sretrieve("MMetaParser.expr4") @@ -2521,7 +2520,7 @@ class MMetaParser < BaseParser def optIter(x:Object) - #throws RuleFailure + begin _start = _pos begin @@ -2597,7 +2596,7 @@ class MMetaParser < BaseParser def expr3 - #throws RuleFailure + begin _start = _pos; n = nil; e = nil; x = nil _t = _sretrieve("MMetaParser.expr3") @@ -2678,7 +2677,7 @@ class MMetaParser < BaseParser def expr2 - #throws RuleFailure + begin _start = _pos; x = nil _t = _sretrieve("MMetaParser.expr2") @@ -2768,7 +2767,7 @@ class MMetaParser < BaseParser def expr1 - #throws RuleFailure + begin _start = _pos; k = nil; x = nil _t = _sretrieve("MMetaParser.expr1") @@ -2933,7 +2932,7 @@ class MMetaParser < BaseParser def annotation - #throws RuleFailure + begin _start = _pos; t = nil; l = nil; n = nil _t = _sretrieve("MMetaParser.annotation") @@ -3100,7 +3099,7 @@ class MMetaParser < BaseParser def ruleArgs - #throws RuleFailure + begin _start = _pos; s = nil _t = _sretrieve("MMetaParser.ruleArgs") @@ -3180,7 +3179,7 @@ class MMetaParser < BaseParser def rule - #throws RuleFailure + begin _start = _pos; a = nil; n = nil; args = nil; x = nil _t = _sretrieve("MMetaParser.rule") @@ -3267,7 +3266,7 @@ class MMetaParser < BaseParser def qualifiers - #throws RuleFailure + begin _start = _pos; qs = nil _t = _sretrieve("MMetaParser.qualifiers") @@ -3379,7 +3378,7 @@ class MMetaParser < BaseParser def method - #throws RuleFailure + begin _start = _pos; m = nil; s = nil; n = nil; as = nil; returntypeopt = nil; bs = nil _t = _sretrieve("MMetaParser.method") @@ -3600,7 +3599,7 @@ class MMetaParser < BaseParser def jimport - #throws RuleFailure + begin _start = _pos; stm = nil; xs = nil _t = _sretrieve("MMetaParser.jimport") @@ -3687,7 +3686,7 @@ class MMetaParser < BaseParser def jpackage - #throws RuleFailure + begin _start = _pos; stm = nil; xs = nil _t = _sretrieve("MMetaParser.jpackage") @@ -3774,7 +3773,7 @@ class MMetaParser < BaseParser def classdef - #throws RuleFailure + begin _start = _pos; q = nil; xs = nil; bs = nil _t = _sretrieve("MMetaParser.classdef") @@ -3884,7 +3883,7 @@ class MMetaParser < BaseParser def ruleMethod - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.ruleMethod") @@ -3930,7 +3929,7 @@ class MMetaParser < BaseParser def parser - #throws RuleFailure + begin _start = _pos; m = nil; n = nil; sn = nil; rs = nil; p = nil _t = _sretrieve("MMetaParser.parser") @@ -4075,7 +4074,7 @@ class MMetaParser < BaseParser def line - #throws RuleFailure + begin _start = _pos; p = nil; l = nil _t = _sretrieve("MMetaParser.line") @@ -4125,7 +4124,7 @@ class MMetaParser < BaseParser def file - #throws RuleFailure + begin _start = _pos; ls = nil _t = _sretrieve("MMetaParser.file") @@ -4177,7 +4176,7 @@ class MMetaParser < BaseParser def start - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaParser.start") @@ -4321,7 +4320,6 @@ class MMetaPass < BaseParser end def _error(expected:String) - #throws RuleFailure @error.last = expected unless ''.equals(expected) raise @error end @@ -4350,7 +4348,7 @@ class MMetaPass < BaseParser def setChanged - #throws RuleFailure + begin _start = _pos _t = _sretrieve("MMetaPass.setChanged") @@ -4376,7 +4374,7 @@ class MMetaPass < BaseParser def destruct - #throws RuleFailure + begin _start = _pos; r = nil; x = nil _t = _sretrieve("MMetaPass.destruct") @@ -4428,7 +4426,7 @@ class MMetaPass < BaseParser def trans - #throws RuleFailure + begin _start = _pos; x = nil _t = _sretrieve("MMetaPass.trans") @@ -4474,7 +4472,7 @@ class MMetaPass < BaseParser def Or - #throws RuleFailure + begin _start = _pos; xs = nil _t = _sretrieve("MMetaPass.Or") @@ -4520,7 +4518,7 @@ class MMetaPass < BaseParser def And - #throws RuleFailure + begin _start = _pos; xs = nil _t = _sretrieve("MMetaPass.And") @@ -4566,7 +4564,7 @@ class MMetaPass < BaseParser def Not - #throws RuleFailure + begin _start = _pos; x = nil _t = _sretrieve("MMetaPass.Not") @@ -4601,7 +4599,7 @@ class MMetaPass < BaseParser def Many - #throws RuleFailure + begin _start = _pos; x = nil _t = _sretrieve("MMetaPass.Many") @@ -4636,7 +4634,7 @@ class MMetaPass < BaseParser def Many1 - #throws RuleFailure + begin _start = _pos; x = nil _t = _sretrieve("MMetaPass.Many1") @@ -4671,7 +4669,7 @@ class MMetaPass < BaseParser def Peek - #throws RuleFailure + begin _start = _pos; x = nil _t = _sretrieve("MMetaPass.Peek") @@ -4706,7 +4704,7 @@ class MMetaPass < BaseParser def List - #throws RuleFailure + begin _start = _pos; x = nil _t = _sretrieve("MMetaPass.List") @@ -4741,7 +4739,7 @@ class MMetaPass < BaseParser def Set - #throws RuleFailure + begin _start = _pos; n = nil; x = nil _t = _sretrieve("MMetaPass.Set") @@ -4779,7 +4777,7 @@ class MMetaPass < BaseParser def Rule - #throws RuleFailure + begin _start = _pos; n = nil; args = nil; x = nil; anno = nil _t = _sretrieve("MMetaPass.Rule") @@ -4823,7 +4821,7 @@ class MMetaPass < BaseParser def SynPred - #throws RuleFailure + begin _start = _pos; xs = nil _t = _sretrieve("MMetaPass.SynPred") @@ -4869,7 +4867,7 @@ class MMetaPass < BaseParser def Error - #throws RuleFailure + begin _start = _pos; m = nil; x = nil _t = _sretrieve("MMetaPass.Error") @@ -4907,7 +4905,7 @@ class MMetaPass < BaseParser def start - #throws RuleFailure + begin _start = _pos; r = nil _t = _sretrieve("MMetaPass.start") @@ -5034,7 +5032,6 @@ class MMetaAndOrOpt < MMetaPass end def _error(expected:String) - #throws RuleFailure @error.last = expected unless ''.equals(expected) raise @error end @@ -5042,7 +5039,7 @@ class MMetaAndOrOpt < MMetaPass def And - #throws RuleFailure + begin _start = _pos; x = nil; xs = nil _t = _sretrieve("MMetaAndOrOpt.And") @@ -5095,7 +5092,7 @@ class MMetaAndOrOpt < MMetaPass def Or - #throws RuleFailure + begin _start = _pos; x = nil; xs = nil _t = _sretrieve("MMetaAndOrOpt.Or") @@ -5148,7 +5145,7 @@ class MMetaAndOrOpt < MMetaPass def transInside(s:String) - #throws RuleFailure + begin _start = _pos; xs = nil; ys = nil; x = nil begin @@ -5236,7 +5233,6 @@ class MMetaOptimizer < BaseParser end def _error(expected:String) - #throws RuleFailure @error.last = expected unless ''.equals(expected) raise @error end @@ -5244,7 +5240,7 @@ class MMetaOptimizer < BaseParser def optimizeGrammar - #throws RuleFailure + begin _start = _pos; p = nil; n = nil; sn = nil; rs = nil; x = nil _t = _sretrieve("MMetaOptimizer.optimizeGrammar") @@ -5315,7 +5311,7 @@ class MMetaOptimizer < BaseParser def optimizeRule - #throws RuleFailure + begin _start = _pos; r = nil _t = _sretrieve("MMetaOptimizer.optimizeRule") From 4be4729d089f53324e5b6121f245adc7ef31df95 Mon Sep 17 00:00:00 2001 From: Felix von Ferey Date: Wed, 22 Jul 2015 15:21:12 +0200 Subject: [PATCH 19/19] Use Java 1.5 class file format to be compatible with Java 1.5. --- Rakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index 91a6812..156579c 100644 --- a/Rakefile +++ b/Rakefile @@ -19,8 +19,8 @@ end file 'dist/mmeta-runtime.jar' => Dir.glob('mmeta/*.{java,mirah}') + ['build/runtime', 'dist'] do ENV['BS_CHECK_CLASSES'] = 'true' - mirahc('mmeta/ast.mirah', :dest => 'build/runtime') - ant.javac :srcDir=>'mmeta', :destDir=>'build/runtime', :debug=>true + mirahc('mmeta/ast.mirah', :dest => 'build/runtime', :options => ['--jvm', '1.5']) + ant.javac :srcDir=>'mmeta', :destDir=>'build/runtime', :debug=>true, :target => '1.5', :source => '1.5' ant.jar :destfile=>'dist/mmeta-runtime.jar', :basedir=>'build/runtime' end @@ -29,7 +29,7 @@ file 'build/boot/mmeta/MMetaParser.class' => ['boot/parser.mirah', 'build/boot/m mirahc('build/boot/mmeta/parser.mirah', :dir => 'build/boot', :dest => 'build/boot', - :options => ['--classpath', 'dist/mmeta-runtime.jar']) + :options => ['--jvm', '1.5', '--classpath', 'dist/mmeta-runtime.jar']) end file 'build/boot/mmeta/MMetaCompiler.class' => ['boot/compiler.mirah', 'build/boot/mmeta', 'dist/mmeta-runtime.jar' ] do @@ -38,7 +38,7 @@ file 'build/boot/mmeta/MMetaCompiler.class' => ['boot/compiler.mirah', 'build/bo :dir => 'build/boot', :dest => 'build/boot', :options => [ - '--classpath', 'build/boot:dist/mmeta-runtime.jar:javalib/hapax-2.3.5-autoindent.jar' + '--jvm', '1.5', '--classpath', 'build/boot:dist/mmeta-runtime.jar:javalib/hapax-2.3.5-autoindent.jar' ]) end