Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program z_ometa_base.
- * The core logic of the OMeta/JS 2.0 parser generator
- * Made available to ABAP using its built-in JS interpreter
- * For oMeta, see
- * http://tinlizzie.org/ometa/ for oMeta
- * Also
- * http://ruediger-plantiko.blogspot.com/2010/11/eine-objektorientierte-metasprache.html
- * I have chosen the report form for easy copy/paste
- data: go_js type ref to cl_java_script,
- begin of gs_translation,
- source type string,
- end of gs_translation.
- load-of-program.
- perform _do_on_load.
- * --- API part ---------------------------------------------------------------------
- * --- DO_IT
- * Execute any JS code with this JS instance
- form do_it using iv_source type string
- changing ev_result type string
- ev_error_code type i.
- ev_result = go_js->evaluate( iv_source ).
- ev_error_code = go_js->last_condition_code.
- endform. "do_it
- * --- MATCH
- * Matches code against a rule and returns the result
- form match using iv_grammar type string
- iv_rule type string
- iv_source type string
- changing ev_result type string
- ev_error_code type i.
- * Leider funktionieren Referenzen auf den Stack nicht -> Muss kopieren
- gs_translation-source = iv_source.
- perform _match using iv_grammar iv_rule 'trans.source'
- changing ev_result ev_error_code.
- endform. "match
- * --- MATCH_LAST_RESULT
- * For applying a chain of transformations
- form match_last_result using iv_grammar type string
- iv_rule type string
- changing ev_result type string
- ev_error_code type i.
- perform _match using iv_grammar iv_rule 'transLastResult'
- changing ev_result ev_error_code.
- endform. "match
- * --- TRANSLATE
- * Build a parser for a given oMeta grammar
- form translate using iv_source type string
- changing ev_result type string
- ev_error_code type i.
- data: lv_result type string.
- gs_translation-source = iv_source.
- perform do_it using 'translateCode( trans.source ) '
- changing ev_result ev_error_code.
- if ev_error_code = 0.
- * Ignore the meaningless result which is of type '[Object object]'
- perform do_it using ev_result
- changing lv_result ev_error_code.
- endif.
- endform. "translate
- * --- GET_OMETA_JS
- * Give back an instance of the oMeta enabled JS interpreter
- * Not needed in simpler cases
- form get_ometa_js changing eo_js type ref to cl_java_script.
- eo_js = go_js.
- endform. "get_ometa_js
- * --- GET_LAST_ERROR
- form get_last_error changing ev_text type string.
- ev_text = space.
- if go_js->last_condition_code <> 0.
- ev_text = go_js->last_error_message.
- endif.
- endform. "get_last_error
- * --- BIND (iv_name maybe compound, like 'abap.obj'
- form bind using iv_name type string
- cv_any type any.
- data: lv_obj type string,
- lv_prop type string.
- if iv_name ca '.'.
- split iv_name at '.' into lv_obj lv_prop.
- else.
- lv_prop = iv_name.
- endif.
- go_js->bind( exporting name_obj = lv_obj
- name_prop = lv_prop
- changing data = cv_any ).
- endform. "bind
- * --- Private part -------------------------------------------------------
- form _match using iv_grammar type string
- iv_rule type string
- iv_source_symbol type string
- changing ev_result type string
- ev_error_code type i.
- data: lv_result type string,
- lv_matcher type string value
- 'transLastResult = #Grammar.matchAll' &
- '(#Source, "#Rule" );'.
- replace :
- '#Grammar' in lv_matcher with iv_grammar,
- '#Rule' in lv_matcher with iv_rule,
- '#Source' in lv_matcher with iv_source_symbol.
- clear ev_result.
- perform do_it using lv_matcher
- changing ev_result ev_error_code.
- endform. "_match
- *&---------------------------------------------------------------------*
- *& Form _do_on_load
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- form _do_on_load.
- go_js = cl_java_script=>create( ).
- perform bind using 'trans.source' gs_translation-source.
- * A global JS variable: the result of the last transformation as JS object
- go_js->evaluate( `var transLastResult = null;` ).
- perform _do_ometa_base.
- endform. "_do_on_load
- * ---
- form _do_ometa_base.
- data: lv_base type string,
- lv_result type string,
- lv_error_code type i.
- perform _read_ometa_base changing lv_base.
- perform do_it using lv_base
- changing lv_result lv_error_code.
- * oMeta base code corrupt?
- assert lv_error_code = 0.
- endform. "do_ometa_base
- * ---
- form _read_ometa_base changing cv_base type string.
- data: lt_code type stringtab,
- lv_code type text72,
- lv_tabix type i.
- field-symbols: <lv_code> type string.
- read report 'Z_OMETA_BASE' into lt_code.
- find regex '<<<\s*ometa-base' in table lt_code match line lv_tabix.
- assert sy-subrc eq 0.
- add 1 to lv_tabix.
- loop at lt_code into lv_code from lv_tabix.
- concatenate cv_base lv_code+2 into cv_base respecting blanks.
- endloop.
- replace all occurrences of '#CRLF#' in cv_base
- with cl_abap_char_utilities=>cr_lf.
- endform. "read_ometa_base
- * oMeta-Base consists of these files:
- * 'lib.js',
- * 'ometa-base.js',
- * 'parser.js',
- * 'bs-js-compiler.js',
- * 'bs-ometa-compiler.js',
- * 'bs-ometa-optimizer.js',
- * 'bs-ometa-js-compiler.js'.
- * + Definition von translateCode()
- * <<< ometa-base
- * #CRLF#// try to use StringBuffer instead of string concatenation to im
- * prove performance#CRLF##CRLF#function StringBuffer() {#CRLF# this.str
- * ings = []#CRLF# for (var idx = 0; idx < arguments.length; idx++)#CRLF
- * # this.nextPutAll(arguments[idx])#CRLF#}#CRLF#StringBuffer.prototyp
- * e.nextPutAll = function(s) { this.strings.push(s) }#CRLF#StringBuffer.
- * prototype.contents = function() { return this.strings.join("") }#CR
- * LF#String.prototype.writeStream = function() { return new StringB
- * uffer(this) }#CRLF##CRLF#// make Arrays print themselves sensibly#CRLF
- * ##CRLF#Object.prototype.printOn = function(ws) { ws.nextPutAll(this.to
- * String()) }#CRLF##CRLF#Array.prototype.toString = function() { var ws
- * = "".writeStream(); this.printOn(ws); return ws.contents() }#CRLF#Arra
- * y.prototype.printOn = function(ws) {#CRLF# ws.nextPutAll("[")#CRLF#
- * for (var idx = 0; idx < this.length; idx++) {#CRLF# if (idx > 0)#CR
- * LF# ws.nextPutAll(", ")#CRLF# this[idx].printOn(ws)#CRLF# }#C
- * RLF# ws.nextPutAll("]")#CRLF#}#CRLF##CRLF#// delegation#CRLF##CRLF#Ob
- * ject.prototype.delegated = function(props) {#CRLF# var f = function()
- * { }#CRLF# f.prototype = this#CRLF# var r = new f()#CRLF# for (var
- * p in props)#CRLF# if (props.hasOwnProperty(p))#CRLF# r[p] = pr
- * ops[p]#CRLF# return r#CRLF#}#CRLF##CRLF#// some reflective stuff#CRLF
- * ##CRLF#Object.prototype.ownPropertyNames = function() {#CRLF# var r =
- * []#CRLF# for (name in this)#CRLF# if (this.hasOwnProperty(name))#
- * CRLF# r.push(name)#CRLF# return r#CRLF#}#CRLF##CRLF#Object.proto
- * type.hasProperty = function(p) { return this[p] != undefined }#CRLF##C
- * RLF#Object.prototype.isNumber = function() { return false }#CRLF#Nu
- * mber.prototype.isNumber = function() { return true }#CRLF##CRLF#Obj
- * ect.prototype.isString = function() { return false }#CRLF#String.pr
- * ototype.isString = function() { return true }#CRLF##CRLF#Object.pro
- * totype.isCharacter = function() { return false }#CRLF##CRLF#String.pro
- * totype.isCharacter = function() { return this.length == 1 }#CRLF#Strin
- * g.prototype.isSpace = function() { return this.isCharacter() && th
- * is.charCodeAt(0) <= 32 }#CRLF#String.prototype.isDigit = functio
- * n() { return this.isCharacter() && this >= "0" && this <= "9" }#CRLF#S
- * tring.prototype.isLower = function() { return this.isCharacter() &
- * & this >= "a" && this <= "z" }#CRLF#String.prototype.isUpper = fun
- * ction() { return this.isCharacter() && this >= "A" && this <= "Z" }#CR
- * LF##CRLF#String.prototype.digitValue = function() { return this.charC
- * odeAt(0) - "0".charCodeAt(0) }#CRLF##CRLF#Object.prototype.isSequencea
- * ble = false#CRLF#Array.prototype.isSequenceable = true#CRLF#String.pr
- * ototype.isSequenceable = true#CRLF##CRLF#// some functional programmin
- * g stuff#CRLF##CRLF#Array.prototype.map = function(f) {#CRLF# var r =
- * []#CRLF# for (var idx = 0; idx < this.length; idx++)#CRLF# r[idx]
- * = f(this[idx])#CRLF# return r#CRLF#}#CRLF##CRLF#Array.prototype.reduc
- * e = function(f, z) {#CRLF# var r = z#CRLF# for (var idx = 0; idx < t
- * his.length; idx++)#CRLF# r = f(r, this[idx])#CRLF# return r#CRLF#}
- * #CRLF##CRLF#Array.prototype.delimWith = function(d) {#CRLF# return th
- * is.reduce(#CRLF# function(xs, x) {#CRLF# if (xs.length > 0)#CR
- * LF# xs.push(d)#CRLF# xs.push(x)#CRLF# return xs#CRLF#
- * },#CRLF# [])#CRLF#}#CRLF##CRLF#// Squeak's ReadStream, kind of#C
- * RLF##CRLF#function ReadStream(anArrayOrString) {#CRLF# this.src = anA
- * rrayOrString#CRLF# this.pos = 0#CRLF#}#CRLF#ReadStream.prototype.atEn
- * d = function() { return this.pos >= this.src.length }#CRLF#ReadStream.
- * prototype.next = function() { return this.src.at(this.pos++) }#CRLF##
- * CRLF#// escape characters#CRLF##CRLF#escapeStringFor = new Object()#CR
- * LF#for (var c = 0; c < 256; c++)#CRLF# escapeStringFor[c] = String.fr
- * omCharCode(c)#CRLF#escapeStringFor["\\".charCodeAt(0)] = "\\\\"#CRLF#e
- * scapeStringFor['"'.charCodeAt(0)] = '\\"'#CRLF#escapeStringFor["'".ch
- * arCodeAt(0)] = "\\'"#CRLF#escapeStringFor["\r".charCodeAt(0)] = "\\r"
- * #CRLF#escapeStringFor["\n".charCodeAt(0)] = "\\n"#CRLF#escapeStringFor
- * ["\t".charCodeAt(0)] = "\\t"#CRLF#escapeChar = function(c) {#CRLF# va
- * r charCode = c.charCodeAt(0)#CRLF# return charCode > 255 ? String.fro
- * mCharCode(charCode) : escapeStringFor[charCode]#CRLF#}#CRLF##CRLF#func
- * tion unescape(s) {#CRLF# if (s[0] == '\\')#CRLF# switch (s[1]) {#C
- * RLF# case '\\': return '\\'#CRLF# case 'r': return '\r'#CRL
- * F# case 'n': return '\n'#CRLF# case 't': return '\t'#CRLF#
- * default: return s[1]#CRLF# }#CRLF# else#CRLF# return s#
- * CRLF#}#CRLF##CRLF#String.prototype.toProgramString = function() {#CRLF
- * # var ws = "\"".writeStream()#CRLF# for (var idx = 0; idx < this.len
- * gth; idx++)#CRLF# ws.nextPutAll(escapeChar(this[idx]))#CRLF# ws.ne
- * xtPutAll("\"")#CRLF# return ws.contents()#CRLF#}#CRLF##CRLF#// C-styl
- * e tempnam function#CRLF##CRLF#function tempnam(s) { return (s ? s : "_
- * tmpnam_") + tempnam.n++ }#CRLF#tempnam.n = 0#CRLF##CRLF##CRLF#// Copyr
- * ight (c) 2007, 2008 Alessandro Warth <awarth@cs.ucla.edu>#CRLF##CRLF#/
- * *#CRLF# new syntax:#CRLF# #foo match the string object 'foo' (shou
- * ld also be accepted in JS)#CRLF# 'abc' match the string object 'abc
- * '#CRLF# 'c' match the string object 'c'#CRLF# ``abc'' match the
- * sequence of string objects 'a', 'b', 'c'#CRLF# "abc" token('abc')#
- * CRLF# [1 2 3] match the array object [1, 2, 3]#CRLF# foo(bar) ap
- * ply rule foo with argument bar#CRLF# -> ... do semantic actions in
- * JS (no more ST). allow multiple statements, but no declarations#CRLF#
- * probably don't even need {}s, because newlines can terminate it!#CRLF
- * #*/#CRLF##CRLF#/*#CRLF#// ometa M {#CRLF#// number = number:n digit:
- * d -> { n * 10 + d.digitValue() }#CRLF#// | digit:d -
- * > { d.digitValue() }.#CRLF#// }#CRLF##CRLF#try {#CRLF# M = OMeta.dele
- * gated({#CRLF# number: function() {#CRLF# var $elf = this#CRLF#
- * return $elf._or(#CRLF# function() {#CRLF# var n,
- * d#CRLF# n = $elf._apply("number")#CRLF# d = $elf._a
- * pply("digit")#CRLF# return n * 10 + d.digitValue()#CRLF#
- * },#CRLF# function() {#CRLF# var d#CRLF# d
- * = $elf._apply("digit")#CRLF# return d.digitValue()#CRLF#
- * }#CRLF# )#CRLF# }#CRLF# })#CRLF# M.matchAll("123456789",
- * "number")#CRLF#} catch (f) { alert(f) }#CRLF#*/#CRLF##CRLF#// the fail
- * ure exception#CRLF##CRLF#fail = { toString: function() { return "match
- * failed" } }#CRLF##CRLF#// streams and memoization#CRLF##CRLF#function
- * OMInputStream(hd, tl) {#CRLF# this.memo = { }#CRLF# this.hd = hd#
- * CRLF# this.tl = tl#CRLF#}#CRLF#OMInputStream.prototype.head = funct
- * ion() { return this.hd }#CRLF#OMInputStream.prototype.tail = function(
- * ) { return this.tl }#CRLF##CRLF#function OMInputStreamEnd() { this.mem
- * o = { } }#CRLF#OMInputStreamEnd.prototype.head = function() { throw fa
- * il }#CRLF#OMInputStreamEnd.prototype.tail = function() { throw fail }#
- * CRLF##CRLF#Array.prototype.toOMInputStream = function() { return make
- * ArrayOMInputStream(this, 0) }#CRLF#//String.prototype.toOMInputStream
- * = Array.prototype.toOMInputStream#CRLF#String.prototype.toOMInputStrea
- * m = ("x"[0] == 'x') ? Array.prototype.toOMInputStream : function() { r
- * eturn makeArrayOMInputStream(this.split(''), 0) }#CRLF##CRLF#function
- * makeArrayOMInputStream(arr, idx) { return idx < arr.length ? new Arra
- * yOMInputStream(arr, idx) : new OMInputStreamEnd() }#CRLF##CRLF#functio
- * n ArrayOMInputStream(arr, idx) {#CRLF# this.memo = { }#CRLF# this.ar
- * r = arr#CRLF# this.idx = idx#CRLF# this.hd = arr[idx]#CRLF#}#CRL
- * F#ArrayOMInputStream.prototype.head = function() { return this.hd }#CR
- * LF#ArrayOMInputStream.prototype.tail = function() {#CRLF# if (this.tl
- * == undefined)#CRLF# this.tl = makeArrayOMInputStream(this.arr, thi
- * s.idx + 1)#CRLF# return this.tl#CRLF#}#CRLF##CRLF#function makeOMInpu
- * tStreamProxy(target) {#CRLF# return target.delegated({#CRLF# memo:
- * { },#CRLF# target: target,#CRLF# tail: function() { return
- * makeOMInputStreamProxy(target.tail()) }#CRLF# })#CRLF#}#CRLF##CRLF#//
- * Failer (i.e., that which makes things fail) is used to detect (direct
- * ) left recursion and memoize failures#CRLF##CRLF#function Failer() { }
- * #CRLF#Failer.prototype.used = false#CRLF##CRLF#// the OMeta "class" an
- * d basic functionality#CRLF##CRLF#OMeta = {#CRLF# _apply: function(rul
- * e) {#CRLF# var memoRec = this.input.memo[rule]#CRLF# if (memoRec
- * == undefined) {#CRLF# var origInput = this.input,#CRLF#
- * failer = new Failer()#CRLF# this.input.memo[rule] = failer#CR
- * LF# this.input.memo[rule] = memoRec = {ans: this[rule].apply(this
- * ), nextInput: this.input}#CRLF# if (failer.used) {#CRLF# v
- * ar sentinel = this.input#CRLF# while (true) {#CRLF# tr
- * y {#CRLF# this.input = origInput#CRLF# var ans =
- * this[rule].apply(this)#CRLF# if (this.input == sentinel)#C
- * RLF# throw fail#CRLF# memoRec.ans = ans#
- * CRLF# memoRec.nextInput = this.input#CRLF# }#CRLF#
- * catch (f) {#CRLF# if (f != fail)#CRLF#
- * throw f#CRLF# break#CRLF# }#CRLF# }#CRLF
- * # }#CRLF# }#CRLF# else if (memoRec instanceof Failer) {#CRL
- * F# memoRec.used = true#CRLF# throw fail#CRLF# }#CRLF#
- * this.input = memoRec.nextInput#CRLF# return memoRec.ans#CRLF# },#C
- * RLF##CRLF# // note: _applyWithArgs and _superApplyWithArgs are not me
- * moized, so they can't be left-recursive#CRLF# _applyWithArgs: functio
- * n(rule) {#CRLF# for (var idx = arguments.length - 1; idx > 0; idx--
- * )#CRLF# this.input = new OMInputStream(arguments[idx], this.input
- * )#CRLF# return this[rule].apply(this)#CRLF# },#CRLF# _superApplyW
- * ithArgs: function($elf, rule) {#CRLF# for (var idx = arguments.leng
- * th - 1; idx > 1; idx--)#CRLF# $elf.input = new OMInputStream(argu
- * ments[idx], $elf.input)#CRLF# return this[rule].apply($elf)#CRLF#
- * },#CRLF# _pred: function(b) {#CRLF# if (b)#CRLF# return true#
- * CRLF# throw fail#CRLF# },#CRLF# _not: function(x) {#CRLF# var
- * origInput = this.input#CRLF# try { x() }#CRLF# catch (f) {#CRLF#
- * if (f != fail)#CRLF# throw f#CRLF# this.input = orig
- * Input#CRLF# return true#CRLF# }#CRLF# throw fail#CRLF# },#
- * CRLF# _lookahead: function(x) {#CRLF# var origInput = this.input,#
- * CRLF# r = x()#CRLF# this.input = origInput#CRLF# r
- * eturn r#CRLF# },#CRLF# _or: function() {#CRLF# var origInput = th
- * is.input#CRLF# for (var idx = 0; idx < arguments.length; idx++)#CRL
- * F# try { this.input = origInput; return arguments[idx]() }#CRLF#
- * catch (f) {#CRLF# if (f != fail)#CRLF# throw f#CR
- * LF# }#CRLF# throw fail#CRLF# },#CRLF# _many: function(x) {#C
- * RLF# var ans = arguments[1] != undefined ? [arguments[1]] : []#CRLF
- * # while (true) {#CRLF# var origInput = this.input#CRLF# t
- * ry { ans.push(x()) }#CRLF# catch (f) {#CRLF# if (f != fail
- * )#CRLF# throw f#CRLF# this.input = origInput#CRLF#
- * break#CRLF# }#CRLF# }#CRLF# return ans#CRLF# },#CRLF#
- * _many1: function(x) { return this._many(x, x()) },#CRLF# _form: func
- * tion(x) {#CRLF# var v = this._apply("anything")#CRLF# if (!v.isS
- * equenceable)#CRLF# throw fail#CRLF# var origInput = this.input
- * #CRLF# this.input = makeArrayOMInputStream(v, 0)#CRLF# var r = x
- * ()#CRLF# this._apply("end")#CRLF# this.input = origInput#CRLF#
- * return v#CRLF# },#CRLF##CRLF# // some basic rules#CRLF# anything:
- * function() {#CRLF# var r = this.input.head()#CRLF# this.input =
- * this.input.tail()#CRLF# return r#CRLF# },#CRLF# end: function()
- * {#CRLF# var $elf = this#CRLF# return this._not(function() { retu
- * rn $elf._apply("anything") })#CRLF# },#CRLF# pos: function() {#CRLF#
- * return this.input.idx#CRLF# },#CRLF# empty: function() { return
- * true },#CRLF# apply: function() {#CRLF# var r = this._apply("anyth
- * ing")#CRLF# return this._apply(r)#CRLF# },#CRLF# foreign: functio
- * n() {#CRLF# var g = this._apply("anything"),#CRLF# r = t
- * his._apply("anything"),#CRLF# gi = g.delegated({input: makeOMI
- * nputStreamProxy(this.input)})#CRLF# var ans = gi._apply(r)#CRLF#
- * this.input = gi.input.target#CRLF# return ans#CRLF# },#CRLF##CRLF
- * # // some useful "derived" rules#CRLF# exactly: function() {#CRLF#
- * var wanted = this._apply("anything")#CRLF# if (wanted === this._
- * apply("anything"))#CRLF# return wanted#CRLF# throw fail#CRLF#
- * },#CRLF# "true": function() {#CRLF# var r = this._apply("anything
- * ")#CRLF# this._pred(r == true)#CRLF# return r#CRLF# },#CRLF# "
- * false": function() {#CRLF# var r = this._apply("anything")#CRLF#
- * this._pred(r == false)#CRLF# return r#CRLF# },#CRLF# "undefined"
- * : function() {#CRLF# var r = this._apply("anything")#CRLF# this.
- * _pred(r == undefined)#CRLF# return r#CRLF# },#CRLF# number: funct
- * ion() {#CRLF# var r = this._apply("anything")#CRLF# this._pred(r
- * .isNumber())#CRLF# return r#CRLF# },#CRLF# string: function() {#C
- * RLF# var r = this._apply("anything")#CRLF# this._pred(r.isString
- * ())#CRLF# return r#CRLF# },#CRLF# "char": function() {#CRLF# v
- * ar r = this._apply("anything")#CRLF# this._pred(r.isCharacter())#CR
- * LF# return r#CRLF# },#CRLF# space: function() {#CRLF# var r =
- * this._apply("char")#CRLF# this._pred(r.charCodeAt(0) <= 32)#CRLF#
- * return r#CRLF# },#CRLF# spaces: function() {#CRLF# var $elf = t
- * his#CRLF# return this._many(function() { return $elf._apply("space"
- * ) })#CRLF# },#CRLF# digit: function() {#CRLF# var r = this._apply
- * ("char")#CRLF# this._pred(r.isDigit())#CRLF# return r#CRLF# },#
- * CRLF# lower: function() {#CRLF# var r = this._apply("char")#CRLF#
- * this._pred(r.isLower())#CRLF# return r#CRLF# },#CRLF# upper: f
- * unction() {#CRLF# var r = this._apply("char")#CRLF# this._pred(r
- * .isUpper())#CRLF# return r#CRLF# },#CRLF# letter: function() {#CR
- * LF# var $elf = this#CRLF# return this._or(function() { return $e
- * lf._apply("lower") },#CRLF# function() { return $el
- * f._apply("upper") })#CRLF# },#CRLF# letterOrDigit: function() {#CRLF
- * # var $elf = this#CRLF# return this._or(function() { return $elf
- * ._apply("letter") },#CRLF# function() { return $elf
- * ._apply("digit") })#CRLF# },#CRLF# firstAndRest: function() {#CRLF
- * # var $elf = this,#CRLF# first = this._apply("anything"),#C
- * RLF# rest = this._apply("anything")#CRLF# return this._man
- * y(function() { return $elf._apply(rest) }, this._apply(first))#CRLF#
- * },#CRLF# seq: function() {#CRLF# var xs = this._apply("anything")#
- * CRLF# for (var idx = 0; idx < xs.length; idx++)#CRLF# this._ap
- * plyWithArgs("exactly", xs[idx])#CRLF# return xs#CRLF# },#CRLF# no
- * tLast: function() {#CRLF# var $elf = this,#CRLF# rule = this
- * ._apply("anything"),#CRLF# r = this._apply(rule)#CRLF# th
- * is._lookahead(function() { return $elf._apply(rule) })#CRLF# return
- * r#CRLF# },#CRLF##CRLF# initialize: function() { },#CRLF# // match
- * and matchAll are a grammar's "public interface"#CRLF# _genericMatch:
- * function(input, rule, args, matchFailed) {#CRLF# if (args == undefi
- * ned)#CRLF# args = []#CRLF# var realArgs = [rule]#CRLF# for
- * (var idx = 0; idx < args.length; idx++)#CRLF# realArgs.push(args[
- * idx])#CRLF# var m = this.delegated({input: input})#CRLF# m.initi
- * alize()#CRLF# try { return realArgs.length == 1 ? m._apply.call(m,
- * realArgs[0]) : m._applyWithArgs.apply(m, realArgs) }#CRLF# catch (f
- * ) {#CRLF# if (f == fail && matchFailed != undefined) {#CRLF#
- * var input = m.input#CRLF# if (input.idx != undefined) {#CRLF
- * # while (input.tl != undefined && input.tl.idx != undefined)#
- * CRLF# input = input.tl#CRLF# input.idx--#CRLF#
- * }#CRLF# return matchFailed(m, input.idx)#CRLF# }#CRLF#
- * throw f#CRLF# }#CRLF# },#CRLF# match: function(obj, rule, a
- * rgs, matchFailed) {#CRLF# return this._genericMatch([obj].toOMInput
- * Stream(), rule, args, matchFailed)#CRLF# },#CRLF# matchAll: funct
- * ion(listyObj, rule, args, matchFailed) {#CRLF# return this._generic
- * Match(listyObj.toOMInputStream(), rule, args, matchFailed)#CRLF# }#CR
- * LF#}#CRLF##CRLF##CRLF#// Copyright (c) 2007, 2008 Alessandro Warth <aw
- * arth@cs.ucla.edu>#CRLF#Parser = OMeta.delegated({#CRLF# listOf: funct
- * ion() {#CRLF# var $elf = this,#CRLF# rule = this._apply("a
- * nything"),#CRLF# delim = this._apply("anything")#CRLF# retur
- * n this._or(function() {#CRLF# var r = $elf._apply
- * (rule)#CRLF# return $elf._many(function() {#CRLF#
- * $elf._applyWithArgs("token",
- * delim)#CRLF# return $elf._ap
- * ply(rule)#CRLF# },#CRLF#
- * r)#CRLF# },#CRLF#
- * function() { return [] })#CRLF# },#CRLF# token: f
- * unction() {#CRLF# var cs = this._apply("anything")#CRLF# this._a
- * pply("spaces")#CRLF# return this._applyWithArgs("seq", cs)#CRLF# }
- * #CRLF#})#CRLF##CRLF##CRLF#{BSJSParser=Parser.delegated({"fromTo":funct
- * ion(){var $elf=this,x,y;return (function(){x=$elf._apply("anything");y
- * =$elf._apply("anything");$elf._applyWithArgs("seq",x);#CRLF#$elf._many
- * (function(){#CRLF#return (function(){$elf._not(function(){#CRLF#return
- * $elf._applyWithArgs("seq",y)});return $elf._apply("char")})()});retur
- * n $elf._applyWithArgs("seq",y)})()},"space":function(){var $elf=this;r
- * eturn $elf._or((function(){#CRLF#return Parser._superApplyWithArgs($el
- * f,"space")}),(function(){#CRLF#return $elf._applyWithArgs("fromTo","//
- * ","\n")}),(function(){#CRLF#return $elf._applyWithArgs("fromTo","/*","
- * */")}))},"nameFirst":function(){var $elf=this;return $elf._or((functio
- * n(){#CRLF#return $elf._apply("letter")}),(function(){#CRLF#return $elf
- * ._applyWithArgs("exactly","$")}),(function(){#CRLF#return $elf._applyW
- * ithArgs("exactly","_")}))},"nameRest":function(){var $elf=this;return
- * $elf._or((function(){#CRLF#return $elf._apply("nameFirst")}),(function
- * (){#CRLF#return $elf._apply("digit")}))},"iName":function(){var $elf=t
- * his,r;#CRLF# return (function(){r=$elf._applyWithArgs("firstA
- * ndRest","nameFirst","nameRest");return r.join("")})()},"isKeyword":fun
- * ction(){var $elf=this,x;return (function(){x=$elf._apply("anything");r
- * eturn $elf._pred(BSJSParser._isKeyword(x))})()},"name":function(){var
- * $elf=this,n;return (function(){n=$elf._apply("iName");$elf._not(functi
- * on(){#CRLF#return $elf._applyWithArgs("isKeyword",n)});return ["name",
- * ((n == "self")?"$elf":n)]})()},"keyword":function(){var $elf=this,k;re
- * turn (function(){k=$elf._apply("iName");$elf._applyWithArgs("isKeyword
- * ",k);return [k,k]})()},"number":function(){var $elf=this,ws,fs;return
- * (function(){ws=$elf._many1(function(){#CRLF#return $elf._apply("digit"
- * )});fs=$elf._or((function(){#CRLF#return (function(){$elf._applyWithAr
- * gs("exactly",".");return $elf._many1(function(){#CRLF#return $elf._app
- * ly("digit")})})()}),(function(){#CRLF#return (function(){$elf._apply("
- * empty");return []})()}));return ["number",parseFloat(((ws.join("") + "
- * .") + fs.join("")))]})()},"escapeChar":function(){var $elf=this,c;retu
- * rn (function(){$elf._applyWithArgs("exactly","\\");c=$elf._apply("char
- * ");return unescape(("\\" + c))})()},"str":function(){var $elf=this,cs,
- * cs,cs,n;return $elf._or((function(){#CRLF# return (
- * function(){$elf._applyWithArgs("seq","\"\"\"");cs=$elf._many(function(
- * ){#CRLF#return $elf._or((function(){#CRLF#return $elf._apply("escapeCh
- * ar")}),(function(){#CRLF#return (function(){$elf._not(function(){#CRLF
- * #return $elf._applyWithArgs("seq","\"\"\"")});return $elf._apply("char
- * ")})()}))});$elf._applyWithArgs("seq","\"\"\"");return ["string",cs.jo
- * in("")]})()}),(function(){#CRLF#return (function(){$elf._applyWithArgs
- * ("exactly","\'");cs=$elf._many(function(){#CRLF#return $elf._or((funct
- * ion(){#CRLF#return $elf._apply("escapeChar")}),(function(){#CRLF#retur
- * n (function(){$elf._not(function(){#CRLF#return $elf._applyWithArgs("e
- * xactly","\'")});return $elf._apply("char")})()}))});$elf._applyWithArg
- * s("exactly","\'");return ["string",cs.join("")]})()}),(function(){#CRL
- * F#return (function(){$elf._applyWithArgs("exactly","\"");cs=$elf._many
- * (function(){#CRLF#return $elf._or((function(){#CRLF#return $elf._apply
- * ("escapeChar")}),(function(){#CRLF#return (function(){$elf._not(functi
- * on(){#CRLF#return $elf._applyWithArgs("exactly","\"")});return $elf._a
- * pply("char")})()}))});$elf._applyWithArgs("exactly","\"");return ["str
- * ing",cs.join("")]})()}),(function(){#CRLF#return (function(){$elf._or(
- * (function(){#CRLF#return $elf._applyWithArgs("exactly","#")}),(functio
- * n(){#CRLF#return $elf._applyWithArgs("exactly","`")}));n=$elf._apply("
- * iName");return ["string",n]})()}))},"special":function(){var $elf=this
- * ,s;return (function(){s=$elf._or((function(){#CRLF#return $elf._applyW
- * ithArgs("exactly","(")}),(function(){#CRLF#return $elf._applyWithArgs(
- * "exactly",")")}),(function(){#CRLF#return $elf._applyWithArgs("exactly
- * ","{")}),(function(){#CRLF#return $elf._applyWithArgs("exactly","}")})
- * ,(function(){#CRLF#return $elf._applyWithArgs("exactly","[")}),(functi
- * on(){#CRLF#return $elf._applyWithArgs("exactly","]")}),(function(){#CR
- * LF#return $elf._applyWithArgs("exactly",",")}),(function(){#CRLF#retur
- * n $elf._applyWithArgs("exactly",";")}),(function(){#CRLF#return $elf._
- * applyWithArgs("exactly","?")}),(function(){#CRLF#return $elf._applyWit
- * hArgs("exactly",":")}),(function(){#CRLF#return $elf._applyWithArgs("s
- * eq","!==")}),(function(){#CRLF#return $elf._applyWithArgs("seq","!=")}
- * ),(function(){#CRLF#return $elf._applyWithArgs("seq","===")}),(functio
- * n(){#CRLF#return $elf._applyWithArgs("seq","==")}),(function(){#CRLF#r
- * eturn $elf._applyWithArgs("seq","=")}),(function(){#CRLF#return $elf._
- * applyWithArgs("seq",">=")}),(function(){#CRLF#return $elf._applyWithAr
- * gs("exactly",">")}),(function(){#CRLF#return $elf._applyWithArgs("seq"
- * ,"<=")}),(function(){#CRLF#return $elf._applyWithArgs("exactly","<")})
- * ,(function(){#CRLF#return $elf._applyWithArgs("seq","++")}),(function(
- * ){#CRLF#return $elf._applyWithArgs("seq","+=")}),(function(){#CRLF#ret
- * urn $elf._applyWithArgs("exactly","+")}),(function(){#CRLF#return $elf
- * ._applyWithArgs("seq","--")}),(function(){#CRLF#return $elf._applyWith
- * Args("seq","-=")}),(function(){#CRLF#return $elf._applyWithArgs("exact
- * ly","-")}),(function(){#CRLF#return $elf._applyWithArgs("seq","*=")}),
- * (function(){#CRLF#return $elf._applyWithArgs("exactly","*")}),(functio
- * n(){#CRLF#return $elf._applyWithArgs("seq","/=")}),(function(){#CRLF#r
- * eturn $elf._applyWithArgs("exactly","/")}),(function(){#CRLF#return $e
- * lf._applyWithArgs("seq","%=")}),(function(){#CRLF#return $elf._applyWi
- * thArgs("exactly","%")}),(function(){#CRLF#return $elf._applyWithArgs("
- * seq","&&=")}),(function(){#CRLF#return $elf._applyWithArgs("seq","&&")
- * }),(function(){#CRLF#return $elf._applyWithArgs("seq","||=")}),(functi
- * on(){#CRLF#return $elf._applyWithArgs("seq","||")}),(function(){#CRLF#
- * return $elf._applyWithArgs("exactly",".")}),(function(){#CRLF#return $
- * elf._applyWithArgs("exactly","!")}));#CRLF# return
- * [s,s]})()},"tok":function(){var $elf=this;return (function(){$elf._app
- * ly("spaces");return $elf._or((function(){#CRLF#return $elf._apply("nam
- * e")}),(function(){#CRLF#return $elf._apply("keyword")}),(function(){#C
- * RLF#return $elf._apply("number")}),(function(){#CRLF#return $elf._appl
- * y("str")}),(function(){#CRLF#return $elf._apply("special")}))})()},"to
- * ks":function(){var $elf=this,ts;return (function(){ts=$elf._many(funct
- * ion(){#CRLF#return $elf._apply("token")});$elf._apply("spaces");$elf._
- * apply("end");return ts})()},"token":function(){var $elf=this,tt,t;retu
- * rn (function(){tt=$elf._apply("anything");t=$elf._apply("tok");$elf._p
- * red((t[(0)] == tt));return t[(1)]})()},"spacesNoNl":function(){var $el
- * f=this;return $elf._many(function(){#CRLF#return (function(){$elf._not
- * (function(){#CRLF#return $elf._applyWithArgs("exactly","\n")});return
- * $elf._apply("space")})()})},"expr":function(){var $elf=this,e,t,f,rhs,
- * rhs,rhs,rhs,rhs,rhs,rhs,rhs;return (function(){e=$elf._apply("orExpr")
- * ;return $elf._or((function(){#CRLF#return (function(){$elf._applyWithA
- * rgs("token","?");t=$elf._apply("expr");$elf._applyWithArgs("token",":"
- * );f=$elf._apply("expr");return ["condExpr",e,t,f]})()}),(function(){#C
- * RLF#return (function(){$elf._applyWithArgs("token","=");rhs=$elf._appl
- * y("expr");return ["set",e,rhs]})()}),(function(){#CRLF#return (functio
- * n(){$elf._applyWithArgs("token","+=");rhs=$elf._apply("expr");return [
- * "mset",e,"+",rhs]})()}),(function(){#CRLF#return (function(){$elf._app
- * lyWithArgs("token","-=");rhs=$elf._apply("expr");return ["mset",e,"-",
- * rhs]})()}),(function(){#CRLF#return (function(){$elf._applyWithArgs("t
- * oken","*=");rhs=$elf._apply("expr");return ["mset",e,"*",rhs]})()}),(f
- * unction(){#CRLF#return (function(){$elf._applyWithArgs("token","/=");r
- * hs=$elf._apply("expr");return ["mset",e,"/",rhs]})()}),(function(){#CR
- * LF#return (function(){$elf._applyWithArgs("token","%=");rhs=$elf._appl
- * y("expr");return ["mset",e,"%",rhs]})()}),(function(){#CRLF#return (fu
- * nction(){$elf._applyWithArgs("token","&&=");rhs=$elf._apply("expr");re
- * turn ["mset",e,"&&",rhs]})()}),(function(){#CRLF#return (function(){$e
- * lf._applyWithArgs("token","||=");rhs=$elf._apply("expr");return ["mset
- * ",e,"||",rhs]})()}),(function(){#CRLF#return (function(){$elf._apply("
- * empty");return e})()}))})()},"orExpr":function(){var $elf=this,x,y;ret
- * urn $elf._or((function(){#CRLF#return (function(){x=$elf._apply("orExp
- * r");$elf._applyWithArgs("token","||");y=$elf._apply("andExpr");return
- * ["binop","||",x,y]})()}),(function(){#CRLF#return $elf._apply("andExpr
- * ")}))},"andExpr":function(){var $elf=this,x,y;return $elf._or((functio
- * n(){#CRLF# return (function(){x=$elf._apply("andExp
- * r");$elf._applyWithArgs("token","&&");y=$elf._apply("eqExpr");return [
- * "binop","&&",x,y]})()}),(function(){#CRLF#return $elf._apply("eqExpr")
- * }))},"eqExpr":function(){var $elf=this,x,y,y,y,y;return $elf._or((func
- * tion(){#CRLF#return (function(){x=$elf._apply("eqExpr");return $elf._o
- * r((function(){#CRLF#return (function(){$elf._applyWithArgs("token","==
- * ");y=$elf._apply("relExpr");return ["binop","==",x,y]})()}),(function(
- * ){#CRLF#return (function(){$elf._applyWithArgs("token","!=");y=$elf._a
- * pply("relExpr");return ["binop","!=",x,y]})()}),(function(){#CRLF#retu
- * rn (function(){$elf._applyWithArgs("token","===");y=$elf._apply("relEx
- * pr");return ["binop","===",x,y]})()}),(function(){#CRLF#return (functi
- * on(){$elf._applyWithArgs("token","!==");y=$elf._apply("relExpr");retur
- * n ["binop","!==",x,y]})()}))})()}),(function(){#CRLF#return $elf._appl
- * y("relExpr")}))},"relExpr":function(){var $elf=this,x,y,y,y,y,y;return
- * $elf._or((function(){#CRLF#return (function(){x=$elf._apply("relExpr"
- * );return $elf._or((function(){#CRLF#return (function(){$elf._applyWith
- * Args("token",">");y=$elf._apply("addExpr");return ["binop",">",x,y]})(
- * )}),(function(){#CRLF#return (function(){$elf._applyWithArgs("token","
- * >=");y=$elf._apply("addExpr");return ["binop",">=",x,y]})()}),(functio
- * n(){#CRLF#return (function(){$elf._applyWithArgs("token","<");y=$elf._
- * apply("addExpr");return ["binop","<",x,y]})()}),(function(){#CRLF#retu
- * rn (function(){$elf._applyWithArgs("token","<=");y=$elf._apply("addExp
- * r");return ["binop","<=",x,y]})()}),(function(){#CRLF#return (function
- * (){$elf._applyWithArgs("token","instanceof");y=$elf._apply("addExpr");
- * return ["binop","instanceof",x,y]})()}))})()}),(function(){#CRLF#retur
- * n $elf._apply("addExpr")}))},"addExpr":function(){var $elf=this,x,y,x,
- * y;return $elf._or((function(){#CRLF#return (function(){x=$elf._apply("
- * addExpr");$elf._applyWithArgs("token","+");y=$elf._apply("mulExpr");re
- * turn ["binop","+",x,y]})()}),(function(){#CRLF#return (function(){x=$e
- * lf._apply("addExpr");$elf._applyWithArgs("token","-");y=$elf._apply("m
- * ulExpr");return ["binop","-",x,y]})()}),(function(){#CRLF#return $elf.
- * _apply("mulExpr")}))},"mulExpr":function(){var $elf=this,x,y,x,y,x,y;r
- * eturn $elf._or((function(){#CRLF#return (function(){x=$elf._apply("mul
- * Expr");$elf._applyWithArgs("token","*");y=$elf._apply("unary");return
- * ["binop","*",x,y]})()}),(function(){#CRLF#return (function(){x=$elf._a
- * pply("mulExpr");$elf._applyWithArgs("token","/");y=$elf._apply("unary"
- * );return ["binop","/",x,y]})()}),(function(){#CRLF#return (function(){
- * x=$elf._apply("mulExpr");$elf._applyWithArgs("token","%");y=$elf._appl
- * y("unary");return ["binop","%",x,y]})()}),(function(){#CRLF#return $el
- * f._apply("unary")}))},"unary":function(){var $elf=this,p,p,p,p,p;retur
- * n $elf._or((function(){#CRLF#return (function(){$elf._applyWithArgs("t
- * oken","-");p=$elf._apply("postfix");return ["unop","-",p]})()}),(funct
- * ion(){#CRLF#return (function(){$elf._applyWithArgs("token","+");p=$elf
- * ._apply("postfix");return p})()}),(function(){#CRLF#return (function()
- * {$elf._applyWithArgs("token","++");p=$elf._apply("postfix");return ["p
- * reop","++",p]})()}),(function(){#CRLF#return (function(){$elf._applyWi
- * thArgs("token","--");p=$elf._apply("postfix");return ["preop","--",p]}
- * )()}),(function(){#CRLF#return (function(){$elf._applyWithArgs("token"
- * ,"!");p=$elf._apply("unary");return ["unop","!",p]})()}),(function(){#
- * CRLF#return $elf._apply("postfix")}))},"postfix":function(){var $elf=t
- * his,p;return (function(){p=$elf._apply("primExpr");return $elf._or((fu
- * nction(){#CRLF#return (function(){$elf._apply("spacesNoNl");$elf._appl
- * yWithArgs("token","++");return ["postop","++",p]})()}),(function(){#CR
- * LF#return (function(){$elf._apply("spacesNoNl");$elf._applyWithArgs("t
- * oken","--");return ["postop","--",p]})()}),(function(){#CRLF#return (f
- * unction(){$elf._apply("empty");return p})()}))})()},"primExpr":functio
- * n(){var $elf=this,p,i,m,as,f,as;return $elf._or((function(){#CRLF#retu
- * rn (function(){p=$elf._apply("primExpr");return $elf._or((function(){#
- * CRLF#return (function(){$elf._applyWithArgs("token","[");i=$elf._apply
- * ("expr");$elf._applyWithArgs("token","]");return ["getp",i,p]})()}),(f
- * unction(){#CRLF#return (function(){$elf._applyWithArgs("token",".");m=
- * $elf._applyWithArgs("token","name");$elf._applyWithArgs("token","(");a
- * s=$elf._applyWithArgs("listOf","expr",",");$elf._applyWithArgs("token"
- * ,")");return ["send",m,p].concat(as)})()}),(function(){#CRLF#return (f
- * unction(){$elf._applyWithArgs("token",".");f=$elf._applyWithArgs("toke
- * n","name");return ["getp",["string",f],p]})()}),(function(){#CRLF#retu
- * rn (function(){$elf._applyWithArgs("token","(");as=$elf._applyWithArgs
- * ("listOf","expr",",");$elf._applyWithArgs("token",")");return ["call",
- * p].concat(as)})()}))})()}),(function(){#CRLF#return $elf._apply("primE
- * xprHd")}))},"primExprHd":function(){var $elf=this,e,n,n,s,n,as,es;retu
- * rn $elf._or((function(){#CRLF#return (function(){$elf._applyWithArgs("
- * token","(");e=$elf._apply("expr");$elf._applyWithArgs("token",")");ret
- * urn e})()}),(function(){#CRLF#return (function(){$elf._applyWithArgs("
- * token","this");return ["this"]})()}),(function(){#CRLF#return (functio
- * n(){n=$elf._applyWithArgs("token","name");return ["get",n]})()}),(func
- * tion(){#CRLF#return (function(){n=$elf._applyWithArgs("token","number"
- * );return ["number",n]})()}),(function(){#CRLF#return (function(){s=$el
- * f._applyWithArgs("token","string");return ["string",s]})()}),(function
- * (){#CRLF#return (function(){$elf._applyWithArgs("token","function");re
- * turn $elf._apply("funcRest")})()}),(function(){#CRLF#return (function(
- * ){$elf._applyWithArgs("token","new");n=$elf._applyWithArgs("token","na
- * me");$elf._applyWithArgs("token","(");as=$elf._applyWithArgs("listOf",
- * "expr",",");$elf._applyWithArgs("token",")");return ["new",n].concat(a
- * s)})()}),(function(){#CRLF#return (function(){$elf._applyWithArgs("tok
- * en","[");es=$elf._applyWithArgs("listOf","expr",",");$elf._applyWithAr
- * gs("token","]");return ["arr"].concat(es)})()}),(function(){#CRLF#retu
- * rn $elf._apply("json")}))},"json":function(){var $elf=this,bs;return (
- * function(){$elf._applyWithArgs("token","{");bs=$elf._applyWithArgs("li
- * stOf","jsonBinding",",");$elf._applyWithArgs("token","}");return ["jso
- * n"].concat(bs)})()},"jsonBinding":function(){var $elf=this,n,v;return
- * (function(){n=$elf._apply("jsonPropName");$elf._applyWithArgs("token",
- * ":");v=$elf._apply("expr");return ["binding",n,v]})()},"jsonPropName":
- * function(){var $elf=this;return $elf._or((function(){#CRLF#return $elf
- * ._applyWithArgs("token","name")}),(function(){#CRLF#return $elf._apply
- * WithArgs("token","number")}),(function(){#CRLF#return $elf._applyWithA
- * rgs("token","string")}))},"formal":function(){var $elf=this;return (fu
- * nction(){$elf._apply("spaces");return $elf._applyWithArgs("token","nam
- * e")})()},"funcRest":function(){var $elf=this,fs,body;return (function(
- * ){$elf._applyWithArgs("token","(");fs=$elf._applyWithArgs("listOf","fo
- * rmal",",");$elf._applyWithArgs("token",")");$elf._applyWithArgs("token
- * ","{");body=$elf._apply("srcElems");$elf._applyWithArgs("token","}");r
- * eturn ["func",fs,body]})()},"sc":function(){var $elf=this;return $elf.
- * _or((function(){#CRLF#return (function(){$elf._apply("spacesNoNl");ret
- * urn $elf._or((function(){#CRLF#return $elf._applyWithArgs("exactly","\
- * n")}),(function(){#CRLF#return $elf._lookahead(function(){#CRLF#return
- * $elf._applyWithArgs("exactly","}")})}),(function(){#CRLF#return $elf.
- * _apply("end")}))})()}),(function(){#CRLF#return $elf._applyWithArgs("t
- * oken",";")}))},"binding":function(){var $elf=this,n,v;return (function
- * (){n=$elf._applyWithArgs("token","name");v=$elf._or((function(){#CRLF#
- * return (function(){$elf._applyWithArgs("token","=");return $elf._apply
- * ("expr")})()}),(function(){#CRLF#return (function(){$elf._apply("empty
- * ");return ["get","undefined"]})()}));return ["var",n,v]})()},"block":f
- * unction(){var $elf=this,ss;return (function(){$elf._applyWithArgs("tok
- * en","{");ss=$elf._apply("srcElems");$elf._applyWithArgs("token","}");r
- * eturn ss})()},"stmt":function(){var $elf=this,bs,c,t,f,c,s,s,c,i,c,u,s
- * ,n,v,e,s,e,c,cs,cs,cs,e,t,e,c,f,e,x,s,e;return $elf._or((function(){#C
- * RLF#return $elf._apply("block")}),(function(){#CRLF#return (function()
- * {$elf._applyWithArgs("token","var");bs=$elf._applyWithArgs("listOf","b
- * inding",",");$elf._apply("sc");return ["begin"].concat(bs)})()}),(func
- * tion(){#CRLF#return (function(){$elf._applyWithArgs("token","if");$elf
- * ._applyWithArgs("token","(");c=$elf._apply("expr");$elf._applyWithArgs
- * ("token",")");t=$elf._apply("stmt");f=$elf._or((function(){#CRLF#retur
- * n (function(){$elf._applyWithArgs("token","else");return $elf._apply("
- * stmt")})()}),(function(){#CRLF#return (function(){$elf._apply("empty")
- * ;return ["get","undefined"]})()}));return ["if",c,t,f]})()}),(function
- * (){#CRLF#return (function(){$elf._applyWithArgs("token","while");$elf.
- * _applyWithArgs("token","(");c=$elf._apply("expr");$elf._applyWithArgs(
- * "token",")");s=$elf._apply("stmt");return ["while",c,s]})()}),(functio
- * n(){#CRLF#return (function(){$elf._applyWithArgs("token","do");s=$elf.
- * _apply("stmt");$elf._applyWithArgs("token","while");$elf._applyWithArg
- * s("token","(");c=$elf._apply("expr");$elf._applyWithArgs("token",")");
- * $elf._apply("sc");return ["doWhile",s,c]})()}),(function(){#CRLF#retur
- * n (function(){$elf._applyWithArgs("token","for");$elf._applyWithArgs("
- * token","(");i=$elf._or((function(){#CRLF#return (function(){$elf._appl
- * yWithArgs("token","var");return $elf._apply("binding")})()}),(function
- * (){#CRLF#return $elf._apply("expr")}),(function(){#CRLF#return (functi
- * on(){$elf._apply("empty");return ["get","undefined"]})()}));$elf._appl
- * yWithArgs("token",";");c=$elf._or((function(){#CRLF#return $elf._apply
- * ("expr")}),(function(){#CRLF#return (function(){$elf._apply("empty");r
- * eturn ["get","true"]})()}));$elf._applyWithArgs("token",";");u=$elf._o
- * r((function(){#CRLF#return $elf._apply("expr")}),(function(){#CRLF#ret
- * urn (function(){$elf._apply("empty");return ["get","undefined"]})()}))
- * ;$elf._applyWithArgs("token",")");s=$elf._apply("stmt");return ["for",
- * i,c,u,s]})()}),(function(){#CRLF#return (function(){$elf._applyWithArg
- * s("token","for");$elf._applyWithArgs("token","(");v=$elf._or((function
- * (){#CRLF#return (function(){$elf._applyWithArgs("token","var");n=$elf.
- * _applyWithArgs("token","name");return ["var",n,["get","undefined"]]})(
- * )}),(function(){#CRLF#return $elf._apply("expr")}));$elf._applyWithArg
- * s("token","in");e=$elf._apply("expr");$elf._applyWithArgs("token",")")
- * ;s=$elf._apply("stmt");return ["forIn",v,e,s]})()}),(function(){#CRLF#
- * return (function(){$elf._applyWithArgs("token","switch");$elf._applyWi
- * thArgs("token","(");e=$elf._apply("expr");$elf._applyWithArgs("token",
- * ")");$elf._applyWithArgs("token","{");cs=$elf._many(function(){#CRLF#r
- * eturn $elf._or((function(){#CRLF#return (function(){$elf._applyWithArg
- * s("token","case");c=$elf._apply("expr");$elf._applyWithArgs("token",":
- * ");cs=$elf._apply("srcElems");return ["case",c,cs]})()}),(function(){#
- * CRLF#return (function(){$elf._applyWithArgs("token","default");$elf._a
- * pplyWithArgs("token",":");cs=$elf._apply("srcElems");return ["default"
- * ,cs]})()}))});$elf._applyWithArgs("token","}");return ["switch",e].con
- * cat(cs)})()}),(function(){#CRLF#return (function(){$elf._applyWithArgs
- * ("token","break");$elf._apply("sc");return ["break"]})()}),(function()
- * {#CRLF#return (function(){$elf._applyWithArgs("token","continue");$elf
- * ._apply("sc");#CRLF#return ["continue"]})()}),(function(){#CRLF#return
- * (function(){$elf._applyWithArgs("token","throw");$elf._apply("spacesN
- * oNl");e=$elf._apply("expr");$elf._apply("sc");return ["throw",e]})()})
- * ,(function(){#CRLF#return (function(){$elf._applyWithArgs("token","try
- * ");t=$elf._apply("block");$elf._applyWithArgs("token","catch");$elf._a
- * pplyWithArgs("token","(");e=$elf._applyWithArgs("token","name");$elf._
- * applyWithArgs("token",")");c=$elf._apply("block");f=$elf._or((function
- * (){#CRLF#return (function(){$elf._applyWithArgs("token","finally");ret
- * urn $elf._apply("block")})()}),(function(){#CRLF#return (function(){$e
- * lf._apply("empty");return ["get","undefined"]})()}));return ["try",t,e
- * ,c,f]})()}),(function(){#CRLF#return (function(){$elf._applyWithArgs("
- * token","return");e=$elf._or((function(){#CRLF#return $elf._apply("expr
- * ")}),(function(){#CRLF#return (function(){$elf._apply("empty");return
- * ["get","undefined"]})()}));$elf._apply("sc");return ["return",e]})()})
- * ,(function(){#CRLF#return (function(){$elf._applyWithArgs("token","wit
- * h");$elf._applyWithArgs("token","(");x=$elf._apply("expr");$elf._apply
- * WithArgs("token",")");s=$elf._apply("stmt");return ["with",x,s]})()}),
- * (function(){#CRLF#return (function(){e=$elf._apply("expr");$elf._apply
- * ("sc");return e})()}),(function(){#CRLF#return (function(){$elf._apply
- * WithArgs("token",";");return ["get","undefined"]})()}))},"srcElem":fun
- * ction(){var $elf=this,n,f;return $elf._or((function(){#CRLF#return (fu
- * nction(){$elf._applyWithArgs("token","function");n=$elf._applyWithArgs
- * ("token","name");f=$elf._apply("funcRest");return ["var",n,f]})()}),(f
- * unction(){#CRLF#return $elf._apply("stmt")}))},"srcElems":function(){v
- * ar $elf=this,ss;return (function(){ss=$elf._many(function(){#CRLF#retu
- * rn $elf._apply("srcElem")});return ["begin"].concat(ss)})()},"topLevel
- * ":function(){var $elf=this,r;return (function(){r=$elf._apply("srcElem
- * s");$elf._apply("spaces");$elf._apply("end");return r})()},"curlySemAc
- * tion":function(){var $elf=this,s,ss,r,r;return $elf._or((function(){#C
- * RLF#return (function(){$elf._applyWithArgs("token","{");ss=$elf._many1
- * (function(){#CRLF#return (function(){s=$elf._apply("srcElem");$elf._lo
- * okahead(function(){#CRLF#return $elf._apply("srcElem")});return s})()}
- * );r=$elf._apply("expr");$elf._apply("sc");$elf._applyWithArgs("token",
- * "}");$elf._apply("spaces");return (function (){ss.push(["return",r]);r
- * eturn ["call",["func",[],["begin"].concat(ss)]]})()})()}),(function(){
- * #CRLF#return (function(){$elf._applyWithArgs("token","{");r=$elf._appl
- * y("expr");$elf._applyWithArgs("token","}");$elf._apply("spaces");retur
- * n r})()}))},"semAction":function(){var $elf=this,r;return $elf._or((fu
- * nction(){#CRLF#return $elf._apply("curlySemAction")}),(function(){#CRL
- * F#return (function(){r=$elf._apply("primExpr");$elf._apply("spaces");r
- * eturn r})()}))}});BSJSParser["keywords"]=({});keywords=["break","case"
- * ,"catch","continue","default","delete","do","else","finally","for","fu
- * nction","if","in","instanceof","new","return","switch","this","throw",
- * "try","typeof","var","void","while","with","ometa"];for(var idx=(0);(i
- * dx < keywords["length"]);idx++){BSJSParser["keywords"][keywords[idx]]=
- * true}BSJSParser["_isKeyword"]=(function (k){#CRLF#return (this["keywor
- * ds"].hasProperty(k) && (!Object["prototype"].hasProperty(k)))});BSJSTr
- * anslator=OMeta.delegated({"trans":function(){var $elf=this,t,ans;retur
- * n (function(){$elf._form(function(){#CRLF#return (function(){t=$elf._a
- * pply("anything");return ans=$elf._applyWithArgs("apply",t)})()});retur
- * n ans})()},"curlyTrans":function(){var $elf=this,r,rs,r;return $elf._o
- * r((function(){#CRLF#return (function(){$elf._form(function(){#CRLF#ret
- * urn (function(){$elf._applyWithArgs("exactly","begin");return r=$elf._
- * apply("curlyTrans")})()});return r})()}),(function(){#CRLF#return (fun
- * ction(){$elf._form(function(){#CRLF#return (function(){$elf._applyWith
- * Args("exactly","begin");return rs=$elf._many(function(){#CRLF#return $
- * elf._apply("trans")})})()});return (("{" + rs.join(";")) + "}")})()}),
- * (function(){#CRLF#return (function(){r=$elf._apply("trans");return (("
- * {" + r) + "}")})()}))},"this":function(){var $elf=this;return "this"},
- * "break":function(){var $elf=this;return "break"},"continue":function()
- * {var $elf=this;return "continue"},"number":function(){var $elf=this,n;
- * return (function(){n=$elf._apply("anything");return (("(" + n) + ")")}
- * )()},"string":function(){var $elf=this,s;return (function(){s=$elf._ap
- * ply("anything");return s.toProgramString()})()},"arr":function(){var $
- * elf=this,xs;return (function(){xs=$elf._many(function(){#CRLF#return $
- * elf._apply("trans")});return (("[" + xs.join(",")) + "]")})()},"unop":
- * function(){var $elf=this,op,x;return (function(){op=$elf._apply("anyth
- * ing");x=$elf._apply("trans");return ((("(" + op) + x) + ")")})()},"get
- * p":function(){var $elf=this,fd,x;return (function(){fd=$elf._apply("tr
- * ans");x=$elf._apply("trans");return (((x + "[") + fd) + "]")})()},"get
- * ":function(){var $elf=this,x;return (function(){x=$elf._apply("anythin
- * g");return x})()},"set":function(){var $elf=this,lhs,rhs;return (funct
- * ion(){lhs=$elf._apply("trans");rhs=$elf._apply("trans");return ((lhs +
- * "=") + rhs)})()},"mset":function(){var $elf=this,lhs,op,rhs;return (f
- * unction(){lhs=$elf._apply("trans");op=$elf._apply("anything");rhs=$elf
- * ._apply("trans");return (((lhs + op) + "=") + rhs)})()},"binop":functi
- * on(){var $elf=this,op,x,y;return (function(){op=$elf._apply("anything"
- * );x=$elf._apply("trans");y=$elf._apply("trans");return (((((("(" + x)
- * + " ") + op) + " ") + y) + ")")})()},"preop":function(){var $elf=this,
- * op,x;return (function(){op=$elf._apply("anything");x=$elf._apply("tran
- * s");return (op + x)})()},"postop":function(){var $elf=this,op,x;return
- * (function(){op=$elf._apply("anything");x=$elf._apply("trans");return
- * (x + op)})()},"return":function(){var $elf=this,x;return (function(){x
- * =$elf._apply("trans");return ("return " + x)})()},"with":function(){va
- * r $elf=this,x,s;return (function(){x=$elf._apply("trans");s=$elf._appl
- * y("curlyTrans");return ((("with(" + x) + ")") + s)})()},"if":function(
- * ){var $elf=this,cond,t,e;return (function(){cond=$elf._apply("trans");
- * t=$elf._apply("curlyTrans");e=$elf._apply("curlyTrans");return ((((("i
- * f(" + cond) + ")") + t) + "else") + e)})()},"condExpr":function(){var
- * $elf=this,cond,t,e;return (function(){cond=$elf._apply("trans");t=$elf
- * ._apply("trans");e=$elf._apply("trans");return (((((("(" + cond) + "?"
- * ) + t) + ":") + e) + ")")})()},"while":function(){var $elf=this,cond,b
- * ody;return (function(){cond=$elf._apply("trans");body=$elf._apply("cur
- * lyTrans");return ((("while(" + cond) + ")") + body)})()},"doWhile":fun
- * ction(){var $elf=this,body,cond;return (function(){body=$elf._apply("c
- * urlyTrans");cond=$elf._apply("trans");return (((("do" + body) + "while
- * (") + cond) + ")")})()},"for":function(){var $elf=this,init,cond,upd,b
- * ody;return (function(){init=$elf._apply("trans");cond=$elf._apply("tra
- * ns");upd=$elf._apply("trans");body=$elf._apply("curlyTrans");return ((
- * ((((("for(" + init) + ";") + cond) + ";") + upd) + ")") + body)})()},"
- * forIn":function(){var $elf=this,x,arr,body;return (function(){x=$elf._
- * apply("trans");arr=$elf._apply("trans");body=$elf._apply("curlyTrans")
- * ;return ((((("for(" + x) + " in ") + arr) + ")") + body)})()},"begin":
- * function(){var $elf=this,x,x,xs;return $elf._or((function(){#CRLF#retu
- * rn (function(){x=$elf._apply("trans");$elf._apply("end");return x})()}
- * ),(function(){#CRLF#return (function(){xs=$elf._many(function(){#CRLF#
- * return (function(){x=$elf._apply("trans");return $elf._or((function(){
- * #CRLF#return (function(){$elf._or((function(){#CRLF#return $elf._pred(
- * (x[(x["length"] - (1))] == "}"))}),(function(){#CRLF#return $elf._appl
- * y("end")}));return x})()}),(function(){#CRLF#return (function(){$elf._
- * apply("empty");return (x + ";")})()}))})()});return (("{" + xs.join(""
- * )) + "}")})()}))},"func":function(){var $elf=this,args,body;return (fu
- * nction(){args=$elf._apply("anything");body=$elf._apply("curlyTrans");r
- * eturn (((("(function (" + args.join(",")) + ")") + body) + ")")})()},"
- * call":function(){var $elf=this,fn,args;return (function(){fn=$elf._app
- * ly("trans");args=$elf._many(function(){#CRLF#return $elf._apply("trans
- * ")});return (((fn + "(") + args.join(",")) + ")")})()},"send":function
- * (){var $elf=this,msg,recv,args;return (function(){msg=$elf._apply("any
- * thing");recv=$elf._apply("trans");args=$elf._many(function(){#CRLF#ret
- * urn $elf._apply("trans")});return (((((recv + ".") + msg) + "(") + arg
- * s.join(",")) + ")")})()},"new":function(){var $elf=this,cls,args;retur
- * n (function(){cls=$elf._apply("anything");args=$elf._many(function(){#
- * CRLF#return $elf._apply("trans")});return (((("new " + cls) + "(") + a
- * rgs.join(",")) + ")")})()},"var":function(){var $elf=this,name,val;ret
- * urn (function(){name=$elf._apply("anything");val=$elf._apply("trans");
- * return ((("var " + name) + "=") + val)})()},"throw":function(){var $el
- * f=this,x;return (function(){x=$elf._apply("trans");return ("throw " +
- * x)})()},"try":function(){var $elf=this,x,name,c,f;return (function(){x
- * =$elf._apply("curlyTrans");name=$elf._apply("anything");c=$elf._apply(
- * "curlyTrans");f=$elf._apply("curlyTrans");return ((((((("try " + x) +
- * "catch(") + name) + ")") + c) + "finally") + f)})()},"json":function()
- * {var $elf=this,props;return (function(){props=$elf._many(function(){#C
- * RLF#return $elf._apply("trans")});return (("({" + props.join(",")) + "
- * })")})()},"binding":function(){var $elf=this,name,val;return (function
- * (){name=$elf._apply("anything");val=$elf._apply("trans");return ((name
- * .toProgramString() + ": ") + val)})()},"switch":function(){var $elf=th
- * is,x,cases;return (function(){x=$elf._apply("trans");cases=$elf._many(
- * function(){#CRLF#return $elf._apply("trans")});return (((("switch(" +
- * x) + "){") + cases.join(";")) + "}")})()},"case":function(){var $elf=t
- * his,x,y;return (function(){x=$elf._apply("trans");y=$elf._apply("trans
- * ");return ((("case " + x) + ": ") + y)})()},"default":function(){var $
- * elf=this,y;return (function(){y=$elf._apply("trans");return ("default:
- * " + y)})()}})}#CRLF##CRLF#{BSOMetaParser=Parser.delegated({"fromTo":f
- * unction(){var $elf=this,x,y;return (function(){x=$elf._apply("anything
- * ");y=$elf._apply("anything");$elf._applyWithArgs("seq",x);$elf._many(f
- * unction(){return (function(){$elf._not(function(){return $elf._applyWi
- * thArgs("seq",y)});return $elf._apply("char")})()});return $elf._applyW
- * ithArgs("seq",y)})()},"space":function(){var $elf=this;return $elf._or
- * ((function(){return Parser._superApplyWithArgs($elf,"space")}),(functi
- * on(){return $elf._applyWithArgs("fromTo","//","\n")}),(function(){retu
- * rn $elf._applyWithArgs("fromTo","/*","*/")}))},"nameFirst":function(){
- * var $elf=this;return $elf._or((function(){return $elf._applyWithArgs("
- * exactly","_")}),(function(){return $elf._applyWithArgs("exactly","$")}
- * ),(function(){return $elf._apply("letter")}))},"nameRest":function(){v
- * ar $elf=this;return $elf._or((function(){return $elf._apply("nameFirst
- * ")}),(function(){return $elf._apply("digit")}))},"tsName":function(){v
- * ar $elf=this,xs;return (function(){xs=$elf._applyWithArgs("firstAndRes
- * t","nameFirst","nameRest");return xs.join("")})()},"name":function(){v
- * ar $elf=this;return (function(){$elf._apply("spaces");return $elf._app
- * ly("tsName")})()},"eChar":function(){var $elf=this,c;return $elf._or((
- * function(){return (function(){$elf._applyWithArgs("exactly","\\");c=$e
- * lf._apply("char");return unescape(("\\" + c))})()}),(function(){return
- * $elf._apply("char")}))},"tsString":function(){var $elf=this,xs;return
- * (function(){$elf._applyWithArgs("exactly","\'");xs=$elf._many(functio
- * n(){return (function(){$elf._not(function(){return $elf._applyWithArgs
- * ("exactly","\'")});return $elf._apply("eChar")})()});$elf._applyWithAr
- * gs("exactly","\'");return xs.join("")})()},"characters":function(){var
- * $elf=this,xs;return (function(){$elf._applyWithArgs("exactly","`");$e
- * lf._applyWithArgs("exactly","`");xs=$elf._many(function(){return (func
- * tion(){$elf._not(function(){return (function(){$elf._applyWithArgs("ex
- * actly","\'");return $elf._applyWithArgs("exactly","\'")})()});return $
- * elf._apply("eChar")})()});$elf._applyWithArgs("exactly","\'");$elf._ap
- * plyWithArgs("exactly","\'");return ["App","seq",xs.join("").toProgramS
- * tring()]})()},"sCharacters":function(){var $elf=this,xs;return (functi
- * on(){$elf._applyWithArgs("exactly","\"");xs=$elf._many(function(){retu
- * rn (function(){$elf._not(function(){return $elf._applyWithArgs("exactl
- * y","\"")});return $elf._apply("eChar")})()});$elf._applyWithArgs("exac
- * tly","\"");return ["App","token",xs.join("").toProgramString()]})()},"
- * string":function(){var $elf=this,xs;return (function(){xs=$elf._or((fu
- * nction(){return (function(){$elf._or((function(){return $elf._applyWit
- * hArgs("exactly","#")}),(function(){return $elf._applyWithArgs("exactly
- * ","`")}));return $elf._apply("tsName")})()}),(function(){return $elf._
- * apply("tsString")}));return ["App","exactly",xs.toProgramString()]})()
- * },"number":function(){var $elf=this,sign,ds;return (function(){sign=$e
- * lf._or((function(){return $elf._applyWithArgs("exactly","-")}),(functi
- * on(){return (function(){$elf._apply("empty");return ""})()}));ds=$elf.
- * _many1(function(){return $elf._apply("digit")});return ["App","exactly
- * ",(sign + ds.join(""))]})()},"keyword":function(){var $elf=this,xs;ret
- * urn (function(){xs=$elf._apply("anything");$elf._applyWithArgs("token"
- * ,xs);$elf._not(function(){return $elf._apply("letterOrDigit")});return
- * xs})()},"args":function(){var $elf=this,xs;return $elf._or((function(
- * ){return (function(){$elf._applyWithArgs("exactly","(");xs=$elf._apply
- * WithArgs("listOf","hostExpr",",");$elf._applyWithArgs("token",")");ret
- * urn xs})()}),(function(){return (function(){$elf._apply("empty");retur
- * n []})()}))},"application":function(){var $elf=this,rule,as,rule,as;re
- * turn $elf._or((function(){return (function(){$elf._applyWithArgs("toke
- * n","^");rule=$elf._apply("name");as=$elf._apply("args");return ["App",
- * "super",(("\'" + rule) + "\'")].concat(as)})()}),(function(){return (f
- * unction(){rule=$elf._apply("name");as=$elf._apply("args");return ["App
- * ",rule].concat(as)})()}))},"hostExpr":function(){var $elf=this,r;retur
- * n (function(){r=$elf._applyWithArgs("foreign",BSJSParser,"expr");retur
- * n $elf._applyWithArgs("foreign",BSJSTranslator,"trans",r)})()},"atomic
- * HostExpr":function(){var $elf=this,r;return (function(){r=$elf._applyW
- * ithArgs("foreign",BSJSParser,"semAction");return $elf._applyWithArgs("
- * foreign",BSJSTranslator,"trans",r)})()},"curlyHostExpr":function(){var
- * $elf=this,r;return (function(){r=$elf._applyWithArgs("foreign",BSJSPa
- * rser,"curlySemAction");return $elf._applyWithArgs("foreign",BSJSTransl
- * ator,"trans",r)})()},"semAction":function(){var $elf=this,x,x;return $
- * elf._or((function(){return (function(){$elf._or((function(){return $el
- * f._applyWithArgs("token","!")}),(function(){return $elf._applyWithArgs
- * ("token","->")}));x=$elf._apply("atomicHostExpr");return ["Act",x]})()
- * }),(function(){return (function(){x=$elf._apply("curlyHostExpr");retur
- * n ["Act",x]})()}))},"semPred":function(){var $elf=this,x;return (funct
- * ion(){$elf._applyWithArgs("token","?");x=$elf._apply("atomicHostExpr")
- * ;return ["Pred",x]})()},"expr":function(){var $elf=this,xs;return (fun
- * ction(){xs=$elf._applyWithArgs("listOf","expr4","|");return ["Or"].con
- * cat(xs)})()},"expr4":function(){var $elf=this,xs;return (function(){xs
- * =$elf._many(function(){return $elf._apply("expr3")});return ["And"].co
- * ncat(xs)})()},"optIter":function(){var $elf=this,x;return (function(){
- * x=$elf._apply("anything");return $elf._or((function(){return (function
- * (){$elf._applyWithArgs("token","*");return ["Many",x]})()}),(function(
- * ){return (function(){$elf._applyWithArgs("token","+");return ["Many1",
- * x]})()}),(function(){return (function(){$elf._apply("empty");return x}
- * )()}))})()},"expr3":function(){var $elf=this,x,x,n,n;return $elf._or((
- * function(){return (function(){x=$elf._apply("expr2");x=$elf._applyWith
- * Args("optIter",x);return $elf._or((function(){return (function(){$elf.
- * _applyWithArgs("exactly",":");n=$elf._apply("name");return (function (
- * ){$elf["locals"].push(n);return ["Set",n,x]})()})()}),(function(){retu
- * rn (function(){$elf._apply("empty");return x})()}))})()}),(function(){
- * return (function(){$elf._applyWithArgs("token",":");n=$elf._apply("nam
- * e");return (function (){$elf["locals"].push(n);return ["Set",n,["App",
- * "anything"]]})()})()}))},"expr2":function(){var $elf=this,x,x;return $
- * elf._or((function(){return (function(){$elf._applyWithArgs("token","~"
- * );x=$elf._apply("expr2");return ["Not",x]})()}),(function(){return (fu
- * nction(){$elf._applyWithArgs("token","&");x=$elf._apply("expr1");retur
- * n ["Lookahead",x]})()}),(function(){return $elf._apply("expr1")}))},"e
- * xpr1":function(){var $elf=this,x,x,x;return $elf._or((function(){retur
- * n $elf._apply("application")}),(function(){return $elf._apply("semActi
- * on")}),(function(){return $elf._apply("semPred")}),(function(){return
- * (function(){x=$elf._or((function(){return $elf._applyWithArgs("keyword
- * ","undefined")}),(function(){return $elf._applyWithArgs("keyword","nil
- * ")}),(function(){return $elf._applyWithArgs("keyword","true")}),(funct
- * ion(){return $elf._applyWithArgs("keyword","false")}));return ["App","
- * exactly",x]})()}),(function(){return (function(){$elf._apply("spaces")
- * ;return $elf._or((function(){return $elf._apply("characters")}),(funct
- * ion(){return $elf._apply("sCharacters")}),(function(){return $elf._app
- * ly("string")}),(function(){return $elf._apply("number")}))})()}),(func
- * tion(){return (function(){$elf._applyWithArgs("token","[");x=$elf._app
- * ly("expr");$elf._applyWithArgs("token","]");return ["Form",x]})()}),(f
- * unction(){return (function(){$elf._applyWithArgs("token","(");x=$elf._
- * apply("expr");$elf._applyWithArgs("token",")");return x})()}))},"ruleN
- * ame":function(){var $elf=this;return $elf._or((function(){return $elf.
- * _apply("name")}),(function(){return (function(){$elf._apply("spaces");
- * return $elf._apply("tsString")})()}))},"rule":function(){var $elf=this
- * ,n,x,xs;return (function(){$elf._lookahead(function(){return n=$elf._a
- * pply("ruleName")});$elf["locals"]=["$elf=this"];x=$elf._applyWithArgs(
- * "rulePart",n);xs=$elf._many(function(){return (function(){$elf._applyW
- * ithArgs("token",",");return $elf._applyWithArgs("rulePart",n)})()});re
- * turn ["Rule",n,$elf["locals"],["Or",x].concat(xs)]})()},"rulePart":fun
- * ction(){var $elf=this,rn,n,b1,b2;return (function(){rn=$elf._apply("an
- * ything");n=$elf._apply("ruleName");$elf._pred((n == rn));b1=$elf._appl
- * y("expr4");return $elf._or((function(){return (function(){$elf._applyW
- * ithArgs("token","=");b2=$elf._apply("expr");return ["And",b1,b2]})()})
- * ,(function(){return (function(){$elf._apply("empty");return b1})()}))}
- * )()},"grammar":function(){var $elf=this,n,sn,rs;return (function(){$el
- * f._applyWithArgs("keyword","ometa");n=$elf._apply("name");sn=$elf._or(
- * (function(){return (function(){$elf._applyWithArgs("token","<:");retur
- * n $elf._apply("name")})()}),(function(){return (function(){$elf._apply
- * ("empty");return "OMeta"})()}));$elf._applyWithArgs("token","{");rs=$e
- * lf._applyWithArgs("listOf","rule",",");$elf._applyWithArgs("token","}"
- * );return $elf._applyWithArgs("foreign",BSOMetaOptimizer,"optimizeGramm
- * ar",["Grammar",n,sn].concat(rs))})()}});BSOMetaTranslator=OMeta.delega
- * ted({"trans":function(){var $elf=this,t,ans;return (function(){$elf._f
- * orm(function(){return (function(){t=$elf._apply("anything");return ans
- * =$elf._applyWithArgs("apply",t)})()});return ans})()},"App":function()
- * {var $elf=this,args,rule,args,rule;return $elf._or((function(){return
- * (function(){$elf._applyWithArgs("exactly","super");args=$elf._many1(fu
- * nction(){return $elf._apply("anything")});return [$elf["sName"],"._sup
- * erApplyWithArgs($elf,",args.join(","),")"].join("")})()}),(function(){
- * return (function(){rule=$elf._apply("anything");args=$elf._many1(funct
- * ion(){return $elf._apply("anything")});return ["$elf._applyWithArgs(\"
- * ",rule,"\",",args.join(","),")"].join("")})()}),(function(){return (fu
- * nction(){rule=$elf._apply("anything");return ["$elf._apply(\"",rule,"\
- * ")"].join("")})()}))},"Act":function(){var $elf=this,expr;return (func
- * tion(){expr=$elf._apply("anything");return expr})()},"Pred":function()
- * {var $elf=this,expr;return (function(){expr=$elf._apply("anything");re
- * turn ["$elf._pred(",expr,")"].join("")})()},"Or":function(){var $elf=t
- * his,xs;return (function(){xs=$elf._many(function(){return $elf._apply(
- * "transFn")});return ["$elf._or(",xs.join(","),")"].join("")})()},"And"
- * :function(){var $elf=this,xs,y;return $elf._or((function(){return (fun
- * ction(){xs=$elf._many(function(){return $elf._applyWithArgs("notLast",
- * "trans")});y=$elf._apply("trans");return (function (){xs.push(("return
- * " + y));return ["(function(){",xs.join(";"),"})()"].join("")})()})()}
- * ),(function(){return "(function(){})"}))},"Many":function(){var $elf=t
- * his,x;return (function(){x=$elf._apply("trans");return ["$elf._many(fu
- * nction(){return ",x,"})"].join("")})()},"Many1":function(){var $elf=th
- * is,x;return (function(){x=$elf._apply("trans");return ["$elf._many1(fu
- * nction(){return ",x,"})"].join("")})()},"Set":function(){var $elf=this
- * ,n,v;return (function(){n=$elf._apply("anything");v=$elf._apply("trans
- * ");return [n,"=",v].join("")})()},"Not":function(){var $elf=this,x;ret
- * urn (function(){x=$elf._apply("trans");return ["$elf._not(function(){r
- * eturn ",x,"})"].join("")})()},"Lookahead":function(){var $elf=this,x;r
- * eturn (function(){x=$elf._apply("trans");return ["$elf._lookahead(func
- * tion(){return ",x,"})"].join("")})()},"Form":function(){var $elf=this,
- * x;return (function(){x=$elf._apply("trans");return ["$elf._form(functi
- * on(){return ",x,"})"].join("")})()},"Rule":function(){var $elf=this,na
- * me,ls,body;return (function(){name=$elf._apply("anything");ls=$elf._ap
- * ply("locals");body=$elf._apply("trans");return ["\"",name,"\":function
- * (){",ls,"return ",body,"}"].join("")})()},"Grammar":function(){var $el
- * f=this,name,sName,rules;return (function(){name=$elf._apply("anything"
- * );sName=$elf._apply("anything");$elf["sName"]=sName;rules=$elf._many(f
- * unction(){return $elf._apply("trans")});return [name,"=",sName,".deleg
- * ated({",rules.join(","),"})"].join("")})()},"locals":function(){var $e
- * lf=this,vs;return $elf._or((function(){return (function(){$elf._form(f
- * unction(){return vs=$elf._many1(function(){return $elf._apply("string"
- * )})});return ["var ",vs.join(","),";"].join("")})()}),(function(){retu
- * rn (function(){$elf._form(function(){return (function(){})});return ""
- * })()}))},"transFn":function(){var $elf=this,x;return (function(){x=$el
- * f._apply("trans");return ["(function(){return ",x,"})"].join("")})()}}
- * )}#CRLF##CRLF#{BSNullOptimization=OMeta.delegated();BSNullOptimization
- * ['setHelped']=function() {var $elf=this;return $elf["_didSomething"]=t
- * rue};BSNullOptimization['helped']=function() {var $elf=this;return $el
- * f._pred($elf["_didSomething"])};BSNullOptimization['trans']=function()
- * {var $elf=this,t,ans;return $elf._or((function(){return (function(){$
- * elf._form(function(){return (function(){t=$elf._apply("anything");$elf
- * ._pred($elf.hasProperty(t));return ans=$elf._applyWithArgs("apply", t)
- * })()});return ans})()}),(function(){return $elf._apply("anything")}))}
- * ;BSNullOptimization['optimize']=function() {var $elf=this,x;return (fu
- * nction(){x=$elf._apply("trans");$elf._apply("helped");return x})()};BS
- * NullOptimization['Or']=function() {var $elf=this,xs;return (function()
- * {xs=$elf._many(function(){return $elf._apply("trans")});return ["Or"].
- * concat(xs)})()};BSNullOptimization['And']=function() {var $elf=this,xs
- * ;return (function(){xs=$elf._many(function(){return $elf._apply("trans
- * ")});return ["And"].concat(xs)})()};BSNullOptimization['Many']=functio
- * n() {var $elf=this,x;return (function(){x=$elf._apply("trans");return
- * ["Many",x]})()};BSNullOptimization['Many1']=function() {var $elf=this,
- * x;return (function(){x=$elf._apply("trans");return ["Many1",x]})()};BS
- * NullOptimization['Set']=function() {var $elf=this,n,v;return (function
- * (){n=$elf._apply("anything");v=$elf._apply("trans");return ["Set",n,v]
- * })()};BSNullOptimization['Not']=function() {var $elf=this,x;return (fu
- * nction(){x=$elf._apply("trans");return ["Not",x]})()};BSNullOptimizati
- * on['Lookahead']=function() {var $elf=this,x;return (function(){x=$elf.
- * _apply("trans");return ["Lookahead",x]})()};BSNullOptimization['Form']
- * =function() {var $elf=this,x;return (function(){x=$elf._apply("trans")
- * ;return ["Form",x]})()};BSNullOptimization['Rule']=function() {var $el
- * f=this,name,ls,body;return (function(){name=$elf._apply("anything");ls
- * =$elf._apply("anything");body=$elf._apply("trans");return ["Rule",name
- * ,ls,body]})()};BSNullOptimization.prototype=BSNullOptimization;;BSNull
- * Optimization["initialize"]=(function () {this["_didSomething"]=false})
- * ;BSAndOrOptimization=BSNullOptimization.delegated();BSAndOrOptimizatio
- * n['And']=function() {var $elf=this,x,xs;return $elf._or((function(){re
- * turn (function(){x=$elf._apply("trans");$elf._apply("end");$elf._apply
- * ("setHelped");return x})()}),(function(){return (function(){xs=$elf._a
- * pplyWithArgs("transInside", "And");return ["And"].concat(xs)})()}))};B
- * SAndOrOptimization['Or']=function() {var $elf=this,x,xs;return $elf._o
- * r((function(){return (function(){x=$elf._apply("trans");$elf._apply("e
- * nd");$elf._apply("setHelped");return x})()}),(function(){return (funct
- * ion(){xs=$elf._applyWithArgs("transInside", "Or");return ["Or"].concat
- * (xs)})()}))};BSAndOrOptimization['transInside']=function() {var $elf=t
- * his,t,xs,ys,x,xs;return (function(){t=$elf._apply("anything");return $
- * elf._or((function(){return (function(){$elf._form(function(){return (f
- * unction(){$elf._applyWithArgs("exactly", t);return xs=$elf._applyWithA
- * rgs("transInside", t)})()});ys=$elf._applyWithArgs("transInside", t);$
- * elf._apply("setHelped");return xs.concat(ys)})()}),(function(){return
- * (function(){x=$elf._apply("trans");xs=$elf._applyWithArgs("transInside
- * ", t);return [x].concat(xs)})()}),(function(){return []}))})()};BSAndO
- * rOptimization.prototype=BSAndOrOptimization;;BSOMetaOptimizer=OMeta.de
- * legated();BSOMetaOptimizer['optimizeGrammar']=function() {var $elf=thi
- * s,n,sn,rs;return (function(){$elf._form(function(){return (function(){
- * $elf._applyWithArgs("exactly", "Grammar");n=$elf._apply("anything");sn
- * =$elf._apply("anything");return rs=$elf._many(function(){return $elf._
- * apply("optimizeRule")})})()});return ["Grammar",n,sn].concat(rs)})()};
- * BSOMetaOptimizer['optimizeRule']=function() {var $elf=this,r,r;return
- * (function(){r=$elf._apply("anything");$elf._many(function(){return r=$
- * elf._applyWithArgs("foreign", BSAndOrOptimization, "optimize", r)});re
- * turn r})()};BSOMetaOptimizer.prototype=BSOMetaOptimizer;}#CRLF##CRLF#{
- * BSOMetaJSParser=BSJSParser.delegated();BSOMetaJSParser['srcElem']=func
- * tion() {var $elf=this,r;return $elf._or((function(){return (function()
- * {$elf._apply("spaces");r=$elf._applyWithArgs("foreign", BSOMetaParser,
- * "grammar");$elf._apply("sc");return r})()}),(function(){return BSJSPa
- * rser._superApplyWithArgs($elf,"srcElem")}))};BSOMetaJSParser.prototype
- * =BSOMetaJSParser;;BSOMetaJSTranslator=BSJSTranslator.delegated();BSOMe
- * taJSTranslator['Grammar']=function() {var $elf=this;return $elf._apply
- * WithArgs("foreign", BSOMetaTranslator, "Grammar")};BSOMetaJSTranslator
- * .prototype=BSOMetaJSTranslator;}#CRLF#
- * function translateCode(s) {
- * var translationError = function(m, i) { throw fail };
- * var tree = BSOMetaJSParser.matchAll(s, "topLevel", undefined, function
- * (m, i) { throw fail.delegated({errorPos: i}) });
- * return BSOMetaJSTranslator.match(tree, "trans", undefined, translation
- * Error) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement