├── lib ├── html │ ├── package.json │ ├── index.js │ ├── htmlsection.yk │ ├── tagtypes.yk │ └── tags.js ├── jsdata │ ├── package.json │ └── index.js ├── ove │ ├── package.json │ ├── index.js │ ├── string.js │ ├── date.js │ ├── fundemental.js │ └── numeric.js ├── youki-article │ ├── package.json │ └── index.yk ├── pm.js ├── youki-syntax.pegjs ├── runtime.js └── youki-syntax.js ├── package.json ├── .gitignore ├── bin └── yki.js ├── main.js ├── LICENSE └── README.yk /lib/html/package.json: -------------------------------------------------------------------------------- 1 | { "main": "index.js" } -------------------------------------------------------------------------------- /lib/jsdata/package.json: -------------------------------------------------------------------------------- 1 | { "main" : "index.js" } -------------------------------------------------------------------------------- /lib/ove/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "index.js" 3 | } -------------------------------------------------------------------------------- /lib/youki-article/package.json: -------------------------------------------------------------------------------- 1 | { "main": "index.yk" } -------------------------------------------------------------------------------- /lib/html/index.js: -------------------------------------------------------------------------------- 1 | exports.apply = function(scope, exports, runtime){ 2 | require('./tags').apply(scope, exports, runtime); 3 | require('./htmlsection.yk').apply(scope, exports, runtime); 4 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "youki", 3 | "version": "0.4.0", 4 | "main": "./main.js", 5 | "dependencies": { 6 | "yargs": "^7.0.2" 7 | }, 8 | "bin": { 9 | "yki":"./bin/yki.js" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | 14 | npm-debug.log 15 | node_modules 16 | 17 | *.sublime-project 18 | *.sublime-workspace 19 | tests -------------------------------------------------------------------------------- /lib/ove/index.js: -------------------------------------------------------------------------------- 1 | exports.apply = function(scope, exports, runtime){ 2 | require('./fundemental').apply(scope, exports, runtime); 3 | require('./numeric').apply(scope, exports, runtime); 4 | require('./string').apply(scope, exports, runtime); 5 | require('./date').apply(scope, exports, runtime); 6 | } -------------------------------------------------------------------------------- /lib/jsdata/index.js: -------------------------------------------------------------------------------- 1 | exports.apply = function(scope, exports, runtime){ 2 | exports.json = { 3 | parse: function(str){ 4 | return JSON.parse(str) 5 | }, 6 | stringify: function(json){ 7 | return JSON.stringify(json) 8 | } 9 | }; 10 | exports.base64 = { 11 | encode: function(s, encoding){ 12 | return new Buffer(s, encoding || 'utf8').toString('base64') 13 | }, 14 | decode: function(b, encoding){ 15 | return new Buffer(b, 'base64').toString(encoding || 'utf8') 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /lib/html/htmlsection.yk: -------------------------------------------------------------------------------- 1 | [define-macro [html-section $block] [cond 2 | [$block/definingScope 3 | [setf s [derive $block/definingScope]] 4 | [setpart s ".lit" dothtml/dotlit] 5 | [setpart s ".codespan" dothtml/dotcodespan] 6 | [setpart s ".p" dothtml/dotp] 7 | [setpart s ".li" dothtml/dotli] 8 | [setpart s ".ul" dothtml/dotul] 9 | [setpart s ".ol" dothtml/dotol] 10 | [setpart s ".inline**" dothtml/dotstrong] 11 | [setpart s ".inline*" dothtml/dotem] 12 | [evaluate-in-scope s $block] 13 | ] 14 | [true [throw "Unsupported Type"]] 15 | ]] 16 | 17 | [export html-section] -------------------------------------------------------------------------------- /lib/ove/string.js: -------------------------------------------------------------------------------- 1 | /// Youki String Processing Library 2 | exports.apply = function(scope, exports, runtime){ 3 | exports['regex'] = function(pattern, flags){ 4 | return new RegExp(pattern, flags) 5 | } 6 | exports['ssub'] = function(s, pattern, replacement){ 7 | return s.replace(pattern, replacement) 8 | } 9 | exports['slice'] = function(a){ 10 | return [].slice.apply(a, [].slice.call(arguments, 1)) 11 | } 12 | exports['map'] = function(m, f){ 13 | var t = this; 14 | return m.map(function(){ return f.apply(t, arguments) }); 15 | } 16 | exports['cons'] = function(h, t){ 17 | return [h].concat(t); 18 | } 19 | exports['split'] = function(s, k){ 20 | return s.split(k) 21 | } 22 | exports['array-join'] = function(a, d){ 23 | return a.join(d) 24 | } 25 | } -------------------------------------------------------------------------------- /bin/yki.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var path = require('path') 3 | var argv = require('yargs') 4 | .boolean('f').describe('f', 'Find and Import .youki-common/') 5 | .boolean('debug').describe('debug', 'Enable debug mode') 6 | .argv; 7 | var fs = require('fs') 8 | var pm = require('../lib/pm.js'); 9 | var scope = pm.init(); 10 | scope['load-library'](scope.directories.loader + '/ove'); 11 | 12 | if (argv._[0]) { 13 | var inputPath = path.resolve(argv._[0]); 14 | if (argv.f) { 15 | var cwd = path.dirname(inputPath); 16 | do { 17 | if (fs.existsSync(path.resolve(cwd, '.youki-common/package.json'))) { 18 | scope.directories['input-common'] = path.join(cwd, ".youki-common/"); 19 | scope.directories['base'] = cwd; 20 | scope['load-library'](path.join(cwd, ".youki-common/")); 21 | break; 22 | }; 23 | } while (cwd !== (cwd = path.resolve(cwd, '..'))); 24 | } 25 | scope['input-path'] = inputPath 26 | scope['load-library'](inputPath) 27 | } else { 28 | console.error('Missing input') 29 | } -------------------------------------------------------------------------------- /lib/ove/date.js: -------------------------------------------------------------------------------- 1 | exports.apply = function(scope, exports, runtime){ 2 | var fDate = function (format) { 3 | var o = { 4 | "M+": this.getMonth() + 1, //month 5 | "d+": this.getDate(), //day 6 | "h+": this.getHours(), //hour 7 | "m+": this.getMinutes(), //minute 8 | "s+": this.getSeconds(), //second 9 | "q+": Math.floor((this.getMonth() + 3) / 3), //quarter 10 | "S": this.getMilliseconds() //millisecond 11 | } 12 | if (/(y+)/.test(format)) { 13 | format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); 14 | } 15 | for (var k in o) { 16 | if (new RegExp("(" + k + ")").test(format)) { 17 | format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); 18 | } 19 | } 20 | return format; 21 | } 22 | exports.date = { 23 | format: function(df, format){ 24 | return fDate.call(df, format) 25 | }, 26 | now: function(){ 27 | return new Date 28 | }, 29 | create: function(x){ 30 | return new Date(x) 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const pm = require('./lib/pm.js'); 4 | 5 | const newScope = function () { 6 | const scope = pm.init(); 7 | scope['load-library'](scope.directories.loader + '/ove'); 8 | return scope; 9 | } 10 | 11 | function loadPointYouki(scope, inputPath) { 12 | var cwd = path.dirname(inputPath); 13 | do { 14 | if (fs.existsSync(path.resolve(cwd, '.youki-common/package.json'))) { 15 | scope.directories['input-common'] = path.join(cwd, ".youki-common/"); 16 | scope.directories['base'] = cwd; 17 | scope['load-library'](path.join(cwd, ".youki-common/")); 18 | break; 19 | }; 20 | } while (cwd !== (cwd = path.resolve(cwd, '..'))); 21 | } 22 | 23 | function loadPath(scope, inputPath) { 24 | scope['input-path'] = inputPath; 25 | scope['load-library'](inputPath); 26 | } 27 | 28 | function loadText(scope, text, path) { 29 | scope['load-text'](text, path); 30 | } 31 | 32 | module.exports.newScope = newScope; 33 | module.exports.loadPointYouki = loadPointYouki; 34 | module.exports.loadPath = loadPath; 35 | module.exports.loadText = loadText; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Belleve Invis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /lib/youki-article/index.yk: -------------------------------------------------------------------------------- 1 | [begin 2 | [load-library [path/join directories/loader "ove"]] 3 | [load-library [path/join directories/loader "html"]] 4 | 5 | [define-macro [youki-article $template $body] [begin 6 | [define template [evaluate $template]] 7 | [define section-meta [object [level 1] [count 0]]] 8 | [define [proper-head] [apply [part tags [& "h" section-meta/level]] ##]] 9 | [define [proper-head-for-embedded] [apply [part tags [+ [& "h" section-meta/level] 1]] ##]] 10 | 11 | [define current-article [object]] 12 | 13 | [define-macro [section $title $content] [begin 14 | [setf section-meta/level [+ section-meta/level 1]] 15 | [define result [cond 16 | [$content [begin 17 | [setf title [evaluate $title]] 18 | [setf title-id [ssub [& "" title] [regex {|[^a-zA-Z0-9\-\u0080-\uffff]+|} "g"] "-"]] 19 | [tags/section { 20 | [proper-head :id [& "section-" title-id] [& title [tags/a :href [& current-article/html-url "#section-" title-id] :class "handle" {[span :class "h"]{(}#[span :class "h"]{)}}]]] 21 | [evaluate $content] 22 | }]]] 23 | [$title [tags/section [evaluate $title]]] 24 | ]] 25 | [setf section-meta/level [- section-meta/level 1]] 26 | result 27 | ]] 28 | 29 | [define [figure src comment] [tags/figure { 30 | [tags/img :src src] 31 | [tags/figcaption comment] 32 | }]] 33 | 34 | [define s [derive $body/definingScope]] 35 | [define s/section section] 36 | [define s/figure figure] 37 | 38 | [define s/current-article current-article] 39 | 40 | [define additional-parameters [map [slice ## 2] evaluate]] 41 | [if template/inject-before [apply template/inject-before [cons s additional-parameters]]] 42 | [define current-article/body [evaluate-in-scope s `[html-section ,$body]]] 43 | [if template/inject-after [apply template/inject-after [cons s additional-parameters]]] 44 | 45 | [template current-article] 46 | ]] 47 | 48 | [export youki-article] 49 | ] -------------------------------------------------------------------------------- /README.yk: -------------------------------------------------------------------------------- 1 | [load-library [path/join directories/loader "youki-article"]] 2 | 3 | [define [template article aux] [util/trace { 4 | [html5-doctype] 5 | [tags/html { 6 | [tags/head { 7 | [tags/meta [html-attributes [charset "utf-8"]]] 8 | [tags/title article/title] 9 | }] 10 | [tags/body [tags/article { 11 | [tags/h1 article/title] 12 | [= article/body] 13 | }]] 14 | }] 15 | }]] 16 | 17 | [define [template/inject s] [begin 18 | [define [s/title content] [setf s/current-article/title content]] 19 | ]] 20 | 21 | [[macro template article [invoke youki-article template article '[= 333]]] template]:: 22 | 23 | [title {Youki · 有纪}] 24 | 25 | Youki 是一个文档生成语言,其具备完整的编程特性和完备的宏特性,使之可作任意复杂的文章。Youki 是完全开放源码的,依照 MIT 协议发布。 26 | 27 | [section {目录}]: 28 | # 文法 29 | # 章句 30 | # 算式 31 | # 抄录 32 | # 它们的组合 33 | # 预定义函数和宏 34 | # 基础 35 | # 高级 36 | # 有纪华章 37 | 38 | [section "文法"]: 39 | Youki 文章是由许多种元素组合而成,主要的是**章句**、**算式**和**抄录**。它们可以相互穿插嵌套,这也是 Youki 强大能力的来源。 40 | 41 | [section {章句}]: 42 | Youki 使用章句以表示文字。一段章句用花括弧围住,形如: 43 | 44 | [pre]| 45 | {这样。} 46 | 47 | 当然也可以更复杂,比如包含若干个段落,类似 48 | 49 | [pre]| 50 | { 51 | 这里的情形。 52 | 53 | 章句中的段落用空行分隔,一个段落可以包含多行,方便 54 | 组织比较复杂的文字。 55 | 56 | 同一份章句中的段落必须相同缩进,每一行也是如此。 57 | 58 | 不过你可以通过花括弧来组织缩进。花括弧 { 59 | 里面是另一份章句,对于外面来说只相当于一个字。 60 | 61 | 在花括弧里的段落可以增加缩进,只要其中的内容缩进保持一致即可。 62 | 63 | { 64 | 其实也可以减少缩进 :) 65 | } 66 | }。 67 | } 68 | 69 | 在章句里也可以包含列表,它们 70 | 71 | [pre]| 72 | - 由一系列的项目组成 73 | - 每一项占据一行 74 | + 列表表头可以是加号、减号或者井号 75 | + 表头相同的算作同一个列表 76 | # 使用井号可以得到有数字编号的列表 77 | + 列表的每一项只能有一行 78 | + 不过可以 79 | - 包含子列表 80 | - 子列表 81 | # 可以有很多层 82 | # 很多内容 83 | + 当然,任何时候都可以通过 { 84 | 花 85 | 括 86 | 弧 87 | } 来包含更复杂的内容 88 | 89 | 不过只有段落和列表,对于生成文章来说仍然远远不够,因此 Youki 支持一种基于缩进的格式,可以插入任意复杂的模式。要使用它,你需要 90 | 91 | [pre]| 92 | [一个算式调用]: 93 | 后面加上冒号 94 | 95 | 然后就是缩进了的章句节。 96 | 97 | Youki 中绝大多数更复杂的文章组件都是用这种方式提供的,例如, 98 | 99 | [pre]| 100 | [blockquote]: 101 | 使用 `[blockquote]:` 就可以创建引文区段 102 | 103 | 程序员有时候会需要在文章中添加代码块,这些东西都是预先排版好的文字块,我们不想把它当成段落或者列表排版。为了处理这种情形,Youki 的做法是将上面那种「算式-冒号」中的冒号 `:` 替换成竖线 `|`,之后被缩进的地方保持原样,类似 104 | 105 | [pre]| 106 | [pre]| 107 | 这个样子。 108 | 109 | [highlight javascript]| 110 | // 于是你就可以在这里放源码了 111 | -------------------------------------------------------------------------------- /lib/html/tagtypes.yk: -------------------------------------------------------------------------------- 1 | [begin 2 | [define [html5-doctype] ""] 3 | [export html5-doctype] 4 | [define [@ link content] [cond 5 | [content [tags/a [html-attributes [href link]] content]] 6 | [true [tags/a [html-attributes [href link]] [dothtml/dotlit link]]] 7 | ]] 8 | [export @] 9 | 10 | [define-tag html [object [type "block"]]] 11 | [define-tag head [object [type "block"]]] 12 | [define-tag title [object [type "block"]]] 13 | [define-tag script [object [type "inline"]]] 14 | [define-tag style [object [type "inline"]]] 15 | [define-tag meta [object [type "void"]]] 16 | [define-tag base [object [type "void"]]] 17 | [define-tag link [object [type "void"] [notexpose true]]] 18 | 19 | [define-tag body [object [type "block"]]] 20 | [define-tag p [object [type "block"]]] 21 | [define-tag h1 [object [type "block"]]] 22 | [define-tag h2 [object [type "block"]]] 23 | [define-tag h3 [object [type "block"]]] 24 | [define-tag h4 [object [type "block"]]] 25 | [define-tag h5 [object [type "block"]]] 26 | [define-tag h6 [object [type "block"]]] 27 | [define-tag hr [object [type "block"]]] 28 | [define-tag li [object [type "block"]]] 29 | [define-tag ul [object [type "block"]]] 30 | [define-tag ol [object [type "block"]]] 31 | [define-tag dl [object [type "block"]]] 32 | [define-tag dt [object [type "block"]]] 33 | [define-tag dd [object [type "block"]]] 34 | [define-tag div [object [type "block"]]] 35 | [define-tag article [object [type "block"]]] 36 | [define-tag figure [object [type "block"]]] 37 | [define-tag figcaption [object [type "block"]]] 38 | [define-tag blockquote [object [type "block"]]] 39 | [define-tag section [object [type "block"] [notexpose true]]] 40 | [define-tag nav [object [type "block"] [notexpose true]]] 41 | [define-tag main [object [type "block"] [notexpose true]]] 42 | [define-tag aside [object [type "block"] [notexpose true]]] 43 | [define-tag header [object [type "block"] [notexpose true]]] 44 | [define-tag footer [object [type "block"] [notexpose true]]] 45 | [define-tag address [object [type "block"] [notexpose true]]] 46 | [define-tag table [object [type "block"] [notexpose true]]] 47 | [define-tag thead [object [type "block"] [notexpose true]]] 48 | [define-tag tbody [object [type "block"] [notexpose true]]] 49 | [define-tag tr [object [type "block"] [notexpose true]]] 50 | [define-tag th [object [type "block"] [notexpose true]]] 51 | [define-tag td [object [type "block"] [notexpose true]]] 52 | 53 | [define-tag pre [object [type "block"] [pre true]]] 54 | 55 | [define-tag a [object [type "inline"]]] 56 | [define-tag b [object [type "inline"]]] 57 | [define-tag i [object [type "inline"]]] 58 | [define-tag u [object [type "inline"]]] 59 | [define-tag s [object [type "inline"]]] 60 | [define-tag del [object [type "inline"]]] 61 | [define-tag strong [object [type "inline"]]] 62 | [define-tag span [object [type "inline"]]] 63 | [define-tag em [object [type "inline"]]] 64 | [define-tag code [object [type "inline"] [pre true]]] 65 | [define-tag img [object [type "void"]]] 66 | [define-tag button [object [type "void"]]] 67 | [define-tag input [object [type "void"]]] 68 | [define-tag br [object [type "void"]]] 69 | ] -------------------------------------------------------------------------------- /lib/ove/fundemental.js: -------------------------------------------------------------------------------- 1 | /// Youki Fundemental Library 2 | var util = require('util') 3 | exports.apply = function (scope, exports, runtime) { 4 | var Macro = runtime.Macro; 5 | var evaluate = runtime.evaluate; 6 | var Reference = runtime.Reference; 7 | var setf = runtime.setf; 8 | var thunk = runtime.thunk; 9 | exports.define = new Macro(function ($pattern, $definition) { 10 | if ($pattern) { 11 | if ($pattern instanceof Array && $pattern[0] instanceof Reference && !/^\./.test($pattern[0].id)) { 12 | // function definition 13 | setf(this, $pattern[0].id, scope.lambda.apply($definition.definingScope || this, $pattern.slice(1).concat([$definition]))) 14 | } else if ($pattern instanceof Reference) { 15 | setf(this, $pattern.id, scope.evaluate($definition)) 16 | } else { 17 | throw "Invalid pattern" 18 | } 19 | } else { 20 | throw "Invalid pattern" 21 | } 22 | }); 23 | exports['define-macro'] = exports.defineMacro = new Macro(function ($pattern, $definition) { 24 | if (!$pattern || !($pattern instanceof Array) || !($pattern[0] instanceof Reference) || /^\./.test($pattern[0].id)) 25 | throw "Invalid pattern"; 26 | setf(this, $pattern[0].id, scope.macro.apply(this, $pattern.slice(1).concat([$definition]))) 27 | }); 28 | exports['let'] = new Macro(function () { 29 | var $block = arguments[arguments.length - 1]; 30 | if (!$block || !$block.definingScope) throw "Invalid LET usage."; 31 | var t = $block.definingScope; 32 | var s = Object.create(t); 33 | for (var k = 0; k < arguments.length - 1; k++) { 34 | exports.define.apply(s, [thunk(s, arguments[k][0]), thunk(t, arguments[k][1])]); 35 | } 36 | return evaluate(s, $block); 37 | }); 38 | exports['letrec'] = new Macro(function () { 39 | var $block = arguments[arguments.length - 1]; 40 | if (!$block || !$block.definingScope) throw "Invalid LET usage." 41 | var s = Object.create($block.definingScope); 42 | for (var k = 0; k < arguments.length - 1; k++) { 43 | exports.define.apply(s, [thunk(s, arguments[k][0]), thunk(s, arguments[k][1])]); 44 | } 45 | return evaluate(s, $block); 46 | }); 47 | exports.part = function (base, shift) { 48 | return base[shift] 49 | } 50 | exports.setpart = function (base, shift, value) { 51 | return base[shift] = value 52 | } 53 | exports.derive = function (obj) { 54 | return Object.create(obj) 55 | } 56 | exports.emptyObject = function () { 57 | return {} 58 | } 59 | exports.object = new Macro(function () { 60 | var obj = {}; 61 | for (var j = 0; j < arguments.length; j++) { 62 | var s = arguments[j].definingScope; 63 | if (arguments[j] instanceof Array && arguments[j][0] instanceof Reference) { 64 | obj[arguments[j][0].id] = evaluate(s, arguments[j][1]) 65 | } 66 | } 67 | return obj 68 | }); 69 | exports['merge-parts'] = function (p, q) { 70 | var keys = Object.keys(q); 71 | for (var k = 0; k < keys.length; k++) { 72 | p[keys[k]] = q[keys[k]]; 73 | }; 74 | return p; 75 | } 76 | exports.util = { 77 | trace: function (x) { process.stderr.write(x + '\n'); return x }, 78 | log: function (x) { process.stdout.write(x + ''); return x }, 79 | inspect: function (x, options) { return util.inspect(x, options) } 80 | } 81 | } -------------------------------------------------------------------------------- /lib/ove/numeric.js: -------------------------------------------------------------------------------- 1 | /// Youki Numeric Library 2 | exports.apply = function(scope, exports, runtime){ 3 | exports['+'] = function(x, y, z){ 4 | // NOTE: Youki's [+] is always numeric. 5 | // To concat string, use [&]. 6 | switch(arguments.length){ 7 | case 0: return 0 8 | case 1: return x - 0 9 | case 2: return (x - 0) + y 10 | case 3: return (x - 0) + y + z 11 | default: { 12 | var result = x - 0; 13 | for(var j = 1; j < arguments.length; j++) { 14 | result += arguments[j] - 0 15 | } 16 | return result 17 | } 18 | } 19 | }; 20 | exports['-'] = function(x, y, z){ 21 | switch(arguments.length){ 22 | case 0: return 0 23 | case 1: return 0 - x 24 | case 2: return x - y 25 | case 3: return x - y - z 26 | default: { 27 | var result = x; 28 | for(var j = 1; j < arguments.length; j++) { 29 | result -= arguments[j] 30 | } 31 | return result 32 | } 33 | } 34 | }; 35 | exports['*'] = function(x, y, z){ 36 | switch(arguments.length){ 37 | case 0: return 1 38 | case 1: return x - 0 39 | case 2: return x * y 40 | case 3: return x * y * z 41 | default: { 42 | var result = x; 43 | for(var j = 1; j < arguments.length; j++) { 44 | result *= arguments[j] 45 | } 46 | return result 47 | } 48 | } 49 | }; 50 | exports['/'] = function(x, y, z){ 51 | switch(arguments.length){ 52 | case 0: return 1 53 | case 1: return 1 / x 54 | case 2: return x / y 55 | case 3: return x / y / z 56 | default: { 57 | var result = x; 58 | for(var j = 1; j < arguments.length; j++) { 59 | result /= arguments[j] 60 | } 61 | return result 62 | } 63 | } 64 | }; 65 | exports['quotient'] = function(p, q){ 66 | return (p - p % q) / q 67 | }; 68 | exports['modulo'] = function(p, q){ 69 | return p % q 70 | }; 71 | exports['&'] = function(x, y, z){ 72 | // NOTE: Youki's [+] is always numeric. 73 | // To concat string, use [&]. 74 | switch(arguments.length){ 75 | case 0: return '' 76 | case 1: return '' + x 77 | case 2: return '' + x + y 78 | case 3: return '' + x + y + z 79 | default: { 80 | var result = '' + x; 81 | for(var j = 1; j < arguments.length; j++) { 82 | result += arguments[j] 83 | } 84 | return result 85 | } 86 | } 87 | }; 88 | exports['='] = function(x, y){ 89 | if(arguments.length === 1) return x 90 | return x == y 91 | }; 92 | exports['!='] = function(x, y){ 93 | return x != y 94 | }; 95 | exports['<'] = function(x, y){ 96 | return x < y 97 | }; 98 | exports['>'] = function(x, y){ 99 | return x > y 100 | }; 101 | exports['<='] = function(x, y){ 102 | return x <= y 103 | }; 104 | exports['>='] = function(x, y){ 105 | return x >= y 106 | }; 107 | exports['not'] = function(x){ 108 | return !x 109 | }; 110 | exports['negate'] = function(x) { 111 | return 0 - x 112 | }; 113 | // NOTE: [and] and [or] are not functions, they are marcos, to impelment shortcut evaluation 114 | exports['and'] = new runtime.Macro(function(){ 115 | for(var k = 0; k < arguments.length; k++){ 116 | var result = scope.evaluate(arguments[k]); 117 | if(!result) return result; 118 | } 119 | return result; 120 | }); 121 | exports['or'] = new runtime.Macro(function(){ 122 | for(var k = 0; k < arguments.length; k++){ 123 | var result = scope.evaluate(arguments[k]); 124 | if(result) return result; 125 | } 126 | return false; 127 | }); 128 | } -------------------------------------------------------------------------------- /lib/pm.js: -------------------------------------------------------------------------------- 1 | var parser = require('../lib/youki-syntax.js'); 2 | var runtime = require('../lib/runtime.js'); 3 | var fs = require('fs'); 4 | var util = require('util'); 5 | var path = require('path'); 6 | 7 | function parseText(text, config, filename) { 8 | try { 9 | var ast = [new runtime.Reference('.cons_block')].concat(parser.parse(text, config)); 10 | } catch (e) { 11 | if(filename) process.stderr.write("at " + filename); 12 | process.stderr.write(util.inspect(e)); 13 | throw e; 14 | } 15 | var endTime = new Date(); 16 | return { 17 | source: text, 18 | ast: ast 19 | } 20 | } 21 | 22 | function parseFile(filename, config) { 23 | var startTime = new Date(); 24 | var text = fs.readFileSync(filename, 'utf-8'); 25 | return parseText(text, config, filename); 26 | } 27 | function createLoadFunctionsFor(module, s, gs) { 28 | // s is the scope used for evaluating module body 29 | // and gs is the global scope. 30 | function fnRequire(file) { 31 | if (typeof file === 'string') return module.require(file); 32 | else return file 33 | } 34 | 35 | s['load-text'] = function (text, filename) { 36 | return runText(text, module, filename).apply(gs, gs, runtime); 37 | } 38 | s['load-library'] = function (file) { 39 | return fnRequire(file).apply(gs, gs, runtime); 40 | }; 41 | s['require-library'] = function (file) { 42 | return fnRequire(file).apply(gs, Object.create(gs), runtime); 43 | }; 44 | s['load-library-for-scope'] = function (t, file) { 45 | return fnRequire(file).apply(gs, t, runtime); 46 | }; 47 | s['load-library-here'] = function (file) { 48 | return fnRequire(file).apply(gs, this, runtime); 49 | } 50 | } 51 | 52 | function runText(text, module, filename) { 53 | var parseResult = parseText(text, { 54 | Reference: runtime.Reference, 55 | Position: function (offset) { 56 | return { 57 | module: module, 58 | offset: offset 59 | } 60 | } 61 | }, filename); 62 | return run(parseResult, module, filename || ""); 63 | } 64 | 65 | function run(parseResult, module, filename) { 66 | module.exports.filename = filename; 67 | module.exports.source = parseResult.source; 68 | var ast = parseResult.ast; 69 | 70 | function evaluateModule(scope, exports, tfm) { 71 | var s = Object.create(scope); 72 | s.exports = {}; 73 | if (filename) s['module-path'] = filename; 74 | s.export = new runtime.Macro(function ($id, $value) { 75 | if (!$id instanceof runtime.Reference) { 76 | throw new Error($id + ' must be a reference') 77 | }; 78 | if ($value) { 79 | s.exports[$id.id] = this.evaluate($value) 80 | } else { 81 | s.exports[$id.id] = this.evaluate($id) 82 | } 83 | }); 84 | if (filename) createLoadFunctionsFor(module, s, scope); 85 | runtime.evaluate(s, tfm(ast, module)); 86 | return s.exports; 87 | } 88 | 89 | module.exports.applyWithTFM = function (scope, exports, rt, tfm) { 90 | let moduleExports = evaluateModule(scope, exports, tfm) 91 | for (var id in moduleExports) { 92 | runtime.setf(exports, id, moduleExports[id]) 93 | }; 94 | return moduleExports; 95 | } 96 | module.exports.apply = function (scope, exports, rt) { 97 | return module.exports.applyWithTFM(scope, exports, rt, function (x) { return x }) 98 | } 99 | return module.exports; 100 | } 101 | 102 | require.extensions['.yk'] = function (module, filename) { 103 | var parseResult = parseFile(filename, { 104 | Reference: runtime.Reference, 105 | Position: function (loc) { 106 | const offset = loc.start.offset 107 | return { 108 | module: module, 109 | offset: loc.start.offset, 110 | line: loc.start.line, 111 | column: loc.start.column 112 | } 113 | } 114 | }); 115 | return run(parseResult, module, filename); 116 | } 117 | 118 | exports.init = function () { 119 | var scope = Object.create(runtime.globalScope); 120 | scope.path = path; 121 | scope.directories = { loader: __dirname }; 122 | scope.paths = {}; 123 | createLoadFunctionsFor(module, scope, scope); 124 | return scope; 125 | } -------------------------------------------------------------------------------- /lib/html/tags.js: -------------------------------------------------------------------------------- 1 | function safeTagsReplace(str) { 2 | return str.replace(/&/g, '&') 3 | .replace(//g, '>') 5 | .replace(/\{/g, '{') 6 | .replace(/\}/g, '}') 7 | }; 8 | 9 | function propesc(s) { 10 | return safeTagsReplace(s).replace(/"/g, '"') 11 | }; 12 | 13 | function Tag(type, inner, attributes) { 14 | this.type = type; 15 | this.inner = inner || ''; 16 | this.attributes = attributes; 17 | }; 18 | Tag.prototype.toString = function () { 19 | return '<' + this.type + (this.attributes ? ' ' + this.attributes : '') + '>' + ('' + this.inner) + '' 20 | }; 21 | 22 | function VoidTag(type) { 23 | Tag.apply(this, arguments); 24 | }; 25 | VoidTag.prototype = Object.create(Tag.prototype); 26 | VoidTag.prototype.toString = function () { 27 | if (!this.inner) { 28 | return '<' + this.type + (this.attributes ? ' ' + this.attributes : '') + '/>' 29 | } else { 30 | return Tag.prototype.toString.apply(this, arguments) 31 | } 32 | }; 33 | 34 | function BlockTag(type) { 35 | Tag.apply(this, arguments); 36 | }; 37 | BlockTag.prototype = Object.create(Tag.prototype); 38 | BlockTag.prototype.toString = function () { 39 | return Tag.prototype.toString.apply(this, arguments) + '\n' 40 | } 41 | 42 | function AttributeList(items) { 43 | this.items = items; 44 | }; 45 | AttributeList.prototype.toString = function () { return this.items.join(' ') } 46 | 47 | function concatParagraphSegments(tagname, segments) { 48 | var buffer = []; 49 | var workset = []; 50 | for (var j = 0; j < segments.length; j++) { 51 | if (segments[j] instanceof BlockTag) { 52 | if (workset.length) { 53 | if (workset.length === 1) buffer.push(this.tags[tagname](workset[0])) 54 | else buffer.push(this.tags[tagname](workset.join('\n'))) 55 | workset = [] 56 | } 57 | buffer.push(segments[j]) 58 | } else if (segments[j] !== undefined) { 59 | workset.push(segments[j]) 60 | } 61 | 62 | } 63 | if (workset.length) { 64 | if (workset.length === 1) buffer.push(this.tags[tagname](workset[0])) 65 | else buffer.push(this.tags[tagname](workset.join('\n'))) 66 | workset = [] 67 | }; 68 | return this['.cons_block'].apply(this, buffer); 69 | }; 70 | function removeLeftCommonIndent(text) { 71 | var segments = text.replace(/\r\n/g, '\n').split('\n'); 72 | if (!segments.length) return ''; 73 | var commonIndent = null; 74 | for (var j = 0; j < segments.length; j++) { 75 | var segment = segments[j] 76 | if (segments[j].trim() && commonIndent !== '') { 77 | // Calculate the most-common indent of non-blank lines 78 | if (commonIndent === null) { 79 | commonIndent = segment.match(/^[ \t]*/)[0]; 80 | } else if (segment.slice(0, commonIndent.length) !== commonIndent) { 81 | // Calculate the common indentation 82 | var k = 0; 83 | while (k < segment.length && commonIndent.length && commonIndent[k] === segment[k]) { 84 | k += 1 85 | }; 86 | commonIndent = commonIndent.slice(0, k); 87 | } 88 | } 89 | }; 90 | for (var j = 0; j < segments.length; j++) { 91 | if (segments[j].trim()) { 92 | segments[j] = segments[j].slice(commonIndent.length) 93 | } else { 94 | segments[j] = '' 95 | } 96 | }; 97 | return segments.join('\n'); 98 | } 99 | exports.removeLeftCommonIndent = removeLeftCommonIndent; 100 | 101 | exports.apply = function (scope, exports, runtime) { 102 | exports.dothtml = { 103 | dotlit: safeTagsReplace, 104 | dotcodespan: function (text) { 105 | return exports.tags.code(safeTagsReplace(removeLeftCommonIndent(text))) 106 | }, 107 | dotverbatim: function (text) { 108 | return safeTagsReplace(removeLeftCommonIndent(text)) 109 | }, 110 | dotp: function (content) { 111 | return concatParagraphSegments.call(this, 'p', arguments) 112 | }, 113 | dotli: function (lead, rear) { 114 | if (rear) { 115 | return exports.tags.li(lead + rear) 116 | } else { 117 | return exports.tags.li(lead) 118 | } 119 | }, 120 | dotul: function (content) { 121 | return exports.tags.ul.call(this, scope['.cons_block'].apply(this, arguments)) 122 | }, 123 | dotol: function (content) { 124 | return exports.tags.ol.call(this, scope['.cons_block'].apply(this, arguments)) 125 | }, 126 | dotstrong: function (content) { 127 | return exports.tags.strong(content) 128 | }, 129 | dotem: function (content) { 130 | return exports.tags.em(content) 131 | } 132 | }; 133 | var constructTag = function (Type, name, args) { 134 | var unParametrized = []; 135 | var attributes = new AttributeList([]); 136 | for (var j = 0; j < args.length; j++) { 137 | if (args[j] instanceof runtime.AttributeName) { 138 | attributes.items.push(args[j].id + '="' + propesc(args[++j]) + '"') 139 | } else if (args[j] instanceof AttributeList) { 140 | attributes.items = attributes.items.concat(args[j].items) 141 | } else { 142 | unParametrized.push(args[j]) 143 | } 144 | }; 145 | if (unParametrized.length > 1) { 146 | if (attributes.items.length) { 147 | attributes = attributes + unParametrized[0]; 148 | } else { 149 | attributes = unParametrized[0] 150 | } 151 | return new Type(name, unParametrized[1], attributes) 152 | } else { 153 | if (!attributes.items.length) attributes = void 0; 154 | return new Type(name, unParametrized[0], attributes) 155 | } 156 | } 157 | exports.tags = {}; 158 | exports.tag = function (tagname, h, b) { 159 | return constructTag(Tag, tagname, [].slice.call(arguments, 1)); 160 | }; 161 | exports['define-tag'] = new runtime.Macro(function ($name, $properties) { 162 | var tagname = $name.id; 163 | var properties = this.evaluate($properties); 164 | var tagtype = properties.type; 165 | var tagpre = properties.pre; 166 | var expose = !properties.notexpose; 167 | var TagClass = (tagtype === 'void' ? VoidTag 168 | : tagtype === 'block' ? BlockTag 169 | : Tag); 170 | 171 | exports.tags[tagname] = function (h, b) { 172 | return constructTag(TagClass, tagname, arguments); 173 | }; 174 | if (expose) { 175 | if (tagpre) { 176 | exports[tagname] = new runtime.Macro(function ($args) { 177 | for (var j = 0; j < arguments.length; j++) { 178 | if (arguments[j][0] && arguments[j][0].id === '.attribute') { ++j }; 179 | if (arguments[j][0] && arguments[j][0].id === '.id' && typeof arguments[j][1] === 'string') { 180 | arguments[j] = safeTagsReplace(removeLeftCommonIndent(arguments[j][1].replace(/^\s*\n/, ''))) 181 | } 182 | }; 183 | var a = [] 184 | for (var j = 0; j < arguments.length; j++) { 185 | a[j] = this.evaluate(arguments[j]) 186 | } 187 | return exports.tags[tagname].call(this, a) 188 | }) 189 | } else { 190 | exports[tagname] = exports.tags[tagname]; 191 | } 192 | } 193 | return exports.tags[tagname]; 194 | }); 195 | 196 | exports['html-attributes'] = exports['attrs'] = new runtime.Macro(function () { 197 | var buff = []; 198 | for (var j = 0; j < arguments.length; j++) { 199 | var s = arguments[j].definingScope; 200 | if (arguments[j] instanceof Array && arguments[j][0] instanceof runtime.Reference) { 201 | buff.push(arguments[j][0].id + "=\"" + propesc(runtime.evaluate(s, arguments[j][1])) + "\"") 202 | } 203 | } 204 | return new AttributeList(buff) 205 | }); 206 | exports['with-attributes'] = function (attributes, tag) { 207 | if (tag instanceof Tag && !tag.attributes && attributes instanceof AttributeList) { 208 | var tag1 = Object.create(tag); 209 | tag1.attributes = attributes; 210 | return tag1 211 | } else if (tag instanceof Tag && tag.attributes instanceof AttributeList && attributes instanceof AttributeList) { 212 | var tag1 = Object.create(tag); 213 | tag1.attributes = new AttributeList(tag.attributes.items.concat(attributes.items)); 214 | return tag1 215 | } else { 216 | return tag 217 | } 218 | }; 219 | exports['with-class'] = function (classname, tag) { 220 | return exports['with-attributes'](new AttributeList(["class=" + classname]), tag) 221 | }; 222 | require('./tagtypes.yk').apply(scope, exports, runtime); 223 | } -------------------------------------------------------------------------------- /lib/youki-syntax.pegjs: -------------------------------------------------------------------------------- 1 | /* This is the syntax for Youki */ 2 | /* Expressions */ 3 | { 4 | var Reference = options.Reference; 5 | var Position = options.Position; 6 | var storedVerbatimTerminator; 7 | var formLine = function(content) { 8 | if(content.length === 1) return content[0] 9 | else return [new Reference('.cons_line')].concat(content) 10 | }; 11 | var formBlock = function(content) { 12 | if(content.length === 1) return content[0] 13 | else return [new Reference('.cons_block')].concat(content) 14 | }; 15 | var nVerbatimTests = 0; 16 | var textIndentStack = []; 17 | var textIndent = ""; 18 | } 19 | start = blockContent 20 | 21 | expression 22 | = invoke 23 | / quote 24 | / quasiquote 25 | / unquote 26 | / verbatim 27 | / textblock 28 | / attribute 29 | / identifier 30 | / literal 31 | 32 | expressionitems 33 | = head:expression rear:(OPTIONAL_EXPRESSION_SPACES expression)* { 34 | var res = [head] 35 | for(var j = 0; j < rear.length; j++){ 36 | res.push(rear[j][1]) 37 | }; 38 | return res; 39 | } 40 | invoke 41 | = begins:POS "[" 42 | OPTIONAL_EXPRESSION_SPACES 43 | inside:expressionitems 44 | OPTIONAL_EXPRESSION_SPACES 45 | "]" ends:POS { 46 | var call = inside.slice(0); 47 | Object.defineProperty(call, 'begins', { 48 | value: begins, 49 | enumerable: false 50 | }); 51 | Object.defineProperty(call, 'ends', { 52 | value: ends, 53 | enumerable: false 54 | }); 55 | return call 56 | } 57 | 58 | quote 59 | = "'" it:(invoke/verbatim/textblock/identifier) { return [new Reference('quote'), it] } 60 | quasiquote 61 | = '`' it:(invoke/verbatim/textblock/identifier) { return [new Reference('quasiquote'), it] } 62 | unquote 63 | = ',' it:(invoke/verbatim/textblock/identifier) { return [new Reference('unquote'), it] } 64 | attribute 65 | = ":" it:identifier { return [new Reference('.attribute'), it.id] } 66 | literal 67 | = numberliteral 68 | / stringliteral 69 | 70 | /* Texts */ 71 | 72 | textblock 73 | = "{" inside:line "}" { 74 | return inside 75 | } 76 | / "{" 77 | INDENT_CLEAR_ON 78 | inner:textBlockInner 79 | INDENT_CLEAR_OFF 80 | NEWLINE* 81 | "}" { return formBlock(inner) } 82 | 83 | textBlockInner 84 | = NEWLINE_INDENT_ADD bc:blockContent &(NEWLINE* "}") INDENT_REMOVE { return bc } 85 | / bc:blockContent { return bc } 86 | 87 | blockContent 88 | = head:blockSection rear:(PARAGRAPH_BREAK blockSection)* { 89 | var res = [head] 90 | for(var j = 0; j < rear.length; j++){ 91 | res.push(rear[j][1]) 92 | }; 93 | return res; 94 | } 95 | 96 | blockSection 97 | = head:blockSectionPart rear:(TEXT_IN_SEGMENT_LINEBREAK blockSectionPart)* { 98 | var res = [head]; 99 | for(var j = 0; j < rear.length; j++){ 100 | res.push(rear[j][1]) 101 | }; 102 | return formBlock(res); 103 | } 104 | 105 | blockSectionPart 106 | = everlasting 107 | / indentedVerbatimOperate 108 | / indentedOperate 109 | / ul 110 | / ol 111 | / paragraph 112 | 113 | everlasting = leader:invoke "::" NEWLINE rear:blockContent { 114 | return leader.concat([formBlock(rear)]) 115 | } 116 | indentedVerbatimOperate = leader:invoke '|' leadingSpaces:$(NEWLINE_INDENT_ADD) rear:indentedVerbatimLines INDENT_REMOVE { 117 | return leader.concat(leadingSpaces + rear) 118 | } 119 | indentedOperate = leader:invoke ':' NEWLINE_INDENT_ADD rear:blockContent INDENT_REMOVE { 120 | return leader.concat([formBlock(rear)]) 121 | } 122 | 123 | indentedVerbatimLines = $([^\r\n]+ (NEWLINE_INDENT_SAME_OR_MORE [^\r\n]+)*) 124 | 125 | 126 | paragraph = head:line rear:(TEXT_IN_SEGMENT_LINEBREAK line)* { 127 | var res = [new Reference('.p'), head]; 128 | for(var j = 0; j < rear.length; j++){ 129 | res.push(rear[j][1]) 130 | }; 131 | return res; 132 | } 133 | 134 | ul 135 | = head:ulli rear:(TEXT_IN_SEGMENT_LINEBREAK ulli)* { 136 | var res = [new Reference('.ul'), head]; 137 | for(var j = 0; j < rear.length; j++){ 138 | res.push(rear[j][1]) 139 | }; 140 | return res; 141 | } 142 | / head:ulliAlt rear:(TEXT_IN_SEGMENT_LINEBREAK ulliAlt)* { 143 | var res = [new Reference('.ul'), head]; 144 | for(var j = 0; j < rear.length; j++){ 145 | res.push(rear[j][1]) 146 | }; 147 | return res; 148 | } 149 | 150 | ulli = "-" SPACES? lead:line NEWLINE_INDENT_ADD rear:(ul / ol) INDENT_REMOVE { 151 | return [new Reference('.li'), lead, rear] 152 | } 153 | / "-" SPACES? content:line { return [new Reference('.li'), content] } 154 | ulliAlt = "+" SPACES? lead:line NEWLINE_INDENT_ADD rear:(ul / ol) INDENT_REMOVE { 155 | return [new Reference('.li'), lead, rear] 156 | } 157 | / "+" SPACES? content:line { return [new Reference('.li'), content] } 158 | 159 | ol = head:olli rear:(TEXT_IN_SEGMENT_LINEBREAK olli)* { 160 | var res = [new Reference('.ol'), head]; 161 | for(var j = 0; j < rear.length; j++){ 162 | res.push(rear[j][1]) 163 | }; 164 | return res; 165 | } 166 | 167 | olli = "#" SPACES? lead:line NEWLINE_INDENT_ADD rear:(ul / ol) INDENT_REMOVE { 168 | return [new Reference('.li'), lead, rear] 169 | } 170 | / "#" SPACES? content:line { return [new Reference('.li'), content] } 171 | 172 | line = ![+\-#] !(invoke ("::"/":"/"|") NEWLINE) content:lineitem* { return formLine(content) } 173 | 174 | lineitem = lineInvoke / lineVerbatim / textblock / lineDoubleStar / lineSingleStar / lineEscape / lineText 175 | lineitemWithoutDoubleStar = lineInvoke / lineVerbatim / textblock / lineSingleStar / lineEscape / lineText 176 | lineitemWithoutSingleStar = lineInvoke / lineVerbatim / textblock / lineDoubleStar / lineEscape / lineText 177 | 178 | lineInvoke = head:invoke rear:(lineVerbatim / textblock)? { 179 | if(rear && rear.length) 180 | return head.concat([rear]) 181 | else 182 | return head 183 | } 184 | 185 | lineVerbatim = it:verbatim { return [new Reference('.verbatim'), it] } 186 | / it:codeSpan { return [new Reference('.codespan'), it] } 187 | lineEscape = "\\" special:[+#\-=`*:\[\]\{\}\\] { return [new Reference('.lit'), special]} 188 | / '\\' normal:[^\r\n] { return [new Reference('.lit'), '\\' + normal] } 189 | 190 | lineText "Text" = t:$([^\r\n\[\{\\\}\]*`]+) { return [new Reference('.lit'), t] } 191 | lineDoubleStar = "**" inner:lineitemWithoutDoubleStar* "**" { return [new Reference('.inline**'), formLine(inner)] } 192 | lineSingleStar = "*" !"*" inner:lineitemWithoutSingleStar* "*" { return [new Reference('.inline*'), formLine(inner)] } 193 | 194 | 195 | /* Tokens */ 196 | stringliteral "String Literal" 197 | = "\"" inner:stringcharacter* "\"" { return inner.join('') } 198 | stringcharacter 199 | = [^"\\\r\n] 200 | / "\\u" digits:([a-fA-F0-9] [a-fA-F0-9] [a-fA-F0-9] [a-fA-F0-9]) { 201 | return String.fromCharCode(parseInt(digits.join(''), 16)) 202 | } 203 | / "\\" which:[^u\r\n] { 204 | switch(which) { 205 | case('n'): return "\n" 206 | case('r'): return "\r" 207 | case('"'): return "\"" 208 | case('t'): return "\t" 209 | case('v'): return "\v" 210 | default: return "\\" + which 211 | } 212 | } 213 | / "\\" NEWLINE "\\" { return '' } 214 | 215 | codeSpan "Code Span" 216 | = "`" val:$([^`]+) "`" { return val } 217 | / terminator:$("`" "`"+) & { storedVerbatimTerminator = terminator; return true } 218 | inner: $(codeSpanInner*) 219 | codeSpanTerminator { return inner } 220 | codeSpanInner 221 | = [^`]+ 222 | / !codeSpanTerminator "`" 223 | codeSpanTerminator 224 | = term:$("`" "`"+) & { term === storedVerbatimTerminator } { return } 225 | verbatim "Verbatim Segment" 226 | = "{|" val:$(([^|] / "|"+ [^|\}])*) "|}" { return val } 227 | / "{" terminator:verbatimEqualSequence "|" & { storedVerbatimTerminator = terminator; return true } 228 | inner:$(verbatimInner*) 229 | verbatimTerminator { return inner } 230 | verbatimInner 231 | = content:$([^|]+) { return content } 232 | / !verbatimTerminator content:"|" { return content } 233 | verbatimTerminator 234 | = "|" terminator:verbatimEqualSequence "}" & { return terminator === storedVerbatimTerminator } { return } 235 | verbatimEqualSequence 236 | = equals:$("="+) { return equals } 237 | numberliteral "Numeric Literal" 238 | = '-' positive:numberliteral { return -positive } 239 | / ("0x" / "0X") hexdigits:$([0-9a-fA-F]+) { return parseInt(hexdigits, 16) } 240 | / decimal:$([0-9]+ ("." [0-9]+)? ([eE] [+\-]? [0-9]+)?) { return decimal - 0 } 241 | identifier "Identifier" 242 | = begins:POS it:$([a-zA-Z\-_/+*<=>!?$%_&~^@#] [a-zA-Z0-9\.\-_/+*<=>!?$%_&~^@#]*) ends:POS { 243 | var ref = new Reference(it); 244 | Object.defineProperty(ref, 'begins', { 245 | value: begins, 246 | enumerable: false 247 | }); 248 | Object.defineProperty(ref, 'ends', { 249 | value: ends, 250 | enumerable: false 251 | }); 252 | return ref; 253 | } 254 | textidentifier "Embedded Identifier" 255 | = it:$([a-zA-Z_$] [a-zA-Z0-9_]*) { return new Reference(it) } 256 | 257 | // Spaces 258 | SPACE_CHARACTER "Space Character" 259 | = [\t\v\f \u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF] 260 | LINE_BREAK "Line Break" 261 | = "\r"? "\n" 262 | SPACE_CHARACTER_OR_NEWLINE "Space Character or Newline" 263 | = [\t\v\f \u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF\r\n] 264 | COMMENT "Comment" 265 | = $(";" [^\r\n]* LINE_BREAK) 266 | SPACES "Space without Newline" 267 | = $(SPACE_CHARACTER+) 268 | EXPRESSION_SPACE 269 | = SPACE_CHARACTER_OR_NEWLINE 270 | / COMMENT 271 | OPTIONAL_EXPRESSION_SPACES 272 | = $(EXPRESSION_SPACE*) 273 | 274 | PARAGRAPH_BREAK "Paragraph Break" 275 | = LINE_BREAK (SPACES? LINE_BREAK)+ INDENT_SAME 276 | NEWLINE 277 | = LINE_BREAK SPACE_CHARACTER_OR_NEWLINE* 278 | TEXT_IN_SEGMENT_LINEBREAK "Single Newline" 279 | = LINE_BREAK INDENT_SAME !(LINE_BREAK) 280 | NEWLINE_INDENT_ADD 281 | = LINE_BREAK SPACES? NEWLINE_INDENT_ADD 282 | / LINE_BREAK INDENT_ADD 283 | NEWLINE_INDENT_SAME 284 | = LINE_BREAK SPACES? NEWLINE_INDENT_SAME 285 | / LINE_BREAK INDENT_SAME 286 | NEWLINE_INDENT_SAME_OR_MORE 287 | = LINE_BREAK (SPACES? LINE_BREAK)* INDENT_SAME_OR_MORE 288 | 289 | POS = "" { return Position(location()) } 290 | 291 | INDENT_CLEAR_ON = "" { textIndentStack.push(textIndent); textIndent = "" } 292 | INDENT_CLEAR_OFF = "" { textIndent = textIndentStack.pop() } 293 | INDENT_ADD = spaces:SPACES & { return spaces.length > textIndent.length && spaces.slice(0, textIndent.length) === textIndent } 294 | { textIndentStack.push(textIndent); textIndent = spaces } 295 | INDENT_REMOVE = "" { textIndent = textIndentStack.pop() } 296 | INDENT_SAME = spaces:$(SPACES?) & { return spaces === textIndent } 297 | INDENT_SAME_OR_MORE = spaces:$(SPACES?) & { return spaces === textIndent || spaces.slice(0, textIndent.length) === textIndent } -------------------------------------------------------------------------------- /lib/runtime.js: -------------------------------------------------------------------------------- 1 | /// Youki Runtime 2 | var util = require('util'); 3 | /// Runtime Types 4 | var Scope = function(){ } 5 | Scope.prototype.toString = function(){ return '[scope]' } 6 | var Macro = function(f) { 7 | this.apply = function(t, a){ 8 | return f.apply(t, a) 9 | } 10 | }; 11 | var Reference = function(id) { 12 | this.id = id; 13 | }; 14 | Reference.prototype.toString = function(){ 15 | return this.id 16 | }; 17 | var AttributeName = function(id) { 18 | this.id = id; 19 | }; 20 | AttributeName.prototype.toString = function(){ 21 | return this.id 22 | }; 23 | 24 | var serializeForm = function(form, level){ 25 | if(level <= 0) return '...'; 26 | if(form instanceof Reference) return form.id; 27 | if(form instanceof Array) { 28 | return '[' + form.map(function(item){ return serializeForm(item, level - 1) }).join(' ') + ']' 29 | } 30 | return util.inspect(form); 31 | }; 32 | 33 | var EvaluationError = function(reason, form){ 34 | this.message = reason; 35 | if(form) { 36 | this.message += "\nIn form " + serializeForm(form); 37 | if(form.begins && form.ends) { 38 | var filename = form.begins.module.filename; 39 | this.message += '\n\nWithin file ' + filename; 40 | this.message += '\nRelated source ' + form.begins.module.exports.source.slice(form.begins.offset, form.ends.offset); 41 | } 42 | } 43 | } 44 | EvaluationError.prototype = Object.create(Error.prototype); 45 | 46 | /// Runtime Functions 47 | var setf = function(base, shift, value){ 48 | if(!/\//.test(shift) || shift[0] === '/'){ 49 | return (base[shift] = value) 50 | } else { 51 | var idSegments = shift.split('/'); 52 | for(var i = 0; base && i < idSegments.length - 1; i++){ 53 | if(!(idSegments[i] in base)) { 54 | base = base[idSegments[i]] = {}; 55 | } else { 56 | base = base[idSegments[i]] 57 | } 58 | } 59 | return (base[idSegments[idSegments.length - 1]] = value); 60 | } 61 | }; 62 | var getf = function(base, shift) { 63 | if(!/\//.test(shift) || shift[0] === '/'){ 64 | return (base[shift]) 65 | } else { 66 | var idSegments = shift.split('/'); 67 | for(var i = 0; base && i < idSegments.length; i++){ 68 | base = base[idSegments[i]] 69 | if(base === undefined) { return base } 70 | } 71 | return base; 72 | } 73 | }; 74 | var thunk = function(scope, form){ 75 | if(typeof form === 'string' || typeof form === 'number') return thunk(scope, [new Reference('.id'), form]); 76 | var th = (form instanceof Array ? form.slice(0) : Object.create(form)); 77 | Object.defineProperty(th, 'definingScope', { 78 | value: scope, 79 | writable: false, 80 | enumerable: false 81 | }); 82 | return th; 83 | } 84 | var evaluate = function(scope, form) { 85 | if(form instanceof Array) { 86 | // An Invoke Node 87 | if(!form.length) return undefined; 88 | var fn = evaluate(scope, form[0]); 89 | var args = []; 90 | if(fn && fn instanceof Macro) { 91 | for(var j = 1; j < form.length; j++) { 92 | args.push(thunk(scope, form[j])) 93 | }; 94 | } else if(fn && fn instanceof Function) { 95 | for(var j = 1; j < form.length; j++) { 96 | args.push(evaluate(scope, form[j])) 97 | }; 98 | } else { 99 | throw new EvaluationError("Expression " + serializeForm(form[0], 3) + ' is being invoked but it is not a function.', form); 100 | } 101 | return fn.apply(scope, args); 102 | } else if(form instanceof Reference) { 103 | // An Reference Node 104 | return getf(scope, form.id); 105 | } else { 106 | return form; 107 | } 108 | }; 109 | /// Global Scope 110 | var globalScope = new Scope; 111 | globalScope['.globalScope'] = globalScope; 112 | globalScope['.id'] = function(name) { 113 | return getf(this, name); 114 | } 115 | globalScope['setf'] = new Macro(function($base, $name, $value){ 116 | var base; 117 | if(arguments.length < 3) { 118 | $value = arguments[1] 119 | $name = arguments[0] 120 | base = this; 121 | } else { 122 | base = globalScope.evaluate($base); 123 | } 124 | if(!($name instanceof Reference)) throw "Unexpected \\setf Pattern " + util.inspect($name) 125 | var value = globalScope.evaluate($value); 126 | return setf(base, $name.id, value); 127 | }); 128 | 129 | globalScope.evaluate = function(thunk){ 130 | return evaluate(thunk.definingScope, thunk) 131 | } 132 | globalScope['evaluate-here'] = function(form){ 133 | return evaluate(this, form) 134 | } 135 | globalScope['evaluate-in-scope'] = function(scope, form){ 136 | return evaluate(scope, form); 137 | } 138 | globalScope['lambda'] = new Macro(function(){ 139 | // A lambda is an anonymous function, which is always 140 | // statically scoped and call-by-name. 141 | var defScope = this; 142 | var $parnames = []; 143 | var $body = arguments[arguments.length - 1]; 144 | for(var j = 0; j < arguments.length - 1; j++){ 145 | if(arguments[j] instanceof Reference && !/\//.test(arguments[j].id)) { 146 | $parnames[j] = arguments[j].id 147 | } else { 148 | throw "Unexpected Parameter Pattern " + arguments[j] 149 | } 150 | }; 151 | return function(){ 152 | var s = Object.create(defScope); 153 | for(var j = 0; j < arguments.length && j < $parnames.length; j++) { 154 | setf(s, $parnames[j], arguments[j]); 155 | }; 156 | setf(s, '##', arguments); 157 | return evaluate(s, $body); 158 | } 159 | }); 160 | globalScope['macro'] = new Macro(function(){ 161 | // The \macro is defined to create a macro which allows 162 | // dynamic scoping and call-by-need. It is just a \lambda 163 | // with \invokeScope appended. 164 | var defScope = this; 165 | var $parnames = []; 166 | var $body = arguments[arguments.length - 1]; 167 | for(var j = 0; j < arguments.length - 1; j++){ 168 | if(arguments[j] instanceof Reference && !/\//.test(arguments[j].id)) { 169 | $parnames[j] = arguments[j].id 170 | } else { 171 | throw "Unexpected Parameter Pattern " + arguments[j] 172 | } 173 | }; 174 | return new Macro(function(){ 175 | var s = Object.create(defScope); 176 | for(var j = 0; j < arguments.length && j < $parnames.length; j++) { 177 | setf(s, $parnames[j], arguments[j]); 178 | }; 179 | setf(s, '##', arguments); 180 | setf(s, 'clientScope', this); 181 | return evaluate(s, $body); 182 | }) 183 | }); 184 | globalScope['closure'] = function(scope, form){ 185 | return thunk(scope, form); 186 | } 187 | var flatBlockInvokes = function($block){ 188 | if($block[0] instanceof Reference && $block[0].id === '.cons_block') { 189 | return $block.slice(1).map(flatBlockInvokes); 190 | } else if($block[0] instanceof Reference && $block[0].id === '.p') { 191 | return $block[1] 192 | } else { 193 | return $block 194 | } 195 | }; 196 | 197 | globalScope['do'] = new Macro(function($block){ 198 | var SIGNAL_RETURN = {} 199 | var s = Object.create($block.definingScope); 200 | var result = void 0; 201 | setf(s, 'return', function(x){ 202 | result = x; 203 | throw SIGNAL_RETURN; 204 | }); 205 | try { 206 | evaluate(s, $block); 207 | } catch(ex) { 208 | if(ex === SIGNAL_RETURN) return result; 209 | else throw ex; 210 | } 211 | return result 212 | }); 213 | globalScope['begin'] = function(){ 214 | return arguments[arguments.length - 1] 215 | }; 216 | globalScope['list'] = function(){ 217 | return [].slice.call(arguments, 0) 218 | }; 219 | globalScope['quote'] = new Macro(function($block){ return $block }); 220 | var expandQuasiQuote = function(scope, form){ 221 | if(form instanceof Array) { 222 | if(form[0] && form[0] instanceof Reference && form[0].id === 'unquote') { 223 | return evaluate(scope, form[1]) 224 | } else { 225 | var result = [] 226 | for(var j = 0; j < form.length; j++) { 227 | if(form[j] instanceof Array && form[j][0] instanceof Reference && form[j][0].id === 'unquote-splicing') { 228 | result = result.concat(evaluate(scope, form[j][1])) 229 | } else { 230 | result[j] = expandQuasiQuote(scope, form[j]) 231 | } 232 | } 233 | return result 234 | } 235 | } else { 236 | return form; 237 | } 238 | } 239 | globalScope['quasiquote'] = new Macro(function($block){ 240 | return thunk($block.definingScope || this, expandQuasiQuote($block.definingScope, $block)) 241 | }); 242 | globalScope['unquote'] = function(){ throw new Error('Unquote cannot occur directly.') } 243 | globalScope['unquote-splicing'] = function(){ throw new Error('Unquote cannot occur directly.') } 244 | globalScope['.nil'] = void 0; 245 | globalScope['.lit'] = globalScope['.verbatim'] = globalScope['.codespan'] = function(s){ return '' + s } 246 | globalScope['.id'] = function(s){ return s } 247 | globalScope['.attribute'] = function(s){ return new AttributeName(s) } 248 | globalScope['.p'] = globalScope['.li'] = globalScope['.cons_line'] = globalScope['.cons_block'] = globalScope['.ol'] = globalScope['.ul'] = function(){ 249 | var buff = ''; 250 | var ntf = 0; 251 | var ctf; 252 | for(var i = 0; i < arguments.length; i++) { 253 | var tf = arguments[i]; 254 | if(tf != undefined && tf !== '') { 255 | buff += tf; 256 | ntf += 1; 257 | ctf = tf; 258 | } 259 | } 260 | if(ntf === 1){ 261 | return ctf 262 | } else { 263 | return buff; 264 | } 265 | } 266 | 267 | globalScope.invoke = function(f, args){ 268 | return f.apply(this, [].slice.call(arguments, 1)) 269 | } 270 | globalScope.apply = function(f, args){ 271 | return f.apply(this, args) 272 | } 273 | globalScope['true'] = true; 274 | globalScope['false'] = false; 275 | globalScope['null'] = null; 276 | globalScope['undefined'] = undefined; 277 | globalScope['nothing'] = undefined; 278 | globalScope['if'] = new Macro(function($condition, $consequent, $alternate){ 279 | if(globalScope.evaluate($condition)) { 280 | return globalScope.evaluate($consequent) 281 | } else if($alternate) { 282 | return globalScope.evaluate($alternate) 283 | } 284 | }); 285 | globalScope['while'] = new Macro(function($condition, $body){ 286 | var r = undefined; 287 | while(globalScope.evaluate($condition)) { 288 | r = globalScope.evaluate($body) 289 | }; 290 | return r; 291 | }); 292 | globalScope['foreach-property'] = new Macro(function($name, $object, $body){ 293 | var r = undefined; 294 | var obj = globalScope.evaluate($object); 295 | var s = Object.create($body.definingScope); 296 | for(var prop in obj) { 297 | setf(s, $name.id, prop); 298 | r = evaluate(s, $body) 299 | }; 300 | return r; 301 | }); 302 | globalScope['do-while'] = new Macro(function($condition, $body){ 303 | var r = globalScope.evaluate($body); 304 | while(globalScope.evaluate($condition)) { 305 | r = globalScope.evaluate($body) 306 | }; 307 | return r; 308 | }); 309 | globalScope['cond'] = new Macro(function(){ 310 | for(var j = 0; j < arguments.length; j++){ 311 | var clause = arguments[j] 312 | if(!clause || !(clause instanceof Array) || !clause.definingScope) throw "Wrong cond pattern"; 313 | if(evaluate(clause.definingScope, clause[0])) { 314 | return evaluate(clause.definingScope, [new Reference("begin")].concat(clause.slice(1))) 315 | } 316 | } 317 | }); 318 | globalScope['comment'] = new Macro(function(){ }); 319 | globalScope['throw'] = function(ex) { 320 | throw ex; 321 | } 322 | globalScope['debugger'] = function(){ 323 | debugger; 324 | } 325 | 326 | exports.Macro = Macro; 327 | exports.Reference = Reference; 328 | exports.AttributeName = AttributeName; 329 | exports.getf = getf; 330 | exports.setf = setf; 331 | exports.globalScope = globalScope; 332 | exports.evaluate = evaluate; 333 | exports.thunk = thunk; 334 | exports.ref = function(id){ 335 | return new Reference(id) 336 | }; -------------------------------------------------------------------------------- /lib/youki-syntax.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by PEG.js 0.10.0. 3 | * 4 | * http://pegjs.org/ 5 | */ 6 | 7 | "use strict"; 8 | 9 | function peg$subclass(child, parent) { 10 | function ctor() { this.constructor = child; } 11 | ctor.prototype = parent.prototype; 12 | child.prototype = new ctor(); 13 | } 14 | 15 | function peg$SyntaxError(message, expected, found, location) { 16 | this.message = message; 17 | this.expected = expected; 18 | this.found = found; 19 | this.location = location; 20 | this.name = "SyntaxError"; 21 | 22 | if (typeof Error.captureStackTrace === "function") { 23 | Error.captureStackTrace(this, peg$SyntaxError); 24 | } 25 | } 26 | 27 | peg$subclass(peg$SyntaxError, Error); 28 | 29 | peg$SyntaxError.buildMessage = function(expected, found) { 30 | var DESCRIBE_EXPECTATION_FNS = { 31 | literal: function(expectation) { 32 | return "\"" + literalEscape(expectation.text) + "\""; 33 | }, 34 | 35 | "class": function(expectation) { 36 | var escapedParts = "", 37 | i; 38 | 39 | for (i = 0; i < expectation.parts.length; i++) { 40 | escapedParts += expectation.parts[i] instanceof Array 41 | ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) 42 | : classEscape(expectation.parts[i]); 43 | } 44 | 45 | return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; 46 | }, 47 | 48 | any: function(expectation) { 49 | return "any character"; 50 | }, 51 | 52 | end: function(expectation) { 53 | return "end of input"; 54 | }, 55 | 56 | other: function(expectation) { 57 | return expectation.description; 58 | } 59 | }; 60 | 61 | function hex(ch) { 62 | return ch.charCodeAt(0).toString(16).toUpperCase(); 63 | } 64 | 65 | function literalEscape(s) { 66 | return s 67 | .replace(/\\/g, '\\\\') 68 | .replace(/"/g, '\\"') 69 | .replace(/\0/g, '\\0') 70 | .replace(/\t/g, '\\t') 71 | .replace(/\n/g, '\\n') 72 | .replace(/\r/g, '\\r') 73 | .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) 74 | .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); 75 | } 76 | 77 | function classEscape(s) { 78 | return s 79 | .replace(/\\/g, '\\\\') 80 | .replace(/\]/g, '\\]') 81 | .replace(/\^/g, '\\^') 82 | .replace(/-/g, '\\-') 83 | .replace(/\0/g, '\\0') 84 | .replace(/\t/g, '\\t') 85 | .replace(/\n/g, '\\n') 86 | .replace(/\r/g, '\\r') 87 | .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) 88 | .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); 89 | } 90 | 91 | function describeExpectation(expectation) { 92 | return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); 93 | } 94 | 95 | function describeExpected(expected) { 96 | var descriptions = new Array(expected.length), 97 | i, j; 98 | 99 | for (i = 0; i < expected.length; i++) { 100 | descriptions[i] = describeExpectation(expected[i]); 101 | } 102 | 103 | descriptions.sort(); 104 | 105 | if (descriptions.length > 0) { 106 | for (i = 1, j = 1; i < descriptions.length; i++) { 107 | if (descriptions[i - 1] !== descriptions[i]) { 108 | descriptions[j] = descriptions[i]; 109 | j++; 110 | } 111 | } 112 | descriptions.length = j; 113 | } 114 | 115 | switch (descriptions.length) { 116 | case 1: 117 | return descriptions[0]; 118 | 119 | case 2: 120 | return descriptions[0] + " or " + descriptions[1]; 121 | 122 | default: 123 | return descriptions.slice(0, -1).join(", ") 124 | + ", or " 125 | + descriptions[descriptions.length - 1]; 126 | } 127 | } 128 | 129 | function describeFound(found) { 130 | return found ? "\"" + literalEscape(found) + "\"" : "end of input"; 131 | } 132 | 133 | return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; 134 | }; 135 | 136 | function peg$parse(input, options) { 137 | options = options !== void 0 ? options : {}; 138 | 139 | var peg$FAILED = {}, 140 | 141 | peg$startRuleFunctions = { start: peg$parsestart }, 142 | peg$startRuleFunction = peg$parsestart, 143 | 144 | peg$c0 = function(head, rear) { 145 | var res = [head] 146 | for(var j = 0; j < rear.length; j++){ 147 | res.push(rear[j][1]) 148 | }; 149 | return res; 150 | }, 151 | peg$c1 = "[", 152 | peg$c2 = peg$literalExpectation("[", false), 153 | peg$c3 = "]", 154 | peg$c4 = peg$literalExpectation("]", false), 155 | peg$c5 = function(begins, inside, ends) { 156 | var call = inside.slice(0); 157 | Object.defineProperty(call, 'begins', { 158 | value: begins, 159 | enumerable: false 160 | }); 161 | Object.defineProperty(call, 'ends', { 162 | value: ends, 163 | enumerable: false 164 | }); 165 | return call 166 | }, 167 | peg$c6 = "'", 168 | peg$c7 = peg$literalExpectation("'", false), 169 | peg$c8 = function(it) { return [new Reference('quote'), it] }, 170 | peg$c9 = "`", 171 | peg$c10 = peg$literalExpectation("`", false), 172 | peg$c11 = function(it) { return [new Reference('quasiquote'), it] }, 173 | peg$c12 = ",", 174 | peg$c13 = peg$literalExpectation(",", false), 175 | peg$c14 = function(it) { return [new Reference('unquote'), it] }, 176 | peg$c15 = ":", 177 | peg$c16 = peg$literalExpectation(":", false), 178 | peg$c17 = function(it) { return [new Reference('.attribute'), it.id] }, 179 | peg$c18 = "{", 180 | peg$c19 = peg$literalExpectation("{", false), 181 | peg$c20 = "}", 182 | peg$c21 = peg$literalExpectation("}", false), 183 | peg$c22 = function(inside) { 184 | return inside 185 | }, 186 | peg$c23 = function(inner) { return formBlock(inner) }, 187 | peg$c24 = function(bc) { return bc }, 188 | peg$c25 = function(head, rear) { 189 | var res = [head]; 190 | for(var j = 0; j < rear.length; j++){ 191 | res.push(rear[j][1]) 192 | }; 193 | return formBlock(res); 194 | }, 195 | peg$c26 = "::", 196 | peg$c27 = peg$literalExpectation("::", false), 197 | peg$c28 = function(leader, rear) { 198 | return leader.concat([formBlock(rear)]) 199 | }, 200 | peg$c29 = "|", 201 | peg$c30 = peg$literalExpectation("|", false), 202 | peg$c31 = function(leader, leadingSpaces, rear) { 203 | return leader.concat(leadingSpaces + rear) 204 | }, 205 | peg$c32 = function(leader, rear) { 206 | return leader.concat([formBlock(rear)]) 207 | }, 208 | peg$c33 = /^[^\r\n]/, 209 | peg$c34 = peg$classExpectation(["\r", "\n"], true, false), 210 | peg$c35 = function(head, rear) { 211 | var res = [new Reference('.p'), head]; 212 | for(var j = 0; j < rear.length; j++){ 213 | res.push(rear[j][1]) 214 | }; 215 | return res; 216 | }, 217 | peg$c36 = function(head, rear) { 218 | var res = [new Reference('.ul'), head]; 219 | for(var j = 0; j < rear.length; j++){ 220 | res.push(rear[j][1]) 221 | }; 222 | return res; 223 | }, 224 | peg$c37 = "-", 225 | peg$c38 = peg$literalExpectation("-", false), 226 | peg$c39 = function(lead, rear) { 227 | return [new Reference('.li'), lead, rear] 228 | }, 229 | peg$c40 = function(content) { return [new Reference('.li'), content] }, 230 | peg$c41 = "+", 231 | peg$c42 = peg$literalExpectation("+", false), 232 | peg$c43 = function(head, rear) { 233 | var res = [new Reference('.ol'), head]; 234 | for(var j = 0; j < rear.length; j++){ 235 | res.push(rear[j][1]) 236 | }; 237 | return res; 238 | }, 239 | peg$c44 = "#", 240 | peg$c45 = peg$literalExpectation("#", false), 241 | peg$c46 = /^[+\-#]/, 242 | peg$c47 = peg$classExpectation(["+", "-", "#"], false, false), 243 | peg$c48 = function(content) { return formLine(content) }, 244 | peg$c49 = function(head, rear) { 245 | if(rear && rear.length) 246 | return head.concat([rear]) 247 | else 248 | return head 249 | }, 250 | peg$c50 = function(it) { return [new Reference('.verbatim'), it] }, 251 | peg$c51 = function(it) { return [new Reference('.codespan'), it] }, 252 | peg$c52 = "\\", 253 | peg$c53 = peg$literalExpectation("\\", false), 254 | peg$c54 = /^[+#\-=`*:[\]{}\\]/, 255 | peg$c55 = peg$classExpectation(["+", "#", "-", "=", "`", "*", ":", "[", "]", "{", "}", "\\"], false, false), 256 | peg$c56 = function(special) { return [new Reference('.lit'), special]}, 257 | peg$c57 = function(normal) { return [new Reference('.lit'), '\\' + normal] }, 258 | peg$c58 = peg$otherExpectation("Text"), 259 | peg$c59 = /^[^\r\n[{\\}\]*`]/, 260 | peg$c60 = peg$classExpectation(["\r", "\n", "[", "{", "\\", "}", "]", "*", "`"], true, false), 261 | peg$c61 = function(t) { return [new Reference('.lit'), t] }, 262 | peg$c62 = "**", 263 | peg$c63 = peg$literalExpectation("**", false), 264 | peg$c64 = function(inner) { return [new Reference('.inline**'), formLine(inner)] }, 265 | peg$c65 = "*", 266 | peg$c66 = peg$literalExpectation("*", false), 267 | peg$c67 = function(inner) { return [new Reference('.inline*'), formLine(inner)] }, 268 | peg$c68 = peg$otherExpectation("String Literal"), 269 | peg$c69 = "\"", 270 | peg$c70 = peg$literalExpectation("\"", false), 271 | peg$c71 = function(inner) { return inner.join('') }, 272 | peg$c72 = /^[^"\\\r\n]/, 273 | peg$c73 = peg$classExpectation(["\"", "\\", "\r", "\n"], true, false), 274 | peg$c74 = "\\u", 275 | peg$c75 = peg$literalExpectation("\\u", false), 276 | peg$c76 = /^[a-fA-F0-9]/, 277 | peg$c77 = peg$classExpectation([["a", "f"], ["A", "F"], ["0", "9"]], false, false), 278 | peg$c78 = function(digits) { 279 | return String.fromCharCode(parseInt(digits.join(''), 16)) 280 | }, 281 | peg$c79 = /^[^u\r\n]/, 282 | peg$c80 = peg$classExpectation(["u", "\r", "\n"], true, false), 283 | peg$c81 = function(which) { 284 | switch(which) { 285 | case('n'): return "\n" 286 | case('r'): return "\r" 287 | case('"'): return "\"" 288 | case('t'): return "\t" 289 | case('v'): return "\v" 290 | default: return "\\" + which 291 | } 292 | }, 293 | peg$c82 = function() { return '' }, 294 | peg$c83 = peg$otherExpectation("Code Span"), 295 | peg$c84 = /^[^`]/, 296 | peg$c85 = peg$classExpectation(["`"], true, false), 297 | peg$c86 = function(val) { return val }, 298 | peg$c87 = function(terminator) { storedVerbatimTerminator = terminator; return true }, 299 | peg$c88 = function(terminator, inner) { return inner }, 300 | peg$c89 = function(term) { term === storedVerbatimTerminator }, 301 | peg$c90 = function(term) { return }, 302 | peg$c91 = peg$otherExpectation("Verbatim Segment"), 303 | peg$c92 = "{|", 304 | peg$c93 = peg$literalExpectation("{|", false), 305 | peg$c94 = /^[^|]/, 306 | peg$c95 = peg$classExpectation(["|"], true, false), 307 | peg$c96 = /^[^|}]/, 308 | peg$c97 = peg$classExpectation(["|", "}"], true, false), 309 | peg$c98 = "|}", 310 | peg$c99 = peg$literalExpectation("|}", false), 311 | peg$c100 = function(content) { return content }, 312 | peg$c101 = function(terminator) { return terminator === storedVerbatimTerminator }, 313 | peg$c102 = function(terminator) { return }, 314 | peg$c103 = "=", 315 | peg$c104 = peg$literalExpectation("=", false), 316 | peg$c105 = function(equals) { return equals }, 317 | peg$c106 = peg$otherExpectation("Numeric Literal"), 318 | peg$c107 = function(positive) { return -positive }, 319 | peg$c108 = "0x", 320 | peg$c109 = peg$literalExpectation("0x", false), 321 | peg$c110 = "0X", 322 | peg$c111 = peg$literalExpectation("0X", false), 323 | peg$c112 = /^[0-9a-fA-F]/, 324 | peg$c113 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false), 325 | peg$c114 = function(hexdigits) { return parseInt(hexdigits, 16) }, 326 | peg$c115 = /^[0-9]/, 327 | peg$c116 = peg$classExpectation([["0", "9"]], false, false), 328 | peg$c117 = ".", 329 | peg$c118 = peg$literalExpectation(".", false), 330 | peg$c119 = /^[eE]/, 331 | peg$c120 = peg$classExpectation(["e", "E"], false, false), 332 | peg$c121 = /^[+\-]/, 333 | peg$c122 = peg$classExpectation(["+", "-"], false, false), 334 | peg$c123 = function(decimal) { return decimal - 0 }, 335 | peg$c124 = peg$otherExpectation("Identifier"), 336 | peg$c125 = /^[a-zA-Z\-_\/+*<=>!?$%_&~\^@#]/, 337 | peg$c126 = peg$classExpectation([["a", "z"], ["A", "Z"], "-", "_", "/", "+", "*", "<", "=", ">", "!", "?", "$", "%", "_", "&", "~", "^", "@", "#"], false, false), 338 | peg$c127 = /^[a-zA-Z0-9.\-_\/+*<=>!?$%_&~\^@#]/, 339 | peg$c128 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], ".", "-", "_", "/", "+", "*", "<", "=", ">", "!", "?", "$", "%", "_", "&", "~", "^", "@", "#"], false, false), 340 | peg$c129 = function(begins, it, ends) { 341 | var ref = new Reference(it); 342 | Object.defineProperty(ref, 'begins', { 343 | value: begins, 344 | enumerable: false 345 | }); 346 | Object.defineProperty(ref, 'ends', { 347 | value: ends, 348 | enumerable: false 349 | }); 350 | return ref; 351 | }, 352 | peg$c130 = peg$otherExpectation("Embedded Identifier"), 353 | peg$c131 = /^[a-zA-Z_$]/, 354 | peg$c132 = peg$classExpectation([["a", "z"], ["A", "Z"], "_", "$"], false, false), 355 | peg$c133 = /^[a-zA-Z0-9_]/, 356 | peg$c134 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_"], false, false), 357 | peg$c135 = function(it) { return new Reference(it) }, 358 | peg$c136 = peg$otherExpectation("Space Character"), 359 | peg$c137 = /^[\t\x0B\f \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF]/, 360 | peg$c138 = peg$classExpectation(["\t", "\x0B", "\f", " ", "\xA0", "\u1680", "\u180E", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u202F", "\u205F", "\u3000", "\uFEFF"], false, false), 361 | peg$c139 = peg$otherExpectation("Line Break"), 362 | peg$c140 = "\r", 363 | peg$c141 = peg$literalExpectation("\r", false), 364 | peg$c142 = "\n", 365 | peg$c143 = peg$literalExpectation("\n", false), 366 | peg$c144 = peg$otherExpectation("Space Character or Newline"), 367 | peg$c145 = /^[\t\x0B\f \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF\r\n]/, 368 | peg$c146 = peg$classExpectation(["\t", "\x0B", "\f", " ", "\xA0", "\u1680", "\u180E", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u202F", "\u205F", "\u3000", "\uFEFF", "\r", "\n"], false, false), 369 | peg$c147 = peg$otherExpectation("Comment"), 370 | peg$c148 = ";", 371 | peg$c149 = peg$literalExpectation(";", false), 372 | peg$c150 = peg$otherExpectation("Space without Newline"), 373 | peg$c151 = peg$otherExpectation("Paragraph Break"), 374 | peg$c152 = peg$otherExpectation("Single Newline"), 375 | peg$c153 = "", 376 | peg$c154 = function() { return Position(location()) }, 377 | peg$c155 = function() { textIndentStack.push(textIndent); textIndent = "" }, 378 | peg$c156 = function() { textIndent = textIndentStack.pop() }, 379 | peg$c157 = function(spaces) { return spaces.length > textIndent.length && spaces.slice(0, textIndent.length) === textIndent }, 380 | peg$c158 = function(spaces) { textIndentStack.push(textIndent); textIndent = spaces }, 381 | peg$c159 = function(spaces) { return spaces === textIndent }, 382 | peg$c160 = function(spaces) { return spaces === textIndent || spaces.slice(0, textIndent.length) === textIndent }, 383 | 384 | peg$currPos = 0, 385 | peg$savedPos = 0, 386 | peg$posDetailsCache = [{ line: 1, column: 1 }], 387 | peg$maxFailPos = 0, 388 | peg$maxFailExpected = [], 389 | peg$silentFails = 0, 390 | 391 | peg$result; 392 | 393 | if ("startRule" in options) { 394 | if (!(options.startRule in peg$startRuleFunctions)) { 395 | throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); 396 | } 397 | 398 | peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; 399 | } 400 | 401 | function text() { 402 | return input.substring(peg$savedPos, peg$currPos); 403 | } 404 | 405 | function location() { 406 | return peg$computeLocation(peg$savedPos, peg$currPos); 407 | } 408 | 409 | function expected(description, location) { 410 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) 411 | 412 | throw peg$buildStructuredError( 413 | [peg$otherExpectation(description)], 414 | input.substring(peg$savedPos, peg$currPos), 415 | location 416 | ); 417 | } 418 | 419 | function error(message, location) { 420 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) 421 | 422 | throw peg$buildSimpleError(message, location); 423 | } 424 | 425 | function peg$literalExpectation(text, ignoreCase) { 426 | return { type: "literal", text: text, ignoreCase: ignoreCase }; 427 | } 428 | 429 | function peg$classExpectation(parts, inverted, ignoreCase) { 430 | return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; 431 | } 432 | 433 | function peg$anyExpectation() { 434 | return { type: "any" }; 435 | } 436 | 437 | function peg$endExpectation() { 438 | return { type: "end" }; 439 | } 440 | 441 | function peg$otherExpectation(description) { 442 | return { type: "other", description: description }; 443 | } 444 | 445 | function peg$computePosDetails(pos) { 446 | var details = peg$posDetailsCache[pos], p; 447 | 448 | if (details) { 449 | return details; 450 | } else { 451 | p = pos - 1; 452 | while (!peg$posDetailsCache[p]) { 453 | p--; 454 | } 455 | 456 | details = peg$posDetailsCache[p]; 457 | details = { 458 | line: details.line, 459 | column: details.column 460 | }; 461 | 462 | while (p < pos) { 463 | if (input.charCodeAt(p) === 10) { 464 | details.line++; 465 | details.column = 1; 466 | } else { 467 | details.column++; 468 | } 469 | 470 | p++; 471 | } 472 | 473 | peg$posDetailsCache[pos] = details; 474 | return details; 475 | } 476 | } 477 | 478 | function peg$computeLocation(startPos, endPos) { 479 | var startPosDetails = peg$computePosDetails(startPos), 480 | endPosDetails = peg$computePosDetails(endPos); 481 | 482 | return { 483 | start: { 484 | offset: startPos, 485 | line: startPosDetails.line, 486 | column: startPosDetails.column 487 | }, 488 | end: { 489 | offset: endPos, 490 | line: endPosDetails.line, 491 | column: endPosDetails.column 492 | } 493 | }; 494 | } 495 | 496 | function peg$fail(expected) { 497 | if (peg$currPos < peg$maxFailPos) { return; } 498 | 499 | if (peg$currPos > peg$maxFailPos) { 500 | peg$maxFailPos = peg$currPos; 501 | peg$maxFailExpected = []; 502 | } 503 | 504 | peg$maxFailExpected.push(expected); 505 | } 506 | 507 | function peg$buildSimpleError(message, location) { 508 | return new peg$SyntaxError(message, null, null, location); 509 | } 510 | 511 | function peg$buildStructuredError(expected, found, location) { 512 | return new peg$SyntaxError( 513 | peg$SyntaxError.buildMessage(expected, found), 514 | expected, 515 | found, 516 | location 517 | ); 518 | } 519 | 520 | function peg$parsestart() { 521 | var s0; 522 | 523 | s0 = peg$parseblockContent(); 524 | 525 | return s0; 526 | } 527 | 528 | function peg$parseexpression() { 529 | var s0; 530 | 531 | s0 = peg$parseinvoke(); 532 | if (s0 === peg$FAILED) { 533 | s0 = peg$parsequote(); 534 | if (s0 === peg$FAILED) { 535 | s0 = peg$parsequasiquote(); 536 | if (s0 === peg$FAILED) { 537 | s0 = peg$parseunquote(); 538 | if (s0 === peg$FAILED) { 539 | s0 = peg$parseverbatim(); 540 | if (s0 === peg$FAILED) { 541 | s0 = peg$parsetextblock(); 542 | if (s0 === peg$FAILED) { 543 | s0 = peg$parseattribute(); 544 | if (s0 === peg$FAILED) { 545 | s0 = peg$parseidentifier(); 546 | if (s0 === peg$FAILED) { 547 | s0 = peg$parseliteral(); 548 | } 549 | } 550 | } 551 | } 552 | } 553 | } 554 | } 555 | } 556 | 557 | return s0; 558 | } 559 | 560 | function peg$parseexpressionitems() { 561 | var s0, s1, s2, s3, s4, s5; 562 | 563 | s0 = peg$currPos; 564 | s1 = peg$parseexpression(); 565 | if (s1 !== peg$FAILED) { 566 | s2 = []; 567 | s3 = peg$currPos; 568 | s4 = peg$parseOPTIONAL_EXPRESSION_SPACES(); 569 | if (s4 !== peg$FAILED) { 570 | s5 = peg$parseexpression(); 571 | if (s5 !== peg$FAILED) { 572 | s4 = [s4, s5]; 573 | s3 = s4; 574 | } else { 575 | peg$currPos = s3; 576 | s3 = peg$FAILED; 577 | } 578 | } else { 579 | peg$currPos = s3; 580 | s3 = peg$FAILED; 581 | } 582 | while (s3 !== peg$FAILED) { 583 | s2.push(s3); 584 | s3 = peg$currPos; 585 | s4 = peg$parseOPTIONAL_EXPRESSION_SPACES(); 586 | if (s4 !== peg$FAILED) { 587 | s5 = peg$parseexpression(); 588 | if (s5 !== peg$FAILED) { 589 | s4 = [s4, s5]; 590 | s3 = s4; 591 | } else { 592 | peg$currPos = s3; 593 | s3 = peg$FAILED; 594 | } 595 | } else { 596 | peg$currPos = s3; 597 | s3 = peg$FAILED; 598 | } 599 | } 600 | if (s2 !== peg$FAILED) { 601 | peg$savedPos = s0; 602 | s1 = peg$c0(s1, s2); 603 | s0 = s1; 604 | } else { 605 | peg$currPos = s0; 606 | s0 = peg$FAILED; 607 | } 608 | } else { 609 | peg$currPos = s0; 610 | s0 = peg$FAILED; 611 | } 612 | 613 | return s0; 614 | } 615 | 616 | function peg$parseinvoke() { 617 | var s0, s1, s2, s3, s4, s5, s6, s7; 618 | 619 | s0 = peg$currPos; 620 | s1 = peg$parsePOS(); 621 | if (s1 !== peg$FAILED) { 622 | if (input.charCodeAt(peg$currPos) === 91) { 623 | s2 = peg$c1; 624 | peg$currPos++; 625 | } else { 626 | s2 = peg$FAILED; 627 | if (peg$silentFails === 0) { peg$fail(peg$c2); } 628 | } 629 | if (s2 !== peg$FAILED) { 630 | s3 = peg$parseOPTIONAL_EXPRESSION_SPACES(); 631 | if (s3 !== peg$FAILED) { 632 | s4 = peg$parseexpressionitems(); 633 | if (s4 !== peg$FAILED) { 634 | s5 = peg$parseOPTIONAL_EXPRESSION_SPACES(); 635 | if (s5 !== peg$FAILED) { 636 | if (input.charCodeAt(peg$currPos) === 93) { 637 | s6 = peg$c3; 638 | peg$currPos++; 639 | } else { 640 | s6 = peg$FAILED; 641 | if (peg$silentFails === 0) { peg$fail(peg$c4); } 642 | } 643 | if (s6 !== peg$FAILED) { 644 | s7 = peg$parsePOS(); 645 | if (s7 !== peg$FAILED) { 646 | peg$savedPos = s0; 647 | s1 = peg$c5(s1, s4, s7); 648 | s0 = s1; 649 | } else { 650 | peg$currPos = s0; 651 | s0 = peg$FAILED; 652 | } 653 | } else { 654 | peg$currPos = s0; 655 | s0 = peg$FAILED; 656 | } 657 | } else { 658 | peg$currPos = s0; 659 | s0 = peg$FAILED; 660 | } 661 | } else { 662 | peg$currPos = s0; 663 | s0 = peg$FAILED; 664 | } 665 | } else { 666 | peg$currPos = s0; 667 | s0 = peg$FAILED; 668 | } 669 | } else { 670 | peg$currPos = s0; 671 | s0 = peg$FAILED; 672 | } 673 | } else { 674 | peg$currPos = s0; 675 | s0 = peg$FAILED; 676 | } 677 | 678 | return s0; 679 | } 680 | 681 | function peg$parsequote() { 682 | var s0, s1, s2; 683 | 684 | s0 = peg$currPos; 685 | if (input.charCodeAt(peg$currPos) === 39) { 686 | s1 = peg$c6; 687 | peg$currPos++; 688 | } else { 689 | s1 = peg$FAILED; 690 | if (peg$silentFails === 0) { peg$fail(peg$c7); } 691 | } 692 | if (s1 !== peg$FAILED) { 693 | s2 = peg$parseinvoke(); 694 | if (s2 === peg$FAILED) { 695 | s2 = peg$parseverbatim(); 696 | if (s2 === peg$FAILED) { 697 | s2 = peg$parsetextblock(); 698 | if (s2 === peg$FAILED) { 699 | s2 = peg$parseidentifier(); 700 | } 701 | } 702 | } 703 | if (s2 !== peg$FAILED) { 704 | peg$savedPos = s0; 705 | s1 = peg$c8(s2); 706 | s0 = s1; 707 | } else { 708 | peg$currPos = s0; 709 | s0 = peg$FAILED; 710 | } 711 | } else { 712 | peg$currPos = s0; 713 | s0 = peg$FAILED; 714 | } 715 | 716 | return s0; 717 | } 718 | 719 | function peg$parsequasiquote() { 720 | var s0, s1, s2; 721 | 722 | s0 = peg$currPos; 723 | if (input.charCodeAt(peg$currPos) === 96) { 724 | s1 = peg$c9; 725 | peg$currPos++; 726 | } else { 727 | s1 = peg$FAILED; 728 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 729 | } 730 | if (s1 !== peg$FAILED) { 731 | s2 = peg$parseinvoke(); 732 | if (s2 === peg$FAILED) { 733 | s2 = peg$parseverbatim(); 734 | if (s2 === peg$FAILED) { 735 | s2 = peg$parsetextblock(); 736 | if (s2 === peg$FAILED) { 737 | s2 = peg$parseidentifier(); 738 | } 739 | } 740 | } 741 | if (s2 !== peg$FAILED) { 742 | peg$savedPos = s0; 743 | s1 = peg$c11(s2); 744 | s0 = s1; 745 | } else { 746 | peg$currPos = s0; 747 | s0 = peg$FAILED; 748 | } 749 | } else { 750 | peg$currPos = s0; 751 | s0 = peg$FAILED; 752 | } 753 | 754 | return s0; 755 | } 756 | 757 | function peg$parseunquote() { 758 | var s0, s1, s2; 759 | 760 | s0 = peg$currPos; 761 | if (input.charCodeAt(peg$currPos) === 44) { 762 | s1 = peg$c12; 763 | peg$currPos++; 764 | } else { 765 | s1 = peg$FAILED; 766 | if (peg$silentFails === 0) { peg$fail(peg$c13); } 767 | } 768 | if (s1 !== peg$FAILED) { 769 | s2 = peg$parseinvoke(); 770 | if (s2 === peg$FAILED) { 771 | s2 = peg$parseverbatim(); 772 | if (s2 === peg$FAILED) { 773 | s2 = peg$parsetextblock(); 774 | if (s2 === peg$FAILED) { 775 | s2 = peg$parseidentifier(); 776 | } 777 | } 778 | } 779 | if (s2 !== peg$FAILED) { 780 | peg$savedPos = s0; 781 | s1 = peg$c14(s2); 782 | s0 = s1; 783 | } else { 784 | peg$currPos = s0; 785 | s0 = peg$FAILED; 786 | } 787 | } else { 788 | peg$currPos = s0; 789 | s0 = peg$FAILED; 790 | } 791 | 792 | return s0; 793 | } 794 | 795 | function peg$parseattribute() { 796 | var s0, s1, s2; 797 | 798 | s0 = peg$currPos; 799 | if (input.charCodeAt(peg$currPos) === 58) { 800 | s1 = peg$c15; 801 | peg$currPos++; 802 | } else { 803 | s1 = peg$FAILED; 804 | if (peg$silentFails === 0) { peg$fail(peg$c16); } 805 | } 806 | if (s1 !== peg$FAILED) { 807 | s2 = peg$parseidentifier(); 808 | if (s2 !== peg$FAILED) { 809 | peg$savedPos = s0; 810 | s1 = peg$c17(s2); 811 | s0 = s1; 812 | } else { 813 | peg$currPos = s0; 814 | s0 = peg$FAILED; 815 | } 816 | } else { 817 | peg$currPos = s0; 818 | s0 = peg$FAILED; 819 | } 820 | 821 | return s0; 822 | } 823 | 824 | function peg$parseliteral() { 825 | var s0; 826 | 827 | s0 = peg$parsenumberliteral(); 828 | if (s0 === peg$FAILED) { 829 | s0 = peg$parsestringliteral(); 830 | } 831 | 832 | return s0; 833 | } 834 | 835 | function peg$parsetextblock() { 836 | var s0, s1, s2, s3, s4, s5, s6; 837 | 838 | s0 = peg$currPos; 839 | if (input.charCodeAt(peg$currPos) === 123) { 840 | s1 = peg$c18; 841 | peg$currPos++; 842 | } else { 843 | s1 = peg$FAILED; 844 | if (peg$silentFails === 0) { peg$fail(peg$c19); } 845 | } 846 | if (s1 !== peg$FAILED) { 847 | s2 = peg$parseline(); 848 | if (s2 !== peg$FAILED) { 849 | if (input.charCodeAt(peg$currPos) === 125) { 850 | s3 = peg$c20; 851 | peg$currPos++; 852 | } else { 853 | s3 = peg$FAILED; 854 | if (peg$silentFails === 0) { peg$fail(peg$c21); } 855 | } 856 | if (s3 !== peg$FAILED) { 857 | peg$savedPos = s0; 858 | s1 = peg$c22(s2); 859 | s0 = s1; 860 | } else { 861 | peg$currPos = s0; 862 | s0 = peg$FAILED; 863 | } 864 | } else { 865 | peg$currPos = s0; 866 | s0 = peg$FAILED; 867 | } 868 | } else { 869 | peg$currPos = s0; 870 | s0 = peg$FAILED; 871 | } 872 | if (s0 === peg$FAILED) { 873 | s0 = peg$currPos; 874 | if (input.charCodeAt(peg$currPos) === 123) { 875 | s1 = peg$c18; 876 | peg$currPos++; 877 | } else { 878 | s1 = peg$FAILED; 879 | if (peg$silentFails === 0) { peg$fail(peg$c19); } 880 | } 881 | if (s1 !== peg$FAILED) { 882 | s2 = peg$parseINDENT_CLEAR_ON(); 883 | if (s2 !== peg$FAILED) { 884 | s3 = peg$parsetextBlockInner(); 885 | if (s3 !== peg$FAILED) { 886 | s4 = peg$parseINDENT_CLEAR_OFF(); 887 | if (s4 !== peg$FAILED) { 888 | s5 = []; 889 | s6 = peg$parseNEWLINE(); 890 | while (s6 !== peg$FAILED) { 891 | s5.push(s6); 892 | s6 = peg$parseNEWLINE(); 893 | } 894 | if (s5 !== peg$FAILED) { 895 | if (input.charCodeAt(peg$currPos) === 125) { 896 | s6 = peg$c20; 897 | peg$currPos++; 898 | } else { 899 | s6 = peg$FAILED; 900 | if (peg$silentFails === 0) { peg$fail(peg$c21); } 901 | } 902 | if (s6 !== peg$FAILED) { 903 | peg$savedPos = s0; 904 | s1 = peg$c23(s3); 905 | s0 = s1; 906 | } else { 907 | peg$currPos = s0; 908 | s0 = peg$FAILED; 909 | } 910 | } else { 911 | peg$currPos = s0; 912 | s0 = peg$FAILED; 913 | } 914 | } else { 915 | peg$currPos = s0; 916 | s0 = peg$FAILED; 917 | } 918 | } else { 919 | peg$currPos = s0; 920 | s0 = peg$FAILED; 921 | } 922 | } else { 923 | peg$currPos = s0; 924 | s0 = peg$FAILED; 925 | } 926 | } else { 927 | peg$currPos = s0; 928 | s0 = peg$FAILED; 929 | } 930 | } 931 | 932 | return s0; 933 | } 934 | 935 | function peg$parsetextBlockInner() { 936 | var s0, s1, s2, s3, s4, s5, s6; 937 | 938 | s0 = peg$currPos; 939 | s1 = peg$parseNEWLINE_INDENT_ADD(); 940 | if (s1 !== peg$FAILED) { 941 | s2 = peg$parseblockContent(); 942 | if (s2 !== peg$FAILED) { 943 | s3 = peg$currPos; 944 | peg$silentFails++; 945 | s4 = peg$currPos; 946 | s5 = []; 947 | s6 = peg$parseNEWLINE(); 948 | while (s6 !== peg$FAILED) { 949 | s5.push(s6); 950 | s6 = peg$parseNEWLINE(); 951 | } 952 | if (s5 !== peg$FAILED) { 953 | if (input.charCodeAt(peg$currPos) === 125) { 954 | s6 = peg$c20; 955 | peg$currPos++; 956 | } else { 957 | s6 = peg$FAILED; 958 | if (peg$silentFails === 0) { peg$fail(peg$c21); } 959 | } 960 | if (s6 !== peg$FAILED) { 961 | s5 = [s5, s6]; 962 | s4 = s5; 963 | } else { 964 | peg$currPos = s4; 965 | s4 = peg$FAILED; 966 | } 967 | } else { 968 | peg$currPos = s4; 969 | s4 = peg$FAILED; 970 | } 971 | peg$silentFails--; 972 | if (s4 !== peg$FAILED) { 973 | peg$currPos = s3; 974 | s3 = void 0; 975 | } else { 976 | s3 = peg$FAILED; 977 | } 978 | if (s3 !== peg$FAILED) { 979 | s4 = peg$parseINDENT_REMOVE(); 980 | if (s4 !== peg$FAILED) { 981 | peg$savedPos = s0; 982 | s1 = peg$c24(s2); 983 | s0 = s1; 984 | } else { 985 | peg$currPos = s0; 986 | s0 = peg$FAILED; 987 | } 988 | } else { 989 | peg$currPos = s0; 990 | s0 = peg$FAILED; 991 | } 992 | } else { 993 | peg$currPos = s0; 994 | s0 = peg$FAILED; 995 | } 996 | } else { 997 | peg$currPos = s0; 998 | s0 = peg$FAILED; 999 | } 1000 | if (s0 === peg$FAILED) { 1001 | s0 = peg$currPos; 1002 | s1 = peg$parseblockContent(); 1003 | if (s1 !== peg$FAILED) { 1004 | peg$savedPos = s0; 1005 | s1 = peg$c24(s1); 1006 | } 1007 | s0 = s1; 1008 | } 1009 | 1010 | return s0; 1011 | } 1012 | 1013 | function peg$parseblockContent() { 1014 | var s0, s1, s2, s3, s4, s5; 1015 | 1016 | s0 = peg$currPos; 1017 | s1 = peg$parseblockSection(); 1018 | if (s1 !== peg$FAILED) { 1019 | s2 = []; 1020 | s3 = peg$currPos; 1021 | s4 = peg$parsePARAGRAPH_BREAK(); 1022 | if (s4 !== peg$FAILED) { 1023 | s5 = peg$parseblockSection(); 1024 | if (s5 !== peg$FAILED) { 1025 | s4 = [s4, s5]; 1026 | s3 = s4; 1027 | } else { 1028 | peg$currPos = s3; 1029 | s3 = peg$FAILED; 1030 | } 1031 | } else { 1032 | peg$currPos = s3; 1033 | s3 = peg$FAILED; 1034 | } 1035 | while (s3 !== peg$FAILED) { 1036 | s2.push(s3); 1037 | s3 = peg$currPos; 1038 | s4 = peg$parsePARAGRAPH_BREAK(); 1039 | if (s4 !== peg$FAILED) { 1040 | s5 = peg$parseblockSection(); 1041 | if (s5 !== peg$FAILED) { 1042 | s4 = [s4, s5]; 1043 | s3 = s4; 1044 | } else { 1045 | peg$currPos = s3; 1046 | s3 = peg$FAILED; 1047 | } 1048 | } else { 1049 | peg$currPos = s3; 1050 | s3 = peg$FAILED; 1051 | } 1052 | } 1053 | if (s2 !== peg$FAILED) { 1054 | peg$savedPos = s0; 1055 | s1 = peg$c0(s1, s2); 1056 | s0 = s1; 1057 | } else { 1058 | peg$currPos = s0; 1059 | s0 = peg$FAILED; 1060 | } 1061 | } else { 1062 | peg$currPos = s0; 1063 | s0 = peg$FAILED; 1064 | } 1065 | 1066 | return s0; 1067 | } 1068 | 1069 | function peg$parseblockSection() { 1070 | var s0, s1, s2, s3, s4, s5; 1071 | 1072 | s0 = peg$currPos; 1073 | s1 = peg$parseblockSectionPart(); 1074 | if (s1 !== peg$FAILED) { 1075 | s2 = []; 1076 | s3 = peg$currPos; 1077 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1078 | if (s4 !== peg$FAILED) { 1079 | s5 = peg$parseblockSectionPart(); 1080 | if (s5 !== peg$FAILED) { 1081 | s4 = [s4, s5]; 1082 | s3 = s4; 1083 | } else { 1084 | peg$currPos = s3; 1085 | s3 = peg$FAILED; 1086 | } 1087 | } else { 1088 | peg$currPos = s3; 1089 | s3 = peg$FAILED; 1090 | } 1091 | while (s3 !== peg$FAILED) { 1092 | s2.push(s3); 1093 | s3 = peg$currPos; 1094 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1095 | if (s4 !== peg$FAILED) { 1096 | s5 = peg$parseblockSectionPart(); 1097 | if (s5 !== peg$FAILED) { 1098 | s4 = [s4, s5]; 1099 | s3 = s4; 1100 | } else { 1101 | peg$currPos = s3; 1102 | s3 = peg$FAILED; 1103 | } 1104 | } else { 1105 | peg$currPos = s3; 1106 | s3 = peg$FAILED; 1107 | } 1108 | } 1109 | if (s2 !== peg$FAILED) { 1110 | peg$savedPos = s0; 1111 | s1 = peg$c25(s1, s2); 1112 | s0 = s1; 1113 | } else { 1114 | peg$currPos = s0; 1115 | s0 = peg$FAILED; 1116 | } 1117 | } else { 1118 | peg$currPos = s0; 1119 | s0 = peg$FAILED; 1120 | } 1121 | 1122 | return s0; 1123 | } 1124 | 1125 | function peg$parseblockSectionPart() { 1126 | var s0; 1127 | 1128 | s0 = peg$parseeverlasting(); 1129 | if (s0 === peg$FAILED) { 1130 | s0 = peg$parseindentedVerbatimOperate(); 1131 | if (s0 === peg$FAILED) { 1132 | s0 = peg$parseindentedOperate(); 1133 | if (s0 === peg$FAILED) { 1134 | s0 = peg$parseul(); 1135 | if (s0 === peg$FAILED) { 1136 | s0 = peg$parseol(); 1137 | if (s0 === peg$FAILED) { 1138 | s0 = peg$parseparagraph(); 1139 | } 1140 | } 1141 | } 1142 | } 1143 | } 1144 | 1145 | return s0; 1146 | } 1147 | 1148 | function peg$parseeverlasting() { 1149 | var s0, s1, s2, s3, s4; 1150 | 1151 | s0 = peg$currPos; 1152 | s1 = peg$parseinvoke(); 1153 | if (s1 !== peg$FAILED) { 1154 | if (input.substr(peg$currPos, 2) === peg$c26) { 1155 | s2 = peg$c26; 1156 | peg$currPos += 2; 1157 | } else { 1158 | s2 = peg$FAILED; 1159 | if (peg$silentFails === 0) { peg$fail(peg$c27); } 1160 | } 1161 | if (s2 !== peg$FAILED) { 1162 | s3 = peg$parseNEWLINE(); 1163 | if (s3 !== peg$FAILED) { 1164 | s4 = peg$parseblockContent(); 1165 | if (s4 !== peg$FAILED) { 1166 | peg$savedPos = s0; 1167 | s1 = peg$c28(s1, s4); 1168 | s0 = s1; 1169 | } else { 1170 | peg$currPos = s0; 1171 | s0 = peg$FAILED; 1172 | } 1173 | } else { 1174 | peg$currPos = s0; 1175 | s0 = peg$FAILED; 1176 | } 1177 | } else { 1178 | peg$currPos = s0; 1179 | s0 = peg$FAILED; 1180 | } 1181 | } else { 1182 | peg$currPos = s0; 1183 | s0 = peg$FAILED; 1184 | } 1185 | 1186 | return s0; 1187 | } 1188 | 1189 | function peg$parseindentedVerbatimOperate() { 1190 | var s0, s1, s2, s3, s4, s5; 1191 | 1192 | s0 = peg$currPos; 1193 | s1 = peg$parseinvoke(); 1194 | if (s1 !== peg$FAILED) { 1195 | if (input.charCodeAt(peg$currPos) === 124) { 1196 | s2 = peg$c29; 1197 | peg$currPos++; 1198 | } else { 1199 | s2 = peg$FAILED; 1200 | if (peg$silentFails === 0) { peg$fail(peg$c30); } 1201 | } 1202 | if (s2 !== peg$FAILED) { 1203 | s3 = peg$currPos; 1204 | s4 = peg$parseNEWLINE_INDENT_ADD(); 1205 | if (s4 !== peg$FAILED) { 1206 | s3 = input.substring(s3, peg$currPos); 1207 | } else { 1208 | s3 = s4; 1209 | } 1210 | if (s3 !== peg$FAILED) { 1211 | s4 = peg$parseindentedVerbatimLines(); 1212 | if (s4 !== peg$FAILED) { 1213 | s5 = peg$parseINDENT_REMOVE(); 1214 | if (s5 !== peg$FAILED) { 1215 | peg$savedPos = s0; 1216 | s1 = peg$c31(s1, s3, s4); 1217 | s0 = s1; 1218 | } else { 1219 | peg$currPos = s0; 1220 | s0 = peg$FAILED; 1221 | } 1222 | } else { 1223 | peg$currPos = s0; 1224 | s0 = peg$FAILED; 1225 | } 1226 | } else { 1227 | peg$currPos = s0; 1228 | s0 = peg$FAILED; 1229 | } 1230 | } else { 1231 | peg$currPos = s0; 1232 | s0 = peg$FAILED; 1233 | } 1234 | } else { 1235 | peg$currPos = s0; 1236 | s0 = peg$FAILED; 1237 | } 1238 | 1239 | return s0; 1240 | } 1241 | 1242 | function peg$parseindentedOperate() { 1243 | var s0, s1, s2, s3, s4, s5; 1244 | 1245 | s0 = peg$currPos; 1246 | s1 = peg$parseinvoke(); 1247 | if (s1 !== peg$FAILED) { 1248 | if (input.charCodeAt(peg$currPos) === 58) { 1249 | s2 = peg$c15; 1250 | peg$currPos++; 1251 | } else { 1252 | s2 = peg$FAILED; 1253 | if (peg$silentFails === 0) { peg$fail(peg$c16); } 1254 | } 1255 | if (s2 !== peg$FAILED) { 1256 | s3 = peg$parseNEWLINE_INDENT_ADD(); 1257 | if (s3 !== peg$FAILED) { 1258 | s4 = peg$parseblockContent(); 1259 | if (s4 !== peg$FAILED) { 1260 | s5 = peg$parseINDENT_REMOVE(); 1261 | if (s5 !== peg$FAILED) { 1262 | peg$savedPos = s0; 1263 | s1 = peg$c32(s1, s4); 1264 | s0 = s1; 1265 | } else { 1266 | peg$currPos = s0; 1267 | s0 = peg$FAILED; 1268 | } 1269 | } else { 1270 | peg$currPos = s0; 1271 | s0 = peg$FAILED; 1272 | } 1273 | } else { 1274 | peg$currPos = s0; 1275 | s0 = peg$FAILED; 1276 | } 1277 | } else { 1278 | peg$currPos = s0; 1279 | s0 = peg$FAILED; 1280 | } 1281 | } else { 1282 | peg$currPos = s0; 1283 | s0 = peg$FAILED; 1284 | } 1285 | 1286 | return s0; 1287 | } 1288 | 1289 | function peg$parseindentedVerbatimLines() { 1290 | var s0, s1, s2, s3, s4, s5, s6, s7; 1291 | 1292 | s0 = peg$currPos; 1293 | s1 = peg$currPos; 1294 | s2 = []; 1295 | if (peg$c33.test(input.charAt(peg$currPos))) { 1296 | s3 = input.charAt(peg$currPos); 1297 | peg$currPos++; 1298 | } else { 1299 | s3 = peg$FAILED; 1300 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 1301 | } 1302 | if (s3 !== peg$FAILED) { 1303 | while (s3 !== peg$FAILED) { 1304 | s2.push(s3); 1305 | if (peg$c33.test(input.charAt(peg$currPos))) { 1306 | s3 = input.charAt(peg$currPos); 1307 | peg$currPos++; 1308 | } else { 1309 | s3 = peg$FAILED; 1310 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 1311 | } 1312 | } 1313 | } else { 1314 | s2 = peg$FAILED; 1315 | } 1316 | if (s2 !== peg$FAILED) { 1317 | s3 = []; 1318 | s4 = peg$currPos; 1319 | s5 = peg$parseNEWLINE_INDENT_SAME_OR_MORE(); 1320 | if (s5 !== peg$FAILED) { 1321 | s6 = []; 1322 | if (peg$c33.test(input.charAt(peg$currPos))) { 1323 | s7 = input.charAt(peg$currPos); 1324 | peg$currPos++; 1325 | } else { 1326 | s7 = peg$FAILED; 1327 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 1328 | } 1329 | if (s7 !== peg$FAILED) { 1330 | while (s7 !== peg$FAILED) { 1331 | s6.push(s7); 1332 | if (peg$c33.test(input.charAt(peg$currPos))) { 1333 | s7 = input.charAt(peg$currPos); 1334 | peg$currPos++; 1335 | } else { 1336 | s7 = peg$FAILED; 1337 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 1338 | } 1339 | } 1340 | } else { 1341 | s6 = peg$FAILED; 1342 | } 1343 | if (s6 !== peg$FAILED) { 1344 | s5 = [s5, s6]; 1345 | s4 = s5; 1346 | } else { 1347 | peg$currPos = s4; 1348 | s4 = peg$FAILED; 1349 | } 1350 | } else { 1351 | peg$currPos = s4; 1352 | s4 = peg$FAILED; 1353 | } 1354 | while (s4 !== peg$FAILED) { 1355 | s3.push(s4); 1356 | s4 = peg$currPos; 1357 | s5 = peg$parseNEWLINE_INDENT_SAME_OR_MORE(); 1358 | if (s5 !== peg$FAILED) { 1359 | s6 = []; 1360 | if (peg$c33.test(input.charAt(peg$currPos))) { 1361 | s7 = input.charAt(peg$currPos); 1362 | peg$currPos++; 1363 | } else { 1364 | s7 = peg$FAILED; 1365 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 1366 | } 1367 | if (s7 !== peg$FAILED) { 1368 | while (s7 !== peg$FAILED) { 1369 | s6.push(s7); 1370 | if (peg$c33.test(input.charAt(peg$currPos))) { 1371 | s7 = input.charAt(peg$currPos); 1372 | peg$currPos++; 1373 | } else { 1374 | s7 = peg$FAILED; 1375 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 1376 | } 1377 | } 1378 | } else { 1379 | s6 = peg$FAILED; 1380 | } 1381 | if (s6 !== peg$FAILED) { 1382 | s5 = [s5, s6]; 1383 | s4 = s5; 1384 | } else { 1385 | peg$currPos = s4; 1386 | s4 = peg$FAILED; 1387 | } 1388 | } else { 1389 | peg$currPos = s4; 1390 | s4 = peg$FAILED; 1391 | } 1392 | } 1393 | if (s3 !== peg$FAILED) { 1394 | s2 = [s2, s3]; 1395 | s1 = s2; 1396 | } else { 1397 | peg$currPos = s1; 1398 | s1 = peg$FAILED; 1399 | } 1400 | } else { 1401 | peg$currPos = s1; 1402 | s1 = peg$FAILED; 1403 | } 1404 | if (s1 !== peg$FAILED) { 1405 | s0 = input.substring(s0, peg$currPos); 1406 | } else { 1407 | s0 = s1; 1408 | } 1409 | 1410 | return s0; 1411 | } 1412 | 1413 | function peg$parseparagraph() { 1414 | var s0, s1, s2, s3, s4, s5; 1415 | 1416 | s0 = peg$currPos; 1417 | s1 = peg$parseline(); 1418 | if (s1 !== peg$FAILED) { 1419 | s2 = []; 1420 | s3 = peg$currPos; 1421 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1422 | if (s4 !== peg$FAILED) { 1423 | s5 = peg$parseline(); 1424 | if (s5 !== peg$FAILED) { 1425 | s4 = [s4, s5]; 1426 | s3 = s4; 1427 | } else { 1428 | peg$currPos = s3; 1429 | s3 = peg$FAILED; 1430 | } 1431 | } else { 1432 | peg$currPos = s3; 1433 | s3 = peg$FAILED; 1434 | } 1435 | while (s3 !== peg$FAILED) { 1436 | s2.push(s3); 1437 | s3 = peg$currPos; 1438 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1439 | if (s4 !== peg$FAILED) { 1440 | s5 = peg$parseline(); 1441 | if (s5 !== peg$FAILED) { 1442 | s4 = [s4, s5]; 1443 | s3 = s4; 1444 | } else { 1445 | peg$currPos = s3; 1446 | s3 = peg$FAILED; 1447 | } 1448 | } else { 1449 | peg$currPos = s3; 1450 | s3 = peg$FAILED; 1451 | } 1452 | } 1453 | if (s2 !== peg$FAILED) { 1454 | peg$savedPos = s0; 1455 | s1 = peg$c35(s1, s2); 1456 | s0 = s1; 1457 | } else { 1458 | peg$currPos = s0; 1459 | s0 = peg$FAILED; 1460 | } 1461 | } else { 1462 | peg$currPos = s0; 1463 | s0 = peg$FAILED; 1464 | } 1465 | 1466 | return s0; 1467 | } 1468 | 1469 | function peg$parseul() { 1470 | var s0, s1, s2, s3, s4, s5; 1471 | 1472 | s0 = peg$currPos; 1473 | s1 = peg$parseulli(); 1474 | if (s1 !== peg$FAILED) { 1475 | s2 = []; 1476 | s3 = peg$currPos; 1477 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1478 | if (s4 !== peg$FAILED) { 1479 | s5 = peg$parseulli(); 1480 | if (s5 !== peg$FAILED) { 1481 | s4 = [s4, s5]; 1482 | s3 = s4; 1483 | } else { 1484 | peg$currPos = s3; 1485 | s3 = peg$FAILED; 1486 | } 1487 | } else { 1488 | peg$currPos = s3; 1489 | s3 = peg$FAILED; 1490 | } 1491 | while (s3 !== peg$FAILED) { 1492 | s2.push(s3); 1493 | s3 = peg$currPos; 1494 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1495 | if (s4 !== peg$FAILED) { 1496 | s5 = peg$parseulli(); 1497 | if (s5 !== peg$FAILED) { 1498 | s4 = [s4, s5]; 1499 | s3 = s4; 1500 | } else { 1501 | peg$currPos = s3; 1502 | s3 = peg$FAILED; 1503 | } 1504 | } else { 1505 | peg$currPos = s3; 1506 | s3 = peg$FAILED; 1507 | } 1508 | } 1509 | if (s2 !== peg$FAILED) { 1510 | peg$savedPos = s0; 1511 | s1 = peg$c36(s1, s2); 1512 | s0 = s1; 1513 | } else { 1514 | peg$currPos = s0; 1515 | s0 = peg$FAILED; 1516 | } 1517 | } else { 1518 | peg$currPos = s0; 1519 | s0 = peg$FAILED; 1520 | } 1521 | if (s0 === peg$FAILED) { 1522 | s0 = peg$currPos; 1523 | s1 = peg$parseulliAlt(); 1524 | if (s1 !== peg$FAILED) { 1525 | s2 = []; 1526 | s3 = peg$currPos; 1527 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1528 | if (s4 !== peg$FAILED) { 1529 | s5 = peg$parseulliAlt(); 1530 | if (s5 !== peg$FAILED) { 1531 | s4 = [s4, s5]; 1532 | s3 = s4; 1533 | } else { 1534 | peg$currPos = s3; 1535 | s3 = peg$FAILED; 1536 | } 1537 | } else { 1538 | peg$currPos = s3; 1539 | s3 = peg$FAILED; 1540 | } 1541 | while (s3 !== peg$FAILED) { 1542 | s2.push(s3); 1543 | s3 = peg$currPos; 1544 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1545 | if (s4 !== peg$FAILED) { 1546 | s5 = peg$parseulliAlt(); 1547 | if (s5 !== peg$FAILED) { 1548 | s4 = [s4, s5]; 1549 | s3 = s4; 1550 | } else { 1551 | peg$currPos = s3; 1552 | s3 = peg$FAILED; 1553 | } 1554 | } else { 1555 | peg$currPos = s3; 1556 | s3 = peg$FAILED; 1557 | } 1558 | } 1559 | if (s2 !== peg$FAILED) { 1560 | peg$savedPos = s0; 1561 | s1 = peg$c36(s1, s2); 1562 | s0 = s1; 1563 | } else { 1564 | peg$currPos = s0; 1565 | s0 = peg$FAILED; 1566 | } 1567 | } else { 1568 | peg$currPos = s0; 1569 | s0 = peg$FAILED; 1570 | } 1571 | } 1572 | 1573 | return s0; 1574 | } 1575 | 1576 | function peg$parseulli() { 1577 | var s0, s1, s2, s3, s4, s5, s6; 1578 | 1579 | s0 = peg$currPos; 1580 | if (input.charCodeAt(peg$currPos) === 45) { 1581 | s1 = peg$c37; 1582 | peg$currPos++; 1583 | } else { 1584 | s1 = peg$FAILED; 1585 | if (peg$silentFails === 0) { peg$fail(peg$c38); } 1586 | } 1587 | if (s1 !== peg$FAILED) { 1588 | s2 = peg$parseSPACES(); 1589 | if (s2 === peg$FAILED) { 1590 | s2 = null; 1591 | } 1592 | if (s2 !== peg$FAILED) { 1593 | s3 = peg$parseline(); 1594 | if (s3 !== peg$FAILED) { 1595 | s4 = peg$parseNEWLINE_INDENT_ADD(); 1596 | if (s4 !== peg$FAILED) { 1597 | s5 = peg$parseul(); 1598 | if (s5 === peg$FAILED) { 1599 | s5 = peg$parseol(); 1600 | } 1601 | if (s5 !== peg$FAILED) { 1602 | s6 = peg$parseINDENT_REMOVE(); 1603 | if (s6 !== peg$FAILED) { 1604 | peg$savedPos = s0; 1605 | s1 = peg$c39(s3, s5); 1606 | s0 = s1; 1607 | } else { 1608 | peg$currPos = s0; 1609 | s0 = peg$FAILED; 1610 | } 1611 | } else { 1612 | peg$currPos = s0; 1613 | s0 = peg$FAILED; 1614 | } 1615 | } else { 1616 | peg$currPos = s0; 1617 | s0 = peg$FAILED; 1618 | } 1619 | } else { 1620 | peg$currPos = s0; 1621 | s0 = peg$FAILED; 1622 | } 1623 | } else { 1624 | peg$currPos = s0; 1625 | s0 = peg$FAILED; 1626 | } 1627 | } else { 1628 | peg$currPos = s0; 1629 | s0 = peg$FAILED; 1630 | } 1631 | if (s0 === peg$FAILED) { 1632 | s0 = peg$currPos; 1633 | if (input.charCodeAt(peg$currPos) === 45) { 1634 | s1 = peg$c37; 1635 | peg$currPos++; 1636 | } else { 1637 | s1 = peg$FAILED; 1638 | if (peg$silentFails === 0) { peg$fail(peg$c38); } 1639 | } 1640 | if (s1 !== peg$FAILED) { 1641 | s2 = peg$parseSPACES(); 1642 | if (s2 === peg$FAILED) { 1643 | s2 = null; 1644 | } 1645 | if (s2 !== peg$FAILED) { 1646 | s3 = peg$parseline(); 1647 | if (s3 !== peg$FAILED) { 1648 | peg$savedPos = s0; 1649 | s1 = peg$c40(s3); 1650 | s0 = s1; 1651 | } else { 1652 | peg$currPos = s0; 1653 | s0 = peg$FAILED; 1654 | } 1655 | } else { 1656 | peg$currPos = s0; 1657 | s0 = peg$FAILED; 1658 | } 1659 | } else { 1660 | peg$currPos = s0; 1661 | s0 = peg$FAILED; 1662 | } 1663 | } 1664 | 1665 | return s0; 1666 | } 1667 | 1668 | function peg$parseulliAlt() { 1669 | var s0, s1, s2, s3, s4, s5, s6; 1670 | 1671 | s0 = peg$currPos; 1672 | if (input.charCodeAt(peg$currPos) === 43) { 1673 | s1 = peg$c41; 1674 | peg$currPos++; 1675 | } else { 1676 | s1 = peg$FAILED; 1677 | if (peg$silentFails === 0) { peg$fail(peg$c42); } 1678 | } 1679 | if (s1 !== peg$FAILED) { 1680 | s2 = peg$parseSPACES(); 1681 | if (s2 === peg$FAILED) { 1682 | s2 = null; 1683 | } 1684 | if (s2 !== peg$FAILED) { 1685 | s3 = peg$parseline(); 1686 | if (s3 !== peg$FAILED) { 1687 | s4 = peg$parseNEWLINE_INDENT_ADD(); 1688 | if (s4 !== peg$FAILED) { 1689 | s5 = peg$parseul(); 1690 | if (s5 === peg$FAILED) { 1691 | s5 = peg$parseol(); 1692 | } 1693 | if (s5 !== peg$FAILED) { 1694 | s6 = peg$parseINDENT_REMOVE(); 1695 | if (s6 !== peg$FAILED) { 1696 | peg$savedPos = s0; 1697 | s1 = peg$c39(s3, s5); 1698 | s0 = s1; 1699 | } else { 1700 | peg$currPos = s0; 1701 | s0 = peg$FAILED; 1702 | } 1703 | } else { 1704 | peg$currPos = s0; 1705 | s0 = peg$FAILED; 1706 | } 1707 | } else { 1708 | peg$currPos = s0; 1709 | s0 = peg$FAILED; 1710 | } 1711 | } else { 1712 | peg$currPos = s0; 1713 | s0 = peg$FAILED; 1714 | } 1715 | } else { 1716 | peg$currPos = s0; 1717 | s0 = peg$FAILED; 1718 | } 1719 | } else { 1720 | peg$currPos = s0; 1721 | s0 = peg$FAILED; 1722 | } 1723 | if (s0 === peg$FAILED) { 1724 | s0 = peg$currPos; 1725 | if (input.charCodeAt(peg$currPos) === 43) { 1726 | s1 = peg$c41; 1727 | peg$currPos++; 1728 | } else { 1729 | s1 = peg$FAILED; 1730 | if (peg$silentFails === 0) { peg$fail(peg$c42); } 1731 | } 1732 | if (s1 !== peg$FAILED) { 1733 | s2 = peg$parseSPACES(); 1734 | if (s2 === peg$FAILED) { 1735 | s2 = null; 1736 | } 1737 | if (s2 !== peg$FAILED) { 1738 | s3 = peg$parseline(); 1739 | if (s3 !== peg$FAILED) { 1740 | peg$savedPos = s0; 1741 | s1 = peg$c40(s3); 1742 | s0 = s1; 1743 | } else { 1744 | peg$currPos = s0; 1745 | s0 = peg$FAILED; 1746 | } 1747 | } else { 1748 | peg$currPos = s0; 1749 | s0 = peg$FAILED; 1750 | } 1751 | } else { 1752 | peg$currPos = s0; 1753 | s0 = peg$FAILED; 1754 | } 1755 | } 1756 | 1757 | return s0; 1758 | } 1759 | 1760 | function peg$parseol() { 1761 | var s0, s1, s2, s3, s4, s5; 1762 | 1763 | s0 = peg$currPos; 1764 | s1 = peg$parseolli(); 1765 | if (s1 !== peg$FAILED) { 1766 | s2 = []; 1767 | s3 = peg$currPos; 1768 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1769 | if (s4 !== peg$FAILED) { 1770 | s5 = peg$parseolli(); 1771 | if (s5 !== peg$FAILED) { 1772 | s4 = [s4, s5]; 1773 | s3 = s4; 1774 | } else { 1775 | peg$currPos = s3; 1776 | s3 = peg$FAILED; 1777 | } 1778 | } else { 1779 | peg$currPos = s3; 1780 | s3 = peg$FAILED; 1781 | } 1782 | while (s3 !== peg$FAILED) { 1783 | s2.push(s3); 1784 | s3 = peg$currPos; 1785 | s4 = peg$parseTEXT_IN_SEGMENT_LINEBREAK(); 1786 | if (s4 !== peg$FAILED) { 1787 | s5 = peg$parseolli(); 1788 | if (s5 !== peg$FAILED) { 1789 | s4 = [s4, s5]; 1790 | s3 = s4; 1791 | } else { 1792 | peg$currPos = s3; 1793 | s3 = peg$FAILED; 1794 | } 1795 | } else { 1796 | peg$currPos = s3; 1797 | s3 = peg$FAILED; 1798 | } 1799 | } 1800 | if (s2 !== peg$FAILED) { 1801 | peg$savedPos = s0; 1802 | s1 = peg$c43(s1, s2); 1803 | s0 = s1; 1804 | } else { 1805 | peg$currPos = s0; 1806 | s0 = peg$FAILED; 1807 | } 1808 | } else { 1809 | peg$currPos = s0; 1810 | s0 = peg$FAILED; 1811 | } 1812 | 1813 | return s0; 1814 | } 1815 | 1816 | function peg$parseolli() { 1817 | var s0, s1, s2, s3, s4, s5, s6; 1818 | 1819 | s0 = peg$currPos; 1820 | if (input.charCodeAt(peg$currPos) === 35) { 1821 | s1 = peg$c44; 1822 | peg$currPos++; 1823 | } else { 1824 | s1 = peg$FAILED; 1825 | if (peg$silentFails === 0) { peg$fail(peg$c45); } 1826 | } 1827 | if (s1 !== peg$FAILED) { 1828 | s2 = peg$parseSPACES(); 1829 | if (s2 === peg$FAILED) { 1830 | s2 = null; 1831 | } 1832 | if (s2 !== peg$FAILED) { 1833 | s3 = peg$parseline(); 1834 | if (s3 !== peg$FAILED) { 1835 | s4 = peg$parseNEWLINE_INDENT_ADD(); 1836 | if (s4 !== peg$FAILED) { 1837 | s5 = peg$parseul(); 1838 | if (s5 === peg$FAILED) { 1839 | s5 = peg$parseol(); 1840 | } 1841 | if (s5 !== peg$FAILED) { 1842 | s6 = peg$parseINDENT_REMOVE(); 1843 | if (s6 !== peg$FAILED) { 1844 | peg$savedPos = s0; 1845 | s1 = peg$c39(s3, s5); 1846 | s0 = s1; 1847 | } else { 1848 | peg$currPos = s0; 1849 | s0 = peg$FAILED; 1850 | } 1851 | } else { 1852 | peg$currPos = s0; 1853 | s0 = peg$FAILED; 1854 | } 1855 | } else { 1856 | peg$currPos = s0; 1857 | s0 = peg$FAILED; 1858 | } 1859 | } else { 1860 | peg$currPos = s0; 1861 | s0 = peg$FAILED; 1862 | } 1863 | } else { 1864 | peg$currPos = s0; 1865 | s0 = peg$FAILED; 1866 | } 1867 | } else { 1868 | peg$currPos = s0; 1869 | s0 = peg$FAILED; 1870 | } 1871 | if (s0 === peg$FAILED) { 1872 | s0 = peg$currPos; 1873 | if (input.charCodeAt(peg$currPos) === 35) { 1874 | s1 = peg$c44; 1875 | peg$currPos++; 1876 | } else { 1877 | s1 = peg$FAILED; 1878 | if (peg$silentFails === 0) { peg$fail(peg$c45); } 1879 | } 1880 | if (s1 !== peg$FAILED) { 1881 | s2 = peg$parseSPACES(); 1882 | if (s2 === peg$FAILED) { 1883 | s2 = null; 1884 | } 1885 | if (s2 !== peg$FAILED) { 1886 | s3 = peg$parseline(); 1887 | if (s3 !== peg$FAILED) { 1888 | peg$savedPos = s0; 1889 | s1 = peg$c40(s3); 1890 | s0 = s1; 1891 | } else { 1892 | peg$currPos = s0; 1893 | s0 = peg$FAILED; 1894 | } 1895 | } else { 1896 | peg$currPos = s0; 1897 | s0 = peg$FAILED; 1898 | } 1899 | } else { 1900 | peg$currPos = s0; 1901 | s0 = peg$FAILED; 1902 | } 1903 | } 1904 | 1905 | return s0; 1906 | } 1907 | 1908 | function peg$parseline() { 1909 | var s0, s1, s2, s3, s4, s5, s6; 1910 | 1911 | s0 = peg$currPos; 1912 | s1 = peg$currPos; 1913 | peg$silentFails++; 1914 | if (peg$c46.test(input.charAt(peg$currPos))) { 1915 | s2 = input.charAt(peg$currPos); 1916 | peg$currPos++; 1917 | } else { 1918 | s2 = peg$FAILED; 1919 | if (peg$silentFails === 0) { peg$fail(peg$c47); } 1920 | } 1921 | peg$silentFails--; 1922 | if (s2 === peg$FAILED) { 1923 | s1 = void 0; 1924 | } else { 1925 | peg$currPos = s1; 1926 | s1 = peg$FAILED; 1927 | } 1928 | if (s1 !== peg$FAILED) { 1929 | s2 = peg$currPos; 1930 | peg$silentFails++; 1931 | s3 = peg$currPos; 1932 | s4 = peg$parseinvoke(); 1933 | if (s4 !== peg$FAILED) { 1934 | if (input.substr(peg$currPos, 2) === peg$c26) { 1935 | s5 = peg$c26; 1936 | peg$currPos += 2; 1937 | } else { 1938 | s5 = peg$FAILED; 1939 | if (peg$silentFails === 0) { peg$fail(peg$c27); } 1940 | } 1941 | if (s5 === peg$FAILED) { 1942 | if (input.charCodeAt(peg$currPos) === 58) { 1943 | s5 = peg$c15; 1944 | peg$currPos++; 1945 | } else { 1946 | s5 = peg$FAILED; 1947 | if (peg$silentFails === 0) { peg$fail(peg$c16); } 1948 | } 1949 | if (s5 === peg$FAILED) { 1950 | if (input.charCodeAt(peg$currPos) === 124) { 1951 | s5 = peg$c29; 1952 | peg$currPos++; 1953 | } else { 1954 | s5 = peg$FAILED; 1955 | if (peg$silentFails === 0) { peg$fail(peg$c30); } 1956 | } 1957 | } 1958 | } 1959 | if (s5 !== peg$FAILED) { 1960 | s6 = peg$parseNEWLINE(); 1961 | if (s6 !== peg$FAILED) { 1962 | s4 = [s4, s5, s6]; 1963 | s3 = s4; 1964 | } else { 1965 | peg$currPos = s3; 1966 | s3 = peg$FAILED; 1967 | } 1968 | } else { 1969 | peg$currPos = s3; 1970 | s3 = peg$FAILED; 1971 | } 1972 | } else { 1973 | peg$currPos = s3; 1974 | s3 = peg$FAILED; 1975 | } 1976 | peg$silentFails--; 1977 | if (s3 === peg$FAILED) { 1978 | s2 = void 0; 1979 | } else { 1980 | peg$currPos = s2; 1981 | s2 = peg$FAILED; 1982 | } 1983 | if (s2 !== peg$FAILED) { 1984 | s3 = []; 1985 | s4 = peg$parselineitem(); 1986 | while (s4 !== peg$FAILED) { 1987 | s3.push(s4); 1988 | s4 = peg$parselineitem(); 1989 | } 1990 | if (s3 !== peg$FAILED) { 1991 | peg$savedPos = s0; 1992 | s1 = peg$c48(s3); 1993 | s0 = s1; 1994 | } else { 1995 | peg$currPos = s0; 1996 | s0 = peg$FAILED; 1997 | } 1998 | } else { 1999 | peg$currPos = s0; 2000 | s0 = peg$FAILED; 2001 | } 2002 | } else { 2003 | peg$currPos = s0; 2004 | s0 = peg$FAILED; 2005 | } 2006 | 2007 | return s0; 2008 | } 2009 | 2010 | function peg$parselineitem() { 2011 | var s0; 2012 | 2013 | s0 = peg$parselineInvoke(); 2014 | if (s0 === peg$FAILED) { 2015 | s0 = peg$parselineVerbatim(); 2016 | if (s0 === peg$FAILED) { 2017 | s0 = peg$parsetextblock(); 2018 | if (s0 === peg$FAILED) { 2019 | s0 = peg$parselineDoubleStar(); 2020 | if (s0 === peg$FAILED) { 2021 | s0 = peg$parselineSingleStar(); 2022 | if (s0 === peg$FAILED) { 2023 | s0 = peg$parselineEscape(); 2024 | if (s0 === peg$FAILED) { 2025 | s0 = peg$parselineText(); 2026 | } 2027 | } 2028 | } 2029 | } 2030 | } 2031 | } 2032 | 2033 | return s0; 2034 | } 2035 | 2036 | function peg$parselineitemWithoutDoubleStar() { 2037 | var s0; 2038 | 2039 | s0 = peg$parselineInvoke(); 2040 | if (s0 === peg$FAILED) { 2041 | s0 = peg$parselineVerbatim(); 2042 | if (s0 === peg$FAILED) { 2043 | s0 = peg$parsetextblock(); 2044 | if (s0 === peg$FAILED) { 2045 | s0 = peg$parselineSingleStar(); 2046 | if (s0 === peg$FAILED) { 2047 | s0 = peg$parselineEscape(); 2048 | if (s0 === peg$FAILED) { 2049 | s0 = peg$parselineText(); 2050 | } 2051 | } 2052 | } 2053 | } 2054 | } 2055 | 2056 | return s0; 2057 | } 2058 | 2059 | function peg$parselineitemWithoutSingleStar() { 2060 | var s0; 2061 | 2062 | s0 = peg$parselineInvoke(); 2063 | if (s0 === peg$FAILED) { 2064 | s0 = peg$parselineVerbatim(); 2065 | if (s0 === peg$FAILED) { 2066 | s0 = peg$parsetextblock(); 2067 | if (s0 === peg$FAILED) { 2068 | s0 = peg$parselineDoubleStar(); 2069 | if (s0 === peg$FAILED) { 2070 | s0 = peg$parselineEscape(); 2071 | if (s0 === peg$FAILED) { 2072 | s0 = peg$parselineText(); 2073 | } 2074 | } 2075 | } 2076 | } 2077 | } 2078 | 2079 | return s0; 2080 | } 2081 | 2082 | function peg$parselineInvoke() { 2083 | var s0, s1, s2; 2084 | 2085 | s0 = peg$currPos; 2086 | s1 = peg$parseinvoke(); 2087 | if (s1 !== peg$FAILED) { 2088 | s2 = peg$parselineVerbatim(); 2089 | if (s2 === peg$FAILED) { 2090 | s2 = peg$parsetextblock(); 2091 | } 2092 | if (s2 === peg$FAILED) { 2093 | s2 = null; 2094 | } 2095 | if (s2 !== peg$FAILED) { 2096 | peg$savedPos = s0; 2097 | s1 = peg$c49(s1, s2); 2098 | s0 = s1; 2099 | } else { 2100 | peg$currPos = s0; 2101 | s0 = peg$FAILED; 2102 | } 2103 | } else { 2104 | peg$currPos = s0; 2105 | s0 = peg$FAILED; 2106 | } 2107 | 2108 | return s0; 2109 | } 2110 | 2111 | function peg$parselineVerbatim() { 2112 | var s0, s1; 2113 | 2114 | s0 = peg$currPos; 2115 | s1 = peg$parseverbatim(); 2116 | if (s1 !== peg$FAILED) { 2117 | peg$savedPos = s0; 2118 | s1 = peg$c50(s1); 2119 | } 2120 | s0 = s1; 2121 | if (s0 === peg$FAILED) { 2122 | s0 = peg$currPos; 2123 | s1 = peg$parsecodeSpan(); 2124 | if (s1 !== peg$FAILED) { 2125 | peg$savedPos = s0; 2126 | s1 = peg$c51(s1); 2127 | } 2128 | s0 = s1; 2129 | } 2130 | 2131 | return s0; 2132 | } 2133 | 2134 | function peg$parselineEscape() { 2135 | var s0, s1, s2; 2136 | 2137 | s0 = peg$currPos; 2138 | if (input.charCodeAt(peg$currPos) === 92) { 2139 | s1 = peg$c52; 2140 | peg$currPos++; 2141 | } else { 2142 | s1 = peg$FAILED; 2143 | if (peg$silentFails === 0) { peg$fail(peg$c53); } 2144 | } 2145 | if (s1 !== peg$FAILED) { 2146 | if (peg$c54.test(input.charAt(peg$currPos))) { 2147 | s2 = input.charAt(peg$currPos); 2148 | peg$currPos++; 2149 | } else { 2150 | s2 = peg$FAILED; 2151 | if (peg$silentFails === 0) { peg$fail(peg$c55); } 2152 | } 2153 | if (s2 !== peg$FAILED) { 2154 | peg$savedPos = s0; 2155 | s1 = peg$c56(s2); 2156 | s0 = s1; 2157 | } else { 2158 | peg$currPos = s0; 2159 | s0 = peg$FAILED; 2160 | } 2161 | } else { 2162 | peg$currPos = s0; 2163 | s0 = peg$FAILED; 2164 | } 2165 | if (s0 === peg$FAILED) { 2166 | s0 = peg$currPos; 2167 | if (input.charCodeAt(peg$currPos) === 92) { 2168 | s1 = peg$c52; 2169 | peg$currPos++; 2170 | } else { 2171 | s1 = peg$FAILED; 2172 | if (peg$silentFails === 0) { peg$fail(peg$c53); } 2173 | } 2174 | if (s1 !== peg$FAILED) { 2175 | if (peg$c33.test(input.charAt(peg$currPos))) { 2176 | s2 = input.charAt(peg$currPos); 2177 | peg$currPos++; 2178 | } else { 2179 | s2 = peg$FAILED; 2180 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 2181 | } 2182 | if (s2 !== peg$FAILED) { 2183 | peg$savedPos = s0; 2184 | s1 = peg$c57(s2); 2185 | s0 = s1; 2186 | } else { 2187 | peg$currPos = s0; 2188 | s0 = peg$FAILED; 2189 | } 2190 | } else { 2191 | peg$currPos = s0; 2192 | s0 = peg$FAILED; 2193 | } 2194 | } 2195 | 2196 | return s0; 2197 | } 2198 | 2199 | function peg$parselineText() { 2200 | var s0, s1, s2, s3; 2201 | 2202 | peg$silentFails++; 2203 | s0 = peg$currPos; 2204 | s1 = peg$currPos; 2205 | s2 = []; 2206 | if (peg$c59.test(input.charAt(peg$currPos))) { 2207 | s3 = input.charAt(peg$currPos); 2208 | peg$currPos++; 2209 | } else { 2210 | s3 = peg$FAILED; 2211 | if (peg$silentFails === 0) { peg$fail(peg$c60); } 2212 | } 2213 | if (s3 !== peg$FAILED) { 2214 | while (s3 !== peg$FAILED) { 2215 | s2.push(s3); 2216 | if (peg$c59.test(input.charAt(peg$currPos))) { 2217 | s3 = input.charAt(peg$currPos); 2218 | peg$currPos++; 2219 | } else { 2220 | s3 = peg$FAILED; 2221 | if (peg$silentFails === 0) { peg$fail(peg$c60); } 2222 | } 2223 | } 2224 | } else { 2225 | s2 = peg$FAILED; 2226 | } 2227 | if (s2 !== peg$FAILED) { 2228 | s1 = input.substring(s1, peg$currPos); 2229 | } else { 2230 | s1 = s2; 2231 | } 2232 | if (s1 !== peg$FAILED) { 2233 | peg$savedPos = s0; 2234 | s1 = peg$c61(s1); 2235 | } 2236 | s0 = s1; 2237 | peg$silentFails--; 2238 | if (s0 === peg$FAILED) { 2239 | s1 = peg$FAILED; 2240 | if (peg$silentFails === 0) { peg$fail(peg$c58); } 2241 | } 2242 | 2243 | return s0; 2244 | } 2245 | 2246 | function peg$parselineDoubleStar() { 2247 | var s0, s1, s2, s3; 2248 | 2249 | s0 = peg$currPos; 2250 | if (input.substr(peg$currPos, 2) === peg$c62) { 2251 | s1 = peg$c62; 2252 | peg$currPos += 2; 2253 | } else { 2254 | s1 = peg$FAILED; 2255 | if (peg$silentFails === 0) { peg$fail(peg$c63); } 2256 | } 2257 | if (s1 !== peg$FAILED) { 2258 | s2 = []; 2259 | s3 = peg$parselineitemWithoutDoubleStar(); 2260 | while (s3 !== peg$FAILED) { 2261 | s2.push(s3); 2262 | s3 = peg$parselineitemWithoutDoubleStar(); 2263 | } 2264 | if (s2 !== peg$FAILED) { 2265 | if (input.substr(peg$currPos, 2) === peg$c62) { 2266 | s3 = peg$c62; 2267 | peg$currPos += 2; 2268 | } else { 2269 | s3 = peg$FAILED; 2270 | if (peg$silentFails === 0) { peg$fail(peg$c63); } 2271 | } 2272 | if (s3 !== peg$FAILED) { 2273 | peg$savedPos = s0; 2274 | s1 = peg$c64(s2); 2275 | s0 = s1; 2276 | } else { 2277 | peg$currPos = s0; 2278 | s0 = peg$FAILED; 2279 | } 2280 | } else { 2281 | peg$currPos = s0; 2282 | s0 = peg$FAILED; 2283 | } 2284 | } else { 2285 | peg$currPos = s0; 2286 | s0 = peg$FAILED; 2287 | } 2288 | 2289 | return s0; 2290 | } 2291 | 2292 | function peg$parselineSingleStar() { 2293 | var s0, s1, s2, s3, s4; 2294 | 2295 | s0 = peg$currPos; 2296 | if (input.charCodeAt(peg$currPos) === 42) { 2297 | s1 = peg$c65; 2298 | peg$currPos++; 2299 | } else { 2300 | s1 = peg$FAILED; 2301 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 2302 | } 2303 | if (s1 !== peg$FAILED) { 2304 | s2 = peg$currPos; 2305 | peg$silentFails++; 2306 | if (input.charCodeAt(peg$currPos) === 42) { 2307 | s3 = peg$c65; 2308 | peg$currPos++; 2309 | } else { 2310 | s3 = peg$FAILED; 2311 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 2312 | } 2313 | peg$silentFails--; 2314 | if (s3 === peg$FAILED) { 2315 | s2 = void 0; 2316 | } else { 2317 | peg$currPos = s2; 2318 | s2 = peg$FAILED; 2319 | } 2320 | if (s2 !== peg$FAILED) { 2321 | s3 = []; 2322 | s4 = peg$parselineitemWithoutSingleStar(); 2323 | while (s4 !== peg$FAILED) { 2324 | s3.push(s4); 2325 | s4 = peg$parselineitemWithoutSingleStar(); 2326 | } 2327 | if (s3 !== peg$FAILED) { 2328 | if (input.charCodeAt(peg$currPos) === 42) { 2329 | s4 = peg$c65; 2330 | peg$currPos++; 2331 | } else { 2332 | s4 = peg$FAILED; 2333 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 2334 | } 2335 | if (s4 !== peg$FAILED) { 2336 | peg$savedPos = s0; 2337 | s1 = peg$c67(s3); 2338 | s0 = s1; 2339 | } else { 2340 | peg$currPos = s0; 2341 | s0 = peg$FAILED; 2342 | } 2343 | } else { 2344 | peg$currPos = s0; 2345 | s0 = peg$FAILED; 2346 | } 2347 | } else { 2348 | peg$currPos = s0; 2349 | s0 = peg$FAILED; 2350 | } 2351 | } else { 2352 | peg$currPos = s0; 2353 | s0 = peg$FAILED; 2354 | } 2355 | 2356 | return s0; 2357 | } 2358 | 2359 | function peg$parsestringliteral() { 2360 | var s0, s1, s2, s3; 2361 | 2362 | peg$silentFails++; 2363 | s0 = peg$currPos; 2364 | if (input.charCodeAt(peg$currPos) === 34) { 2365 | s1 = peg$c69; 2366 | peg$currPos++; 2367 | } else { 2368 | s1 = peg$FAILED; 2369 | if (peg$silentFails === 0) { peg$fail(peg$c70); } 2370 | } 2371 | if (s1 !== peg$FAILED) { 2372 | s2 = []; 2373 | s3 = peg$parsestringcharacter(); 2374 | while (s3 !== peg$FAILED) { 2375 | s2.push(s3); 2376 | s3 = peg$parsestringcharacter(); 2377 | } 2378 | if (s2 !== peg$FAILED) { 2379 | if (input.charCodeAt(peg$currPos) === 34) { 2380 | s3 = peg$c69; 2381 | peg$currPos++; 2382 | } else { 2383 | s3 = peg$FAILED; 2384 | if (peg$silentFails === 0) { peg$fail(peg$c70); } 2385 | } 2386 | if (s3 !== peg$FAILED) { 2387 | peg$savedPos = s0; 2388 | s1 = peg$c71(s2); 2389 | s0 = s1; 2390 | } else { 2391 | peg$currPos = s0; 2392 | s0 = peg$FAILED; 2393 | } 2394 | } else { 2395 | peg$currPos = s0; 2396 | s0 = peg$FAILED; 2397 | } 2398 | } else { 2399 | peg$currPos = s0; 2400 | s0 = peg$FAILED; 2401 | } 2402 | peg$silentFails--; 2403 | if (s0 === peg$FAILED) { 2404 | s1 = peg$FAILED; 2405 | if (peg$silentFails === 0) { peg$fail(peg$c68); } 2406 | } 2407 | 2408 | return s0; 2409 | } 2410 | 2411 | function peg$parsestringcharacter() { 2412 | var s0, s1, s2, s3, s4, s5, s6; 2413 | 2414 | if (peg$c72.test(input.charAt(peg$currPos))) { 2415 | s0 = input.charAt(peg$currPos); 2416 | peg$currPos++; 2417 | } else { 2418 | s0 = peg$FAILED; 2419 | if (peg$silentFails === 0) { peg$fail(peg$c73); } 2420 | } 2421 | if (s0 === peg$FAILED) { 2422 | s0 = peg$currPos; 2423 | if (input.substr(peg$currPos, 2) === peg$c74) { 2424 | s1 = peg$c74; 2425 | peg$currPos += 2; 2426 | } else { 2427 | s1 = peg$FAILED; 2428 | if (peg$silentFails === 0) { peg$fail(peg$c75); } 2429 | } 2430 | if (s1 !== peg$FAILED) { 2431 | s2 = peg$currPos; 2432 | if (peg$c76.test(input.charAt(peg$currPos))) { 2433 | s3 = input.charAt(peg$currPos); 2434 | peg$currPos++; 2435 | } else { 2436 | s3 = peg$FAILED; 2437 | if (peg$silentFails === 0) { peg$fail(peg$c77); } 2438 | } 2439 | if (s3 !== peg$FAILED) { 2440 | if (peg$c76.test(input.charAt(peg$currPos))) { 2441 | s4 = input.charAt(peg$currPos); 2442 | peg$currPos++; 2443 | } else { 2444 | s4 = peg$FAILED; 2445 | if (peg$silentFails === 0) { peg$fail(peg$c77); } 2446 | } 2447 | if (s4 !== peg$FAILED) { 2448 | if (peg$c76.test(input.charAt(peg$currPos))) { 2449 | s5 = input.charAt(peg$currPos); 2450 | peg$currPos++; 2451 | } else { 2452 | s5 = peg$FAILED; 2453 | if (peg$silentFails === 0) { peg$fail(peg$c77); } 2454 | } 2455 | if (s5 !== peg$FAILED) { 2456 | if (peg$c76.test(input.charAt(peg$currPos))) { 2457 | s6 = input.charAt(peg$currPos); 2458 | peg$currPos++; 2459 | } else { 2460 | s6 = peg$FAILED; 2461 | if (peg$silentFails === 0) { peg$fail(peg$c77); } 2462 | } 2463 | if (s6 !== peg$FAILED) { 2464 | s3 = [s3, s4, s5, s6]; 2465 | s2 = s3; 2466 | } else { 2467 | peg$currPos = s2; 2468 | s2 = peg$FAILED; 2469 | } 2470 | } else { 2471 | peg$currPos = s2; 2472 | s2 = peg$FAILED; 2473 | } 2474 | } else { 2475 | peg$currPos = s2; 2476 | s2 = peg$FAILED; 2477 | } 2478 | } else { 2479 | peg$currPos = s2; 2480 | s2 = peg$FAILED; 2481 | } 2482 | if (s2 !== peg$FAILED) { 2483 | peg$savedPos = s0; 2484 | s1 = peg$c78(s2); 2485 | s0 = s1; 2486 | } else { 2487 | peg$currPos = s0; 2488 | s0 = peg$FAILED; 2489 | } 2490 | } else { 2491 | peg$currPos = s0; 2492 | s0 = peg$FAILED; 2493 | } 2494 | if (s0 === peg$FAILED) { 2495 | s0 = peg$currPos; 2496 | if (input.charCodeAt(peg$currPos) === 92) { 2497 | s1 = peg$c52; 2498 | peg$currPos++; 2499 | } else { 2500 | s1 = peg$FAILED; 2501 | if (peg$silentFails === 0) { peg$fail(peg$c53); } 2502 | } 2503 | if (s1 !== peg$FAILED) { 2504 | if (peg$c79.test(input.charAt(peg$currPos))) { 2505 | s2 = input.charAt(peg$currPos); 2506 | peg$currPos++; 2507 | } else { 2508 | s2 = peg$FAILED; 2509 | if (peg$silentFails === 0) { peg$fail(peg$c80); } 2510 | } 2511 | if (s2 !== peg$FAILED) { 2512 | peg$savedPos = s0; 2513 | s1 = peg$c81(s2); 2514 | s0 = s1; 2515 | } else { 2516 | peg$currPos = s0; 2517 | s0 = peg$FAILED; 2518 | } 2519 | } else { 2520 | peg$currPos = s0; 2521 | s0 = peg$FAILED; 2522 | } 2523 | if (s0 === peg$FAILED) { 2524 | s0 = peg$currPos; 2525 | if (input.charCodeAt(peg$currPos) === 92) { 2526 | s1 = peg$c52; 2527 | peg$currPos++; 2528 | } else { 2529 | s1 = peg$FAILED; 2530 | if (peg$silentFails === 0) { peg$fail(peg$c53); } 2531 | } 2532 | if (s1 !== peg$FAILED) { 2533 | s2 = peg$parseNEWLINE(); 2534 | if (s2 !== peg$FAILED) { 2535 | if (input.charCodeAt(peg$currPos) === 92) { 2536 | s3 = peg$c52; 2537 | peg$currPos++; 2538 | } else { 2539 | s3 = peg$FAILED; 2540 | if (peg$silentFails === 0) { peg$fail(peg$c53); } 2541 | } 2542 | if (s3 !== peg$FAILED) { 2543 | peg$savedPos = s0; 2544 | s1 = peg$c82(); 2545 | s0 = s1; 2546 | } else { 2547 | peg$currPos = s0; 2548 | s0 = peg$FAILED; 2549 | } 2550 | } else { 2551 | peg$currPos = s0; 2552 | s0 = peg$FAILED; 2553 | } 2554 | } else { 2555 | peg$currPos = s0; 2556 | s0 = peg$FAILED; 2557 | } 2558 | } 2559 | } 2560 | } 2561 | 2562 | return s0; 2563 | } 2564 | 2565 | function peg$parsecodeSpan() { 2566 | var s0, s1, s2, s3, s4, s5; 2567 | 2568 | peg$silentFails++; 2569 | s0 = peg$currPos; 2570 | if (input.charCodeAt(peg$currPos) === 96) { 2571 | s1 = peg$c9; 2572 | peg$currPos++; 2573 | } else { 2574 | s1 = peg$FAILED; 2575 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 2576 | } 2577 | if (s1 !== peg$FAILED) { 2578 | s2 = peg$currPos; 2579 | s3 = []; 2580 | if (peg$c84.test(input.charAt(peg$currPos))) { 2581 | s4 = input.charAt(peg$currPos); 2582 | peg$currPos++; 2583 | } else { 2584 | s4 = peg$FAILED; 2585 | if (peg$silentFails === 0) { peg$fail(peg$c85); } 2586 | } 2587 | if (s4 !== peg$FAILED) { 2588 | while (s4 !== peg$FAILED) { 2589 | s3.push(s4); 2590 | if (peg$c84.test(input.charAt(peg$currPos))) { 2591 | s4 = input.charAt(peg$currPos); 2592 | peg$currPos++; 2593 | } else { 2594 | s4 = peg$FAILED; 2595 | if (peg$silentFails === 0) { peg$fail(peg$c85); } 2596 | } 2597 | } 2598 | } else { 2599 | s3 = peg$FAILED; 2600 | } 2601 | if (s3 !== peg$FAILED) { 2602 | s2 = input.substring(s2, peg$currPos); 2603 | } else { 2604 | s2 = s3; 2605 | } 2606 | if (s2 !== peg$FAILED) { 2607 | if (input.charCodeAt(peg$currPos) === 96) { 2608 | s3 = peg$c9; 2609 | peg$currPos++; 2610 | } else { 2611 | s3 = peg$FAILED; 2612 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 2613 | } 2614 | if (s3 !== peg$FAILED) { 2615 | peg$savedPos = s0; 2616 | s1 = peg$c86(s2); 2617 | s0 = s1; 2618 | } else { 2619 | peg$currPos = s0; 2620 | s0 = peg$FAILED; 2621 | } 2622 | } else { 2623 | peg$currPos = s0; 2624 | s0 = peg$FAILED; 2625 | } 2626 | } else { 2627 | peg$currPos = s0; 2628 | s0 = peg$FAILED; 2629 | } 2630 | if (s0 === peg$FAILED) { 2631 | s0 = peg$currPos; 2632 | s1 = peg$currPos; 2633 | s2 = peg$currPos; 2634 | if (input.charCodeAt(peg$currPos) === 96) { 2635 | s3 = peg$c9; 2636 | peg$currPos++; 2637 | } else { 2638 | s3 = peg$FAILED; 2639 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 2640 | } 2641 | if (s3 !== peg$FAILED) { 2642 | s4 = []; 2643 | if (input.charCodeAt(peg$currPos) === 96) { 2644 | s5 = peg$c9; 2645 | peg$currPos++; 2646 | } else { 2647 | s5 = peg$FAILED; 2648 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 2649 | } 2650 | if (s5 !== peg$FAILED) { 2651 | while (s5 !== peg$FAILED) { 2652 | s4.push(s5); 2653 | if (input.charCodeAt(peg$currPos) === 96) { 2654 | s5 = peg$c9; 2655 | peg$currPos++; 2656 | } else { 2657 | s5 = peg$FAILED; 2658 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 2659 | } 2660 | } 2661 | } else { 2662 | s4 = peg$FAILED; 2663 | } 2664 | if (s4 !== peg$FAILED) { 2665 | s3 = [s3, s4]; 2666 | s2 = s3; 2667 | } else { 2668 | peg$currPos = s2; 2669 | s2 = peg$FAILED; 2670 | } 2671 | } else { 2672 | peg$currPos = s2; 2673 | s2 = peg$FAILED; 2674 | } 2675 | if (s2 !== peg$FAILED) { 2676 | s1 = input.substring(s1, peg$currPos); 2677 | } else { 2678 | s1 = s2; 2679 | } 2680 | if (s1 !== peg$FAILED) { 2681 | peg$savedPos = peg$currPos; 2682 | s2 = peg$c87(s1); 2683 | if (s2) { 2684 | s2 = void 0; 2685 | } else { 2686 | s2 = peg$FAILED; 2687 | } 2688 | if (s2 !== peg$FAILED) { 2689 | s3 = peg$currPos; 2690 | s4 = []; 2691 | s5 = peg$parsecodeSpanInner(); 2692 | while (s5 !== peg$FAILED) { 2693 | s4.push(s5); 2694 | s5 = peg$parsecodeSpanInner(); 2695 | } 2696 | if (s4 !== peg$FAILED) { 2697 | s3 = input.substring(s3, peg$currPos); 2698 | } else { 2699 | s3 = s4; 2700 | } 2701 | if (s3 !== peg$FAILED) { 2702 | s4 = peg$parsecodeSpanTerminator(); 2703 | if (s4 !== peg$FAILED) { 2704 | peg$savedPos = s0; 2705 | s1 = peg$c88(s1, s3); 2706 | s0 = s1; 2707 | } else { 2708 | peg$currPos = s0; 2709 | s0 = peg$FAILED; 2710 | } 2711 | } else { 2712 | peg$currPos = s0; 2713 | s0 = peg$FAILED; 2714 | } 2715 | } else { 2716 | peg$currPos = s0; 2717 | s0 = peg$FAILED; 2718 | } 2719 | } else { 2720 | peg$currPos = s0; 2721 | s0 = peg$FAILED; 2722 | } 2723 | } 2724 | peg$silentFails--; 2725 | if (s0 === peg$FAILED) { 2726 | s1 = peg$FAILED; 2727 | if (peg$silentFails === 0) { peg$fail(peg$c83); } 2728 | } 2729 | 2730 | return s0; 2731 | } 2732 | 2733 | function peg$parsecodeSpanInner() { 2734 | var s0, s1, s2; 2735 | 2736 | s0 = []; 2737 | if (peg$c84.test(input.charAt(peg$currPos))) { 2738 | s1 = input.charAt(peg$currPos); 2739 | peg$currPos++; 2740 | } else { 2741 | s1 = peg$FAILED; 2742 | if (peg$silentFails === 0) { peg$fail(peg$c85); } 2743 | } 2744 | if (s1 !== peg$FAILED) { 2745 | while (s1 !== peg$FAILED) { 2746 | s0.push(s1); 2747 | if (peg$c84.test(input.charAt(peg$currPos))) { 2748 | s1 = input.charAt(peg$currPos); 2749 | peg$currPos++; 2750 | } else { 2751 | s1 = peg$FAILED; 2752 | if (peg$silentFails === 0) { peg$fail(peg$c85); } 2753 | } 2754 | } 2755 | } else { 2756 | s0 = peg$FAILED; 2757 | } 2758 | if (s0 === peg$FAILED) { 2759 | s0 = peg$currPos; 2760 | s1 = peg$currPos; 2761 | peg$silentFails++; 2762 | s2 = peg$parsecodeSpanTerminator(); 2763 | peg$silentFails--; 2764 | if (s2 === peg$FAILED) { 2765 | s1 = void 0; 2766 | } else { 2767 | peg$currPos = s1; 2768 | s1 = peg$FAILED; 2769 | } 2770 | if (s1 !== peg$FAILED) { 2771 | if (input.charCodeAt(peg$currPos) === 96) { 2772 | s2 = peg$c9; 2773 | peg$currPos++; 2774 | } else { 2775 | s2 = peg$FAILED; 2776 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 2777 | } 2778 | if (s2 !== peg$FAILED) { 2779 | s1 = [s1, s2]; 2780 | s0 = s1; 2781 | } else { 2782 | peg$currPos = s0; 2783 | s0 = peg$FAILED; 2784 | } 2785 | } else { 2786 | peg$currPos = s0; 2787 | s0 = peg$FAILED; 2788 | } 2789 | } 2790 | 2791 | return s0; 2792 | } 2793 | 2794 | function peg$parsecodeSpanTerminator() { 2795 | var s0, s1, s2, s3, s4, s5; 2796 | 2797 | s0 = peg$currPos; 2798 | s1 = peg$currPos; 2799 | s2 = peg$currPos; 2800 | if (input.charCodeAt(peg$currPos) === 96) { 2801 | s3 = peg$c9; 2802 | peg$currPos++; 2803 | } else { 2804 | s3 = peg$FAILED; 2805 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 2806 | } 2807 | if (s3 !== peg$FAILED) { 2808 | s4 = []; 2809 | if (input.charCodeAt(peg$currPos) === 96) { 2810 | s5 = peg$c9; 2811 | peg$currPos++; 2812 | } else { 2813 | s5 = peg$FAILED; 2814 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 2815 | } 2816 | if (s5 !== peg$FAILED) { 2817 | while (s5 !== peg$FAILED) { 2818 | s4.push(s5); 2819 | if (input.charCodeAt(peg$currPos) === 96) { 2820 | s5 = peg$c9; 2821 | peg$currPos++; 2822 | } else { 2823 | s5 = peg$FAILED; 2824 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 2825 | } 2826 | } 2827 | } else { 2828 | s4 = peg$FAILED; 2829 | } 2830 | if (s4 !== peg$FAILED) { 2831 | s3 = [s3, s4]; 2832 | s2 = s3; 2833 | } else { 2834 | peg$currPos = s2; 2835 | s2 = peg$FAILED; 2836 | } 2837 | } else { 2838 | peg$currPos = s2; 2839 | s2 = peg$FAILED; 2840 | } 2841 | if (s2 !== peg$FAILED) { 2842 | s1 = input.substring(s1, peg$currPos); 2843 | } else { 2844 | s1 = s2; 2845 | } 2846 | if (s1 !== peg$FAILED) { 2847 | peg$savedPos = peg$currPos; 2848 | s2 = peg$c89(s1); 2849 | if (s2) { 2850 | s2 = void 0; 2851 | } else { 2852 | s2 = peg$FAILED; 2853 | } 2854 | if (s2 !== peg$FAILED) { 2855 | peg$savedPos = s0; 2856 | s1 = peg$c90(s1); 2857 | s0 = s1; 2858 | } else { 2859 | peg$currPos = s0; 2860 | s0 = peg$FAILED; 2861 | } 2862 | } else { 2863 | peg$currPos = s0; 2864 | s0 = peg$FAILED; 2865 | } 2866 | 2867 | return s0; 2868 | } 2869 | 2870 | function peg$parseverbatim() { 2871 | var s0, s1, s2, s3, s4, s5, s6, s7; 2872 | 2873 | peg$silentFails++; 2874 | s0 = peg$currPos; 2875 | if (input.substr(peg$currPos, 2) === peg$c92) { 2876 | s1 = peg$c92; 2877 | peg$currPos += 2; 2878 | } else { 2879 | s1 = peg$FAILED; 2880 | if (peg$silentFails === 0) { peg$fail(peg$c93); } 2881 | } 2882 | if (s1 !== peg$FAILED) { 2883 | s2 = peg$currPos; 2884 | s3 = []; 2885 | if (peg$c94.test(input.charAt(peg$currPos))) { 2886 | s4 = input.charAt(peg$currPos); 2887 | peg$currPos++; 2888 | } else { 2889 | s4 = peg$FAILED; 2890 | if (peg$silentFails === 0) { peg$fail(peg$c95); } 2891 | } 2892 | if (s4 === peg$FAILED) { 2893 | s4 = peg$currPos; 2894 | s5 = []; 2895 | if (input.charCodeAt(peg$currPos) === 124) { 2896 | s6 = peg$c29; 2897 | peg$currPos++; 2898 | } else { 2899 | s6 = peg$FAILED; 2900 | if (peg$silentFails === 0) { peg$fail(peg$c30); } 2901 | } 2902 | if (s6 !== peg$FAILED) { 2903 | while (s6 !== peg$FAILED) { 2904 | s5.push(s6); 2905 | if (input.charCodeAt(peg$currPos) === 124) { 2906 | s6 = peg$c29; 2907 | peg$currPos++; 2908 | } else { 2909 | s6 = peg$FAILED; 2910 | if (peg$silentFails === 0) { peg$fail(peg$c30); } 2911 | } 2912 | } 2913 | } else { 2914 | s5 = peg$FAILED; 2915 | } 2916 | if (s5 !== peg$FAILED) { 2917 | if (peg$c96.test(input.charAt(peg$currPos))) { 2918 | s6 = input.charAt(peg$currPos); 2919 | peg$currPos++; 2920 | } else { 2921 | s6 = peg$FAILED; 2922 | if (peg$silentFails === 0) { peg$fail(peg$c97); } 2923 | } 2924 | if (s6 !== peg$FAILED) { 2925 | s5 = [s5, s6]; 2926 | s4 = s5; 2927 | } else { 2928 | peg$currPos = s4; 2929 | s4 = peg$FAILED; 2930 | } 2931 | } else { 2932 | peg$currPos = s4; 2933 | s4 = peg$FAILED; 2934 | } 2935 | } 2936 | while (s4 !== peg$FAILED) { 2937 | s3.push(s4); 2938 | if (peg$c94.test(input.charAt(peg$currPos))) { 2939 | s4 = input.charAt(peg$currPos); 2940 | peg$currPos++; 2941 | } else { 2942 | s4 = peg$FAILED; 2943 | if (peg$silentFails === 0) { peg$fail(peg$c95); } 2944 | } 2945 | if (s4 === peg$FAILED) { 2946 | s4 = peg$currPos; 2947 | s5 = []; 2948 | if (input.charCodeAt(peg$currPos) === 124) { 2949 | s6 = peg$c29; 2950 | peg$currPos++; 2951 | } else { 2952 | s6 = peg$FAILED; 2953 | if (peg$silentFails === 0) { peg$fail(peg$c30); } 2954 | } 2955 | if (s6 !== peg$FAILED) { 2956 | while (s6 !== peg$FAILED) { 2957 | s5.push(s6); 2958 | if (input.charCodeAt(peg$currPos) === 124) { 2959 | s6 = peg$c29; 2960 | peg$currPos++; 2961 | } else { 2962 | s6 = peg$FAILED; 2963 | if (peg$silentFails === 0) { peg$fail(peg$c30); } 2964 | } 2965 | } 2966 | } else { 2967 | s5 = peg$FAILED; 2968 | } 2969 | if (s5 !== peg$FAILED) { 2970 | if (peg$c96.test(input.charAt(peg$currPos))) { 2971 | s6 = input.charAt(peg$currPos); 2972 | peg$currPos++; 2973 | } else { 2974 | s6 = peg$FAILED; 2975 | if (peg$silentFails === 0) { peg$fail(peg$c97); } 2976 | } 2977 | if (s6 !== peg$FAILED) { 2978 | s5 = [s5, s6]; 2979 | s4 = s5; 2980 | } else { 2981 | peg$currPos = s4; 2982 | s4 = peg$FAILED; 2983 | } 2984 | } else { 2985 | peg$currPos = s4; 2986 | s4 = peg$FAILED; 2987 | } 2988 | } 2989 | } 2990 | if (s3 !== peg$FAILED) { 2991 | s2 = input.substring(s2, peg$currPos); 2992 | } else { 2993 | s2 = s3; 2994 | } 2995 | if (s2 !== peg$FAILED) { 2996 | if (input.substr(peg$currPos, 2) === peg$c98) { 2997 | s3 = peg$c98; 2998 | peg$currPos += 2; 2999 | } else { 3000 | s3 = peg$FAILED; 3001 | if (peg$silentFails === 0) { peg$fail(peg$c99); } 3002 | } 3003 | if (s3 !== peg$FAILED) { 3004 | peg$savedPos = s0; 3005 | s1 = peg$c86(s2); 3006 | s0 = s1; 3007 | } else { 3008 | peg$currPos = s0; 3009 | s0 = peg$FAILED; 3010 | } 3011 | } else { 3012 | peg$currPos = s0; 3013 | s0 = peg$FAILED; 3014 | } 3015 | } else { 3016 | peg$currPos = s0; 3017 | s0 = peg$FAILED; 3018 | } 3019 | if (s0 === peg$FAILED) { 3020 | s0 = peg$currPos; 3021 | if (input.charCodeAt(peg$currPos) === 123) { 3022 | s1 = peg$c18; 3023 | peg$currPos++; 3024 | } else { 3025 | s1 = peg$FAILED; 3026 | if (peg$silentFails === 0) { peg$fail(peg$c19); } 3027 | } 3028 | if (s1 !== peg$FAILED) { 3029 | s2 = peg$parseverbatimEqualSequence(); 3030 | if (s2 !== peg$FAILED) { 3031 | if (input.charCodeAt(peg$currPos) === 124) { 3032 | s3 = peg$c29; 3033 | peg$currPos++; 3034 | } else { 3035 | s3 = peg$FAILED; 3036 | if (peg$silentFails === 0) { peg$fail(peg$c30); } 3037 | } 3038 | if (s3 !== peg$FAILED) { 3039 | peg$savedPos = peg$currPos; 3040 | s4 = peg$c87(s2); 3041 | if (s4) { 3042 | s4 = void 0; 3043 | } else { 3044 | s4 = peg$FAILED; 3045 | } 3046 | if (s4 !== peg$FAILED) { 3047 | s5 = peg$currPos; 3048 | s6 = []; 3049 | s7 = peg$parseverbatimInner(); 3050 | while (s7 !== peg$FAILED) { 3051 | s6.push(s7); 3052 | s7 = peg$parseverbatimInner(); 3053 | } 3054 | if (s6 !== peg$FAILED) { 3055 | s5 = input.substring(s5, peg$currPos); 3056 | } else { 3057 | s5 = s6; 3058 | } 3059 | if (s5 !== peg$FAILED) { 3060 | s6 = peg$parseverbatimTerminator(); 3061 | if (s6 !== peg$FAILED) { 3062 | peg$savedPos = s0; 3063 | s1 = peg$c88(s2, s5); 3064 | s0 = s1; 3065 | } else { 3066 | peg$currPos = s0; 3067 | s0 = peg$FAILED; 3068 | } 3069 | } else { 3070 | peg$currPos = s0; 3071 | s0 = peg$FAILED; 3072 | } 3073 | } else { 3074 | peg$currPos = s0; 3075 | s0 = peg$FAILED; 3076 | } 3077 | } else { 3078 | peg$currPos = s0; 3079 | s0 = peg$FAILED; 3080 | } 3081 | } else { 3082 | peg$currPos = s0; 3083 | s0 = peg$FAILED; 3084 | } 3085 | } else { 3086 | peg$currPos = s0; 3087 | s0 = peg$FAILED; 3088 | } 3089 | } 3090 | peg$silentFails--; 3091 | if (s0 === peg$FAILED) { 3092 | s1 = peg$FAILED; 3093 | if (peg$silentFails === 0) { peg$fail(peg$c91); } 3094 | } 3095 | 3096 | return s0; 3097 | } 3098 | 3099 | function peg$parseverbatimInner() { 3100 | var s0, s1, s2, s3; 3101 | 3102 | s0 = peg$currPos; 3103 | s1 = peg$currPos; 3104 | s2 = []; 3105 | if (peg$c94.test(input.charAt(peg$currPos))) { 3106 | s3 = input.charAt(peg$currPos); 3107 | peg$currPos++; 3108 | } else { 3109 | s3 = peg$FAILED; 3110 | if (peg$silentFails === 0) { peg$fail(peg$c95); } 3111 | } 3112 | if (s3 !== peg$FAILED) { 3113 | while (s3 !== peg$FAILED) { 3114 | s2.push(s3); 3115 | if (peg$c94.test(input.charAt(peg$currPos))) { 3116 | s3 = input.charAt(peg$currPos); 3117 | peg$currPos++; 3118 | } else { 3119 | s3 = peg$FAILED; 3120 | if (peg$silentFails === 0) { peg$fail(peg$c95); } 3121 | } 3122 | } 3123 | } else { 3124 | s2 = peg$FAILED; 3125 | } 3126 | if (s2 !== peg$FAILED) { 3127 | s1 = input.substring(s1, peg$currPos); 3128 | } else { 3129 | s1 = s2; 3130 | } 3131 | if (s1 !== peg$FAILED) { 3132 | peg$savedPos = s0; 3133 | s1 = peg$c100(s1); 3134 | } 3135 | s0 = s1; 3136 | if (s0 === peg$FAILED) { 3137 | s0 = peg$currPos; 3138 | s1 = peg$currPos; 3139 | peg$silentFails++; 3140 | s2 = peg$parseverbatimTerminator(); 3141 | peg$silentFails--; 3142 | if (s2 === peg$FAILED) { 3143 | s1 = void 0; 3144 | } else { 3145 | peg$currPos = s1; 3146 | s1 = peg$FAILED; 3147 | } 3148 | if (s1 !== peg$FAILED) { 3149 | if (input.charCodeAt(peg$currPos) === 124) { 3150 | s2 = peg$c29; 3151 | peg$currPos++; 3152 | } else { 3153 | s2 = peg$FAILED; 3154 | if (peg$silentFails === 0) { peg$fail(peg$c30); } 3155 | } 3156 | if (s2 !== peg$FAILED) { 3157 | peg$savedPos = s0; 3158 | s1 = peg$c100(s2); 3159 | s0 = s1; 3160 | } else { 3161 | peg$currPos = s0; 3162 | s0 = peg$FAILED; 3163 | } 3164 | } else { 3165 | peg$currPos = s0; 3166 | s0 = peg$FAILED; 3167 | } 3168 | } 3169 | 3170 | return s0; 3171 | } 3172 | 3173 | function peg$parseverbatimTerminator() { 3174 | var s0, s1, s2, s3, s4; 3175 | 3176 | s0 = peg$currPos; 3177 | if (input.charCodeAt(peg$currPos) === 124) { 3178 | s1 = peg$c29; 3179 | peg$currPos++; 3180 | } else { 3181 | s1 = peg$FAILED; 3182 | if (peg$silentFails === 0) { peg$fail(peg$c30); } 3183 | } 3184 | if (s1 !== peg$FAILED) { 3185 | s2 = peg$parseverbatimEqualSequence(); 3186 | if (s2 !== peg$FAILED) { 3187 | if (input.charCodeAt(peg$currPos) === 125) { 3188 | s3 = peg$c20; 3189 | peg$currPos++; 3190 | } else { 3191 | s3 = peg$FAILED; 3192 | if (peg$silentFails === 0) { peg$fail(peg$c21); } 3193 | } 3194 | if (s3 !== peg$FAILED) { 3195 | peg$savedPos = peg$currPos; 3196 | s4 = peg$c101(s2); 3197 | if (s4) { 3198 | s4 = void 0; 3199 | } else { 3200 | s4 = peg$FAILED; 3201 | } 3202 | if (s4 !== peg$FAILED) { 3203 | peg$savedPos = s0; 3204 | s1 = peg$c102(s2); 3205 | s0 = s1; 3206 | } else { 3207 | peg$currPos = s0; 3208 | s0 = peg$FAILED; 3209 | } 3210 | } else { 3211 | peg$currPos = s0; 3212 | s0 = peg$FAILED; 3213 | } 3214 | } else { 3215 | peg$currPos = s0; 3216 | s0 = peg$FAILED; 3217 | } 3218 | } else { 3219 | peg$currPos = s0; 3220 | s0 = peg$FAILED; 3221 | } 3222 | 3223 | return s0; 3224 | } 3225 | 3226 | function peg$parseverbatimEqualSequence() { 3227 | var s0, s1, s2, s3; 3228 | 3229 | s0 = peg$currPos; 3230 | s1 = peg$currPos; 3231 | s2 = []; 3232 | if (input.charCodeAt(peg$currPos) === 61) { 3233 | s3 = peg$c103; 3234 | peg$currPos++; 3235 | } else { 3236 | s3 = peg$FAILED; 3237 | if (peg$silentFails === 0) { peg$fail(peg$c104); } 3238 | } 3239 | if (s3 !== peg$FAILED) { 3240 | while (s3 !== peg$FAILED) { 3241 | s2.push(s3); 3242 | if (input.charCodeAt(peg$currPos) === 61) { 3243 | s3 = peg$c103; 3244 | peg$currPos++; 3245 | } else { 3246 | s3 = peg$FAILED; 3247 | if (peg$silentFails === 0) { peg$fail(peg$c104); } 3248 | } 3249 | } 3250 | } else { 3251 | s2 = peg$FAILED; 3252 | } 3253 | if (s2 !== peg$FAILED) { 3254 | s1 = input.substring(s1, peg$currPos); 3255 | } else { 3256 | s1 = s2; 3257 | } 3258 | if (s1 !== peg$FAILED) { 3259 | peg$savedPos = s0; 3260 | s1 = peg$c105(s1); 3261 | } 3262 | s0 = s1; 3263 | 3264 | return s0; 3265 | } 3266 | 3267 | function peg$parsenumberliteral() { 3268 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; 3269 | 3270 | peg$silentFails++; 3271 | s0 = peg$currPos; 3272 | if (input.charCodeAt(peg$currPos) === 45) { 3273 | s1 = peg$c37; 3274 | peg$currPos++; 3275 | } else { 3276 | s1 = peg$FAILED; 3277 | if (peg$silentFails === 0) { peg$fail(peg$c38); } 3278 | } 3279 | if (s1 !== peg$FAILED) { 3280 | s2 = peg$parsenumberliteral(); 3281 | if (s2 !== peg$FAILED) { 3282 | peg$savedPos = s0; 3283 | s1 = peg$c107(s2); 3284 | s0 = s1; 3285 | } else { 3286 | peg$currPos = s0; 3287 | s0 = peg$FAILED; 3288 | } 3289 | } else { 3290 | peg$currPos = s0; 3291 | s0 = peg$FAILED; 3292 | } 3293 | if (s0 === peg$FAILED) { 3294 | s0 = peg$currPos; 3295 | if (input.substr(peg$currPos, 2) === peg$c108) { 3296 | s1 = peg$c108; 3297 | peg$currPos += 2; 3298 | } else { 3299 | s1 = peg$FAILED; 3300 | if (peg$silentFails === 0) { peg$fail(peg$c109); } 3301 | } 3302 | if (s1 === peg$FAILED) { 3303 | if (input.substr(peg$currPos, 2) === peg$c110) { 3304 | s1 = peg$c110; 3305 | peg$currPos += 2; 3306 | } else { 3307 | s1 = peg$FAILED; 3308 | if (peg$silentFails === 0) { peg$fail(peg$c111); } 3309 | } 3310 | } 3311 | if (s1 !== peg$FAILED) { 3312 | s2 = peg$currPos; 3313 | s3 = []; 3314 | if (peg$c112.test(input.charAt(peg$currPos))) { 3315 | s4 = input.charAt(peg$currPos); 3316 | peg$currPos++; 3317 | } else { 3318 | s4 = peg$FAILED; 3319 | if (peg$silentFails === 0) { peg$fail(peg$c113); } 3320 | } 3321 | if (s4 !== peg$FAILED) { 3322 | while (s4 !== peg$FAILED) { 3323 | s3.push(s4); 3324 | if (peg$c112.test(input.charAt(peg$currPos))) { 3325 | s4 = input.charAt(peg$currPos); 3326 | peg$currPos++; 3327 | } else { 3328 | s4 = peg$FAILED; 3329 | if (peg$silentFails === 0) { peg$fail(peg$c113); } 3330 | } 3331 | } 3332 | } else { 3333 | s3 = peg$FAILED; 3334 | } 3335 | if (s3 !== peg$FAILED) { 3336 | s2 = input.substring(s2, peg$currPos); 3337 | } else { 3338 | s2 = s3; 3339 | } 3340 | if (s2 !== peg$FAILED) { 3341 | peg$savedPos = s0; 3342 | s1 = peg$c114(s2); 3343 | s0 = s1; 3344 | } else { 3345 | peg$currPos = s0; 3346 | s0 = peg$FAILED; 3347 | } 3348 | } else { 3349 | peg$currPos = s0; 3350 | s0 = peg$FAILED; 3351 | } 3352 | if (s0 === peg$FAILED) { 3353 | s0 = peg$currPos; 3354 | s1 = peg$currPos; 3355 | s2 = peg$currPos; 3356 | s3 = []; 3357 | if (peg$c115.test(input.charAt(peg$currPos))) { 3358 | s4 = input.charAt(peg$currPos); 3359 | peg$currPos++; 3360 | } else { 3361 | s4 = peg$FAILED; 3362 | if (peg$silentFails === 0) { peg$fail(peg$c116); } 3363 | } 3364 | if (s4 !== peg$FAILED) { 3365 | while (s4 !== peg$FAILED) { 3366 | s3.push(s4); 3367 | if (peg$c115.test(input.charAt(peg$currPos))) { 3368 | s4 = input.charAt(peg$currPos); 3369 | peg$currPos++; 3370 | } else { 3371 | s4 = peg$FAILED; 3372 | if (peg$silentFails === 0) { peg$fail(peg$c116); } 3373 | } 3374 | } 3375 | } else { 3376 | s3 = peg$FAILED; 3377 | } 3378 | if (s3 !== peg$FAILED) { 3379 | s4 = peg$currPos; 3380 | if (input.charCodeAt(peg$currPos) === 46) { 3381 | s5 = peg$c117; 3382 | peg$currPos++; 3383 | } else { 3384 | s5 = peg$FAILED; 3385 | if (peg$silentFails === 0) { peg$fail(peg$c118); } 3386 | } 3387 | if (s5 !== peg$FAILED) { 3388 | s6 = []; 3389 | if (peg$c115.test(input.charAt(peg$currPos))) { 3390 | s7 = input.charAt(peg$currPos); 3391 | peg$currPos++; 3392 | } else { 3393 | s7 = peg$FAILED; 3394 | if (peg$silentFails === 0) { peg$fail(peg$c116); } 3395 | } 3396 | if (s7 !== peg$FAILED) { 3397 | while (s7 !== peg$FAILED) { 3398 | s6.push(s7); 3399 | if (peg$c115.test(input.charAt(peg$currPos))) { 3400 | s7 = input.charAt(peg$currPos); 3401 | peg$currPos++; 3402 | } else { 3403 | s7 = peg$FAILED; 3404 | if (peg$silentFails === 0) { peg$fail(peg$c116); } 3405 | } 3406 | } 3407 | } else { 3408 | s6 = peg$FAILED; 3409 | } 3410 | if (s6 !== peg$FAILED) { 3411 | s5 = [s5, s6]; 3412 | s4 = s5; 3413 | } else { 3414 | peg$currPos = s4; 3415 | s4 = peg$FAILED; 3416 | } 3417 | } else { 3418 | peg$currPos = s4; 3419 | s4 = peg$FAILED; 3420 | } 3421 | if (s4 === peg$FAILED) { 3422 | s4 = null; 3423 | } 3424 | if (s4 !== peg$FAILED) { 3425 | s5 = peg$currPos; 3426 | if (peg$c119.test(input.charAt(peg$currPos))) { 3427 | s6 = input.charAt(peg$currPos); 3428 | peg$currPos++; 3429 | } else { 3430 | s6 = peg$FAILED; 3431 | if (peg$silentFails === 0) { peg$fail(peg$c120); } 3432 | } 3433 | if (s6 !== peg$FAILED) { 3434 | if (peg$c121.test(input.charAt(peg$currPos))) { 3435 | s7 = input.charAt(peg$currPos); 3436 | peg$currPos++; 3437 | } else { 3438 | s7 = peg$FAILED; 3439 | if (peg$silentFails === 0) { peg$fail(peg$c122); } 3440 | } 3441 | if (s7 === peg$FAILED) { 3442 | s7 = null; 3443 | } 3444 | if (s7 !== peg$FAILED) { 3445 | s8 = []; 3446 | if (peg$c115.test(input.charAt(peg$currPos))) { 3447 | s9 = input.charAt(peg$currPos); 3448 | peg$currPos++; 3449 | } else { 3450 | s9 = peg$FAILED; 3451 | if (peg$silentFails === 0) { peg$fail(peg$c116); } 3452 | } 3453 | if (s9 !== peg$FAILED) { 3454 | while (s9 !== peg$FAILED) { 3455 | s8.push(s9); 3456 | if (peg$c115.test(input.charAt(peg$currPos))) { 3457 | s9 = input.charAt(peg$currPos); 3458 | peg$currPos++; 3459 | } else { 3460 | s9 = peg$FAILED; 3461 | if (peg$silentFails === 0) { peg$fail(peg$c116); } 3462 | } 3463 | } 3464 | } else { 3465 | s8 = peg$FAILED; 3466 | } 3467 | if (s8 !== peg$FAILED) { 3468 | s6 = [s6, s7, s8]; 3469 | s5 = s6; 3470 | } else { 3471 | peg$currPos = s5; 3472 | s5 = peg$FAILED; 3473 | } 3474 | } else { 3475 | peg$currPos = s5; 3476 | s5 = peg$FAILED; 3477 | } 3478 | } else { 3479 | peg$currPos = s5; 3480 | s5 = peg$FAILED; 3481 | } 3482 | if (s5 === peg$FAILED) { 3483 | s5 = null; 3484 | } 3485 | if (s5 !== peg$FAILED) { 3486 | s3 = [s3, s4, s5]; 3487 | s2 = s3; 3488 | } else { 3489 | peg$currPos = s2; 3490 | s2 = peg$FAILED; 3491 | } 3492 | } else { 3493 | peg$currPos = s2; 3494 | s2 = peg$FAILED; 3495 | } 3496 | } else { 3497 | peg$currPos = s2; 3498 | s2 = peg$FAILED; 3499 | } 3500 | if (s2 !== peg$FAILED) { 3501 | s1 = input.substring(s1, peg$currPos); 3502 | } else { 3503 | s1 = s2; 3504 | } 3505 | if (s1 !== peg$FAILED) { 3506 | peg$savedPos = s0; 3507 | s1 = peg$c123(s1); 3508 | } 3509 | s0 = s1; 3510 | } 3511 | } 3512 | peg$silentFails--; 3513 | if (s0 === peg$FAILED) { 3514 | s1 = peg$FAILED; 3515 | if (peg$silentFails === 0) { peg$fail(peg$c106); } 3516 | } 3517 | 3518 | return s0; 3519 | } 3520 | 3521 | function peg$parseidentifier() { 3522 | var s0, s1, s2, s3, s4, s5, s6; 3523 | 3524 | peg$silentFails++; 3525 | s0 = peg$currPos; 3526 | s1 = peg$parsePOS(); 3527 | if (s1 !== peg$FAILED) { 3528 | s2 = peg$currPos; 3529 | s3 = peg$currPos; 3530 | if (peg$c125.test(input.charAt(peg$currPos))) { 3531 | s4 = input.charAt(peg$currPos); 3532 | peg$currPos++; 3533 | } else { 3534 | s4 = peg$FAILED; 3535 | if (peg$silentFails === 0) { peg$fail(peg$c126); } 3536 | } 3537 | if (s4 !== peg$FAILED) { 3538 | s5 = []; 3539 | if (peg$c127.test(input.charAt(peg$currPos))) { 3540 | s6 = input.charAt(peg$currPos); 3541 | peg$currPos++; 3542 | } else { 3543 | s6 = peg$FAILED; 3544 | if (peg$silentFails === 0) { peg$fail(peg$c128); } 3545 | } 3546 | while (s6 !== peg$FAILED) { 3547 | s5.push(s6); 3548 | if (peg$c127.test(input.charAt(peg$currPos))) { 3549 | s6 = input.charAt(peg$currPos); 3550 | peg$currPos++; 3551 | } else { 3552 | s6 = peg$FAILED; 3553 | if (peg$silentFails === 0) { peg$fail(peg$c128); } 3554 | } 3555 | } 3556 | if (s5 !== peg$FAILED) { 3557 | s4 = [s4, s5]; 3558 | s3 = s4; 3559 | } else { 3560 | peg$currPos = s3; 3561 | s3 = peg$FAILED; 3562 | } 3563 | } else { 3564 | peg$currPos = s3; 3565 | s3 = peg$FAILED; 3566 | } 3567 | if (s3 !== peg$FAILED) { 3568 | s2 = input.substring(s2, peg$currPos); 3569 | } else { 3570 | s2 = s3; 3571 | } 3572 | if (s2 !== peg$FAILED) { 3573 | s3 = peg$parsePOS(); 3574 | if (s3 !== peg$FAILED) { 3575 | peg$savedPos = s0; 3576 | s1 = peg$c129(s1, s2, s3); 3577 | s0 = s1; 3578 | } else { 3579 | peg$currPos = s0; 3580 | s0 = peg$FAILED; 3581 | } 3582 | } else { 3583 | peg$currPos = s0; 3584 | s0 = peg$FAILED; 3585 | } 3586 | } else { 3587 | peg$currPos = s0; 3588 | s0 = peg$FAILED; 3589 | } 3590 | peg$silentFails--; 3591 | if (s0 === peg$FAILED) { 3592 | s1 = peg$FAILED; 3593 | if (peg$silentFails === 0) { peg$fail(peg$c124); } 3594 | } 3595 | 3596 | return s0; 3597 | } 3598 | 3599 | function peg$parsetextidentifier() { 3600 | var s0, s1, s2, s3, s4, s5; 3601 | 3602 | peg$silentFails++; 3603 | s0 = peg$currPos; 3604 | s1 = peg$currPos; 3605 | s2 = peg$currPos; 3606 | if (peg$c131.test(input.charAt(peg$currPos))) { 3607 | s3 = input.charAt(peg$currPos); 3608 | peg$currPos++; 3609 | } else { 3610 | s3 = peg$FAILED; 3611 | if (peg$silentFails === 0) { peg$fail(peg$c132); } 3612 | } 3613 | if (s3 !== peg$FAILED) { 3614 | s4 = []; 3615 | if (peg$c133.test(input.charAt(peg$currPos))) { 3616 | s5 = input.charAt(peg$currPos); 3617 | peg$currPos++; 3618 | } else { 3619 | s5 = peg$FAILED; 3620 | if (peg$silentFails === 0) { peg$fail(peg$c134); } 3621 | } 3622 | while (s5 !== peg$FAILED) { 3623 | s4.push(s5); 3624 | if (peg$c133.test(input.charAt(peg$currPos))) { 3625 | s5 = input.charAt(peg$currPos); 3626 | peg$currPos++; 3627 | } else { 3628 | s5 = peg$FAILED; 3629 | if (peg$silentFails === 0) { peg$fail(peg$c134); } 3630 | } 3631 | } 3632 | if (s4 !== peg$FAILED) { 3633 | s3 = [s3, s4]; 3634 | s2 = s3; 3635 | } else { 3636 | peg$currPos = s2; 3637 | s2 = peg$FAILED; 3638 | } 3639 | } else { 3640 | peg$currPos = s2; 3641 | s2 = peg$FAILED; 3642 | } 3643 | if (s2 !== peg$FAILED) { 3644 | s1 = input.substring(s1, peg$currPos); 3645 | } else { 3646 | s1 = s2; 3647 | } 3648 | if (s1 !== peg$FAILED) { 3649 | peg$savedPos = s0; 3650 | s1 = peg$c135(s1); 3651 | } 3652 | s0 = s1; 3653 | peg$silentFails--; 3654 | if (s0 === peg$FAILED) { 3655 | s1 = peg$FAILED; 3656 | if (peg$silentFails === 0) { peg$fail(peg$c130); } 3657 | } 3658 | 3659 | return s0; 3660 | } 3661 | 3662 | function peg$parseSPACE_CHARACTER() { 3663 | var s0, s1; 3664 | 3665 | peg$silentFails++; 3666 | if (peg$c137.test(input.charAt(peg$currPos))) { 3667 | s0 = input.charAt(peg$currPos); 3668 | peg$currPos++; 3669 | } else { 3670 | s0 = peg$FAILED; 3671 | if (peg$silentFails === 0) { peg$fail(peg$c138); } 3672 | } 3673 | peg$silentFails--; 3674 | if (s0 === peg$FAILED) { 3675 | s1 = peg$FAILED; 3676 | if (peg$silentFails === 0) { peg$fail(peg$c136); } 3677 | } 3678 | 3679 | return s0; 3680 | } 3681 | 3682 | function peg$parseLINE_BREAK() { 3683 | var s0, s1, s2; 3684 | 3685 | peg$silentFails++; 3686 | s0 = peg$currPos; 3687 | if (input.charCodeAt(peg$currPos) === 13) { 3688 | s1 = peg$c140; 3689 | peg$currPos++; 3690 | } else { 3691 | s1 = peg$FAILED; 3692 | if (peg$silentFails === 0) { peg$fail(peg$c141); } 3693 | } 3694 | if (s1 === peg$FAILED) { 3695 | s1 = null; 3696 | } 3697 | if (s1 !== peg$FAILED) { 3698 | if (input.charCodeAt(peg$currPos) === 10) { 3699 | s2 = peg$c142; 3700 | peg$currPos++; 3701 | } else { 3702 | s2 = peg$FAILED; 3703 | if (peg$silentFails === 0) { peg$fail(peg$c143); } 3704 | } 3705 | if (s2 !== peg$FAILED) { 3706 | s1 = [s1, s2]; 3707 | s0 = s1; 3708 | } else { 3709 | peg$currPos = s0; 3710 | s0 = peg$FAILED; 3711 | } 3712 | } else { 3713 | peg$currPos = s0; 3714 | s0 = peg$FAILED; 3715 | } 3716 | peg$silentFails--; 3717 | if (s0 === peg$FAILED) { 3718 | s1 = peg$FAILED; 3719 | if (peg$silentFails === 0) { peg$fail(peg$c139); } 3720 | } 3721 | 3722 | return s0; 3723 | } 3724 | 3725 | function peg$parseSPACE_CHARACTER_OR_NEWLINE() { 3726 | var s0, s1; 3727 | 3728 | peg$silentFails++; 3729 | if (peg$c145.test(input.charAt(peg$currPos))) { 3730 | s0 = input.charAt(peg$currPos); 3731 | peg$currPos++; 3732 | } else { 3733 | s0 = peg$FAILED; 3734 | if (peg$silentFails === 0) { peg$fail(peg$c146); } 3735 | } 3736 | peg$silentFails--; 3737 | if (s0 === peg$FAILED) { 3738 | s1 = peg$FAILED; 3739 | if (peg$silentFails === 0) { peg$fail(peg$c144); } 3740 | } 3741 | 3742 | return s0; 3743 | } 3744 | 3745 | function peg$parseCOMMENT() { 3746 | var s0, s1, s2, s3, s4; 3747 | 3748 | peg$silentFails++; 3749 | s0 = peg$currPos; 3750 | s1 = peg$currPos; 3751 | if (input.charCodeAt(peg$currPos) === 59) { 3752 | s2 = peg$c148; 3753 | peg$currPos++; 3754 | } else { 3755 | s2 = peg$FAILED; 3756 | if (peg$silentFails === 0) { peg$fail(peg$c149); } 3757 | } 3758 | if (s2 !== peg$FAILED) { 3759 | s3 = []; 3760 | if (peg$c33.test(input.charAt(peg$currPos))) { 3761 | s4 = input.charAt(peg$currPos); 3762 | peg$currPos++; 3763 | } else { 3764 | s4 = peg$FAILED; 3765 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 3766 | } 3767 | while (s4 !== peg$FAILED) { 3768 | s3.push(s4); 3769 | if (peg$c33.test(input.charAt(peg$currPos))) { 3770 | s4 = input.charAt(peg$currPos); 3771 | peg$currPos++; 3772 | } else { 3773 | s4 = peg$FAILED; 3774 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 3775 | } 3776 | } 3777 | if (s3 !== peg$FAILED) { 3778 | s4 = peg$parseLINE_BREAK(); 3779 | if (s4 !== peg$FAILED) { 3780 | s2 = [s2, s3, s4]; 3781 | s1 = s2; 3782 | } else { 3783 | peg$currPos = s1; 3784 | s1 = peg$FAILED; 3785 | } 3786 | } else { 3787 | peg$currPos = s1; 3788 | s1 = peg$FAILED; 3789 | } 3790 | } else { 3791 | peg$currPos = s1; 3792 | s1 = peg$FAILED; 3793 | } 3794 | if (s1 !== peg$FAILED) { 3795 | s0 = input.substring(s0, peg$currPos); 3796 | } else { 3797 | s0 = s1; 3798 | } 3799 | peg$silentFails--; 3800 | if (s0 === peg$FAILED) { 3801 | s1 = peg$FAILED; 3802 | if (peg$silentFails === 0) { peg$fail(peg$c147); } 3803 | } 3804 | 3805 | return s0; 3806 | } 3807 | 3808 | function peg$parseSPACES() { 3809 | var s0, s1, s2; 3810 | 3811 | peg$silentFails++; 3812 | s0 = peg$currPos; 3813 | s1 = []; 3814 | s2 = peg$parseSPACE_CHARACTER(); 3815 | if (s2 !== peg$FAILED) { 3816 | while (s2 !== peg$FAILED) { 3817 | s1.push(s2); 3818 | s2 = peg$parseSPACE_CHARACTER(); 3819 | } 3820 | } else { 3821 | s1 = peg$FAILED; 3822 | } 3823 | if (s1 !== peg$FAILED) { 3824 | s0 = input.substring(s0, peg$currPos); 3825 | } else { 3826 | s0 = s1; 3827 | } 3828 | peg$silentFails--; 3829 | if (s0 === peg$FAILED) { 3830 | s1 = peg$FAILED; 3831 | if (peg$silentFails === 0) { peg$fail(peg$c150); } 3832 | } 3833 | 3834 | return s0; 3835 | } 3836 | 3837 | function peg$parseEXPRESSION_SPACE() { 3838 | var s0; 3839 | 3840 | s0 = peg$parseSPACE_CHARACTER_OR_NEWLINE(); 3841 | if (s0 === peg$FAILED) { 3842 | s0 = peg$parseCOMMENT(); 3843 | } 3844 | 3845 | return s0; 3846 | } 3847 | 3848 | function peg$parseOPTIONAL_EXPRESSION_SPACES() { 3849 | var s0, s1, s2; 3850 | 3851 | s0 = peg$currPos; 3852 | s1 = []; 3853 | s2 = peg$parseEXPRESSION_SPACE(); 3854 | while (s2 !== peg$FAILED) { 3855 | s1.push(s2); 3856 | s2 = peg$parseEXPRESSION_SPACE(); 3857 | } 3858 | if (s1 !== peg$FAILED) { 3859 | s0 = input.substring(s0, peg$currPos); 3860 | } else { 3861 | s0 = s1; 3862 | } 3863 | 3864 | return s0; 3865 | } 3866 | 3867 | function peg$parsePARAGRAPH_BREAK() { 3868 | var s0, s1, s2, s3, s4, s5; 3869 | 3870 | peg$silentFails++; 3871 | s0 = peg$currPos; 3872 | s1 = peg$parseLINE_BREAK(); 3873 | if (s1 !== peg$FAILED) { 3874 | s2 = []; 3875 | s3 = peg$currPos; 3876 | s4 = peg$parseSPACES(); 3877 | if (s4 === peg$FAILED) { 3878 | s4 = null; 3879 | } 3880 | if (s4 !== peg$FAILED) { 3881 | s5 = peg$parseLINE_BREAK(); 3882 | if (s5 !== peg$FAILED) { 3883 | s4 = [s4, s5]; 3884 | s3 = s4; 3885 | } else { 3886 | peg$currPos = s3; 3887 | s3 = peg$FAILED; 3888 | } 3889 | } else { 3890 | peg$currPos = s3; 3891 | s3 = peg$FAILED; 3892 | } 3893 | if (s3 !== peg$FAILED) { 3894 | while (s3 !== peg$FAILED) { 3895 | s2.push(s3); 3896 | s3 = peg$currPos; 3897 | s4 = peg$parseSPACES(); 3898 | if (s4 === peg$FAILED) { 3899 | s4 = null; 3900 | } 3901 | if (s4 !== peg$FAILED) { 3902 | s5 = peg$parseLINE_BREAK(); 3903 | if (s5 !== peg$FAILED) { 3904 | s4 = [s4, s5]; 3905 | s3 = s4; 3906 | } else { 3907 | peg$currPos = s3; 3908 | s3 = peg$FAILED; 3909 | } 3910 | } else { 3911 | peg$currPos = s3; 3912 | s3 = peg$FAILED; 3913 | } 3914 | } 3915 | } else { 3916 | s2 = peg$FAILED; 3917 | } 3918 | if (s2 !== peg$FAILED) { 3919 | s3 = peg$parseINDENT_SAME(); 3920 | if (s3 !== peg$FAILED) { 3921 | s1 = [s1, s2, s3]; 3922 | s0 = s1; 3923 | } else { 3924 | peg$currPos = s0; 3925 | s0 = peg$FAILED; 3926 | } 3927 | } else { 3928 | peg$currPos = s0; 3929 | s0 = peg$FAILED; 3930 | } 3931 | } else { 3932 | peg$currPos = s0; 3933 | s0 = peg$FAILED; 3934 | } 3935 | peg$silentFails--; 3936 | if (s0 === peg$FAILED) { 3937 | s1 = peg$FAILED; 3938 | if (peg$silentFails === 0) { peg$fail(peg$c151); } 3939 | } 3940 | 3941 | return s0; 3942 | } 3943 | 3944 | function peg$parseNEWLINE() { 3945 | var s0, s1, s2, s3; 3946 | 3947 | s0 = peg$currPos; 3948 | s1 = peg$parseLINE_BREAK(); 3949 | if (s1 !== peg$FAILED) { 3950 | s2 = []; 3951 | s3 = peg$parseSPACE_CHARACTER_OR_NEWLINE(); 3952 | while (s3 !== peg$FAILED) { 3953 | s2.push(s3); 3954 | s3 = peg$parseSPACE_CHARACTER_OR_NEWLINE(); 3955 | } 3956 | if (s2 !== peg$FAILED) { 3957 | s1 = [s1, s2]; 3958 | s0 = s1; 3959 | } else { 3960 | peg$currPos = s0; 3961 | s0 = peg$FAILED; 3962 | } 3963 | } else { 3964 | peg$currPos = s0; 3965 | s0 = peg$FAILED; 3966 | } 3967 | 3968 | return s0; 3969 | } 3970 | 3971 | function peg$parseTEXT_IN_SEGMENT_LINEBREAK() { 3972 | var s0, s1, s2, s3, s4; 3973 | 3974 | peg$silentFails++; 3975 | s0 = peg$currPos; 3976 | s1 = peg$parseLINE_BREAK(); 3977 | if (s1 !== peg$FAILED) { 3978 | s2 = peg$parseINDENT_SAME(); 3979 | if (s2 !== peg$FAILED) { 3980 | s3 = peg$currPos; 3981 | peg$silentFails++; 3982 | s4 = peg$parseLINE_BREAK(); 3983 | peg$silentFails--; 3984 | if (s4 === peg$FAILED) { 3985 | s3 = void 0; 3986 | } else { 3987 | peg$currPos = s3; 3988 | s3 = peg$FAILED; 3989 | } 3990 | if (s3 !== peg$FAILED) { 3991 | s1 = [s1, s2, s3]; 3992 | s0 = s1; 3993 | } else { 3994 | peg$currPos = s0; 3995 | s0 = peg$FAILED; 3996 | } 3997 | } else { 3998 | peg$currPos = s0; 3999 | s0 = peg$FAILED; 4000 | } 4001 | } else { 4002 | peg$currPos = s0; 4003 | s0 = peg$FAILED; 4004 | } 4005 | peg$silentFails--; 4006 | if (s0 === peg$FAILED) { 4007 | s1 = peg$FAILED; 4008 | if (peg$silentFails === 0) { peg$fail(peg$c152); } 4009 | } 4010 | 4011 | return s0; 4012 | } 4013 | 4014 | function peg$parseNEWLINE_INDENT_ADD() { 4015 | var s0, s1, s2, s3; 4016 | 4017 | s0 = peg$currPos; 4018 | s1 = peg$parseLINE_BREAK(); 4019 | if (s1 !== peg$FAILED) { 4020 | s2 = peg$parseSPACES(); 4021 | if (s2 === peg$FAILED) { 4022 | s2 = null; 4023 | } 4024 | if (s2 !== peg$FAILED) { 4025 | s3 = peg$parseNEWLINE_INDENT_ADD(); 4026 | if (s3 !== peg$FAILED) { 4027 | s1 = [s1, s2, s3]; 4028 | s0 = s1; 4029 | } else { 4030 | peg$currPos = s0; 4031 | s0 = peg$FAILED; 4032 | } 4033 | } else { 4034 | peg$currPos = s0; 4035 | s0 = peg$FAILED; 4036 | } 4037 | } else { 4038 | peg$currPos = s0; 4039 | s0 = peg$FAILED; 4040 | } 4041 | if (s0 === peg$FAILED) { 4042 | s0 = peg$currPos; 4043 | s1 = peg$parseLINE_BREAK(); 4044 | if (s1 !== peg$FAILED) { 4045 | s2 = peg$parseINDENT_ADD(); 4046 | if (s2 !== peg$FAILED) { 4047 | s1 = [s1, s2]; 4048 | s0 = s1; 4049 | } else { 4050 | peg$currPos = s0; 4051 | s0 = peg$FAILED; 4052 | } 4053 | } else { 4054 | peg$currPos = s0; 4055 | s0 = peg$FAILED; 4056 | } 4057 | } 4058 | 4059 | return s0; 4060 | } 4061 | 4062 | function peg$parseNEWLINE_INDENT_SAME() { 4063 | var s0, s1, s2, s3; 4064 | 4065 | s0 = peg$currPos; 4066 | s1 = peg$parseLINE_BREAK(); 4067 | if (s1 !== peg$FAILED) { 4068 | s2 = peg$parseSPACES(); 4069 | if (s2 === peg$FAILED) { 4070 | s2 = null; 4071 | } 4072 | if (s2 !== peg$FAILED) { 4073 | s3 = peg$parseNEWLINE_INDENT_SAME(); 4074 | if (s3 !== peg$FAILED) { 4075 | s1 = [s1, s2, s3]; 4076 | s0 = s1; 4077 | } else { 4078 | peg$currPos = s0; 4079 | s0 = peg$FAILED; 4080 | } 4081 | } else { 4082 | peg$currPos = s0; 4083 | s0 = peg$FAILED; 4084 | } 4085 | } else { 4086 | peg$currPos = s0; 4087 | s0 = peg$FAILED; 4088 | } 4089 | if (s0 === peg$FAILED) { 4090 | s0 = peg$currPos; 4091 | s1 = peg$parseLINE_BREAK(); 4092 | if (s1 !== peg$FAILED) { 4093 | s2 = peg$parseINDENT_SAME(); 4094 | if (s2 !== peg$FAILED) { 4095 | s1 = [s1, s2]; 4096 | s0 = s1; 4097 | } else { 4098 | peg$currPos = s0; 4099 | s0 = peg$FAILED; 4100 | } 4101 | } else { 4102 | peg$currPos = s0; 4103 | s0 = peg$FAILED; 4104 | } 4105 | } 4106 | 4107 | return s0; 4108 | } 4109 | 4110 | function peg$parseNEWLINE_INDENT_SAME_OR_MORE() { 4111 | var s0, s1, s2, s3, s4, s5; 4112 | 4113 | s0 = peg$currPos; 4114 | s1 = peg$parseLINE_BREAK(); 4115 | if (s1 !== peg$FAILED) { 4116 | s2 = []; 4117 | s3 = peg$currPos; 4118 | s4 = peg$parseSPACES(); 4119 | if (s4 === peg$FAILED) { 4120 | s4 = null; 4121 | } 4122 | if (s4 !== peg$FAILED) { 4123 | s5 = peg$parseLINE_BREAK(); 4124 | if (s5 !== peg$FAILED) { 4125 | s4 = [s4, s5]; 4126 | s3 = s4; 4127 | } else { 4128 | peg$currPos = s3; 4129 | s3 = peg$FAILED; 4130 | } 4131 | } else { 4132 | peg$currPos = s3; 4133 | s3 = peg$FAILED; 4134 | } 4135 | while (s3 !== peg$FAILED) { 4136 | s2.push(s3); 4137 | s3 = peg$currPos; 4138 | s4 = peg$parseSPACES(); 4139 | if (s4 === peg$FAILED) { 4140 | s4 = null; 4141 | } 4142 | if (s4 !== peg$FAILED) { 4143 | s5 = peg$parseLINE_BREAK(); 4144 | if (s5 !== peg$FAILED) { 4145 | s4 = [s4, s5]; 4146 | s3 = s4; 4147 | } else { 4148 | peg$currPos = s3; 4149 | s3 = peg$FAILED; 4150 | } 4151 | } else { 4152 | peg$currPos = s3; 4153 | s3 = peg$FAILED; 4154 | } 4155 | } 4156 | if (s2 !== peg$FAILED) { 4157 | s3 = peg$parseINDENT_SAME_OR_MORE(); 4158 | if (s3 !== peg$FAILED) { 4159 | s1 = [s1, s2, s3]; 4160 | s0 = s1; 4161 | } else { 4162 | peg$currPos = s0; 4163 | s0 = peg$FAILED; 4164 | } 4165 | } else { 4166 | peg$currPos = s0; 4167 | s0 = peg$FAILED; 4168 | } 4169 | } else { 4170 | peg$currPos = s0; 4171 | s0 = peg$FAILED; 4172 | } 4173 | 4174 | return s0; 4175 | } 4176 | 4177 | function peg$parsePOS() { 4178 | var s0, s1; 4179 | 4180 | s0 = peg$currPos; 4181 | s1 = peg$c153; 4182 | if (s1 !== peg$FAILED) { 4183 | peg$savedPos = s0; 4184 | s1 = peg$c154(); 4185 | } 4186 | s0 = s1; 4187 | 4188 | return s0; 4189 | } 4190 | 4191 | function peg$parseINDENT_CLEAR_ON() { 4192 | var s0, s1; 4193 | 4194 | s0 = peg$currPos; 4195 | s1 = peg$c153; 4196 | if (s1 !== peg$FAILED) { 4197 | peg$savedPos = s0; 4198 | s1 = peg$c155(); 4199 | } 4200 | s0 = s1; 4201 | 4202 | return s0; 4203 | } 4204 | 4205 | function peg$parseINDENT_CLEAR_OFF() { 4206 | var s0, s1; 4207 | 4208 | s0 = peg$currPos; 4209 | s1 = peg$c153; 4210 | if (s1 !== peg$FAILED) { 4211 | peg$savedPos = s0; 4212 | s1 = peg$c156(); 4213 | } 4214 | s0 = s1; 4215 | 4216 | return s0; 4217 | } 4218 | 4219 | function peg$parseINDENT_ADD() { 4220 | var s0, s1, s2; 4221 | 4222 | s0 = peg$currPos; 4223 | s1 = peg$parseSPACES(); 4224 | if (s1 !== peg$FAILED) { 4225 | peg$savedPos = peg$currPos; 4226 | s2 = peg$c157(s1); 4227 | if (s2) { 4228 | s2 = void 0; 4229 | } else { 4230 | s2 = peg$FAILED; 4231 | } 4232 | if (s2 !== peg$FAILED) { 4233 | peg$savedPos = s0; 4234 | s1 = peg$c158(s1); 4235 | s0 = s1; 4236 | } else { 4237 | peg$currPos = s0; 4238 | s0 = peg$FAILED; 4239 | } 4240 | } else { 4241 | peg$currPos = s0; 4242 | s0 = peg$FAILED; 4243 | } 4244 | 4245 | return s0; 4246 | } 4247 | 4248 | function peg$parseINDENT_REMOVE() { 4249 | var s0, s1; 4250 | 4251 | s0 = peg$currPos; 4252 | s1 = peg$c153; 4253 | if (s1 !== peg$FAILED) { 4254 | peg$savedPos = s0; 4255 | s1 = peg$c156(); 4256 | } 4257 | s0 = s1; 4258 | 4259 | return s0; 4260 | } 4261 | 4262 | function peg$parseINDENT_SAME() { 4263 | var s0, s1, s2; 4264 | 4265 | s0 = peg$currPos; 4266 | s1 = peg$currPos; 4267 | s2 = peg$parseSPACES(); 4268 | if (s2 === peg$FAILED) { 4269 | s2 = null; 4270 | } 4271 | if (s2 !== peg$FAILED) { 4272 | s1 = input.substring(s1, peg$currPos); 4273 | } else { 4274 | s1 = s2; 4275 | } 4276 | if (s1 !== peg$FAILED) { 4277 | peg$savedPos = peg$currPos; 4278 | s2 = peg$c159(s1); 4279 | if (s2) { 4280 | s2 = void 0; 4281 | } else { 4282 | s2 = peg$FAILED; 4283 | } 4284 | if (s2 !== peg$FAILED) { 4285 | s1 = [s1, s2]; 4286 | s0 = s1; 4287 | } else { 4288 | peg$currPos = s0; 4289 | s0 = peg$FAILED; 4290 | } 4291 | } else { 4292 | peg$currPos = s0; 4293 | s0 = peg$FAILED; 4294 | } 4295 | 4296 | return s0; 4297 | } 4298 | 4299 | function peg$parseINDENT_SAME_OR_MORE() { 4300 | var s0, s1, s2; 4301 | 4302 | s0 = peg$currPos; 4303 | s1 = peg$currPos; 4304 | s2 = peg$parseSPACES(); 4305 | if (s2 === peg$FAILED) { 4306 | s2 = null; 4307 | } 4308 | if (s2 !== peg$FAILED) { 4309 | s1 = input.substring(s1, peg$currPos); 4310 | } else { 4311 | s1 = s2; 4312 | } 4313 | if (s1 !== peg$FAILED) { 4314 | peg$savedPos = peg$currPos; 4315 | s2 = peg$c160(s1); 4316 | if (s2) { 4317 | s2 = void 0; 4318 | } else { 4319 | s2 = peg$FAILED; 4320 | } 4321 | if (s2 !== peg$FAILED) { 4322 | s1 = [s1, s2]; 4323 | s0 = s1; 4324 | } else { 4325 | peg$currPos = s0; 4326 | s0 = peg$FAILED; 4327 | } 4328 | } else { 4329 | peg$currPos = s0; 4330 | s0 = peg$FAILED; 4331 | } 4332 | 4333 | return s0; 4334 | } 4335 | 4336 | 4337 | var Reference = options.Reference; 4338 | var Position = options.Position; 4339 | var storedVerbatimTerminator; 4340 | var formLine = function(content) { 4341 | if(content.length === 1) return content[0] 4342 | else return [new Reference('.cons_line')].concat(content) 4343 | }; 4344 | var formBlock = function(content) { 4345 | if(content.length === 1) return content[0] 4346 | else return [new Reference('.cons_block')].concat(content) 4347 | }; 4348 | var nVerbatimTests = 0; 4349 | var textIndentStack = []; 4350 | var textIndent = ""; 4351 | 4352 | 4353 | peg$result = peg$startRuleFunction(); 4354 | 4355 | if (peg$result !== peg$FAILED && peg$currPos === input.length) { 4356 | return peg$result; 4357 | } else { 4358 | if (peg$result !== peg$FAILED && peg$currPos < input.length) { 4359 | peg$fail(peg$endExpectation()); 4360 | } 4361 | 4362 | throw peg$buildStructuredError( 4363 | peg$maxFailExpected, 4364 | peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, 4365 | peg$maxFailPos < input.length 4366 | ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) 4367 | : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) 4368 | ); 4369 | } 4370 | } 4371 | 4372 | module.exports = { 4373 | SyntaxError: peg$SyntaxError, 4374 | parse: peg$parse 4375 | }; 4376 | --------------------------------------------------------------------------------