diff --git a/package.json b/package.json index 5876e0ced..2c9d42b70 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ ], "scripts": { "prepublishOnly": "tsc", - "build": "tsc", + "build": "scripts/build.sh", "test": "jest", "test-coveralls": "jest --coverage --coverageReporters=text-lcov | coveralls" }, @@ -39,6 +39,8 @@ "@types/invariant": "^2.2.29", "@types/jest": "^23.1.4", "@types/node": "^9.4.7", + "babel-preset-es2015": "^6.24.1", + "babel-preset-stage-2": "^6.24.1", "coveralls": "^3.0.1", "jest": "^23.3.0", "ts-jest": "^23.0.0", @@ -50,7 +52,8 @@ "js" ], "transform": { - "\\.ts$": "/node_modules/ts-jest/preprocessor.js" + "\\.ts$": "/node_modules/ts-jest/preprocessor.js", + "\\.js$": "/node_modules/babel-jest" }, "testRegex": "/__tests__/.*\\.ts$", "testPathIgnorePatterns": [ diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 000000000..f948710b8 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,6 @@ +# Compile all .ts files, then +# copy the only .js file, parser.js, to dist. +# This is required because it is not possible to both inlcude .js +# files (allowJs = true) and export type declarations (declarations = true) +# in tsconfig. See https://github.com/Microsoft/TypeScript/issues/7546 +tsc && cp src/stdlib/parser.js dist/stdlib diff --git a/src/createContext.ts b/src/createContext.ts index 16c4e30c6..b71409051 100644 --- a/src/createContext.ts +++ b/src/createContext.ts @@ -3,6 +3,10 @@ import * as misc from './stdlib/misc' import { Context, CustomBuiltIns, Value } from './types' import { toString } from '.'; +/** Import meta-circular parser */ +const createParserModule = require('./stdlib/parser') +const createParser = createParserModule.default + const GLOBAL = typeof window === 'undefined' ? global : window const createEmptyCFG = () => ({ @@ -24,7 +28,8 @@ export const createEmptyContext = (chapter: number, externalSymbols: string[] errors: [], externalContext, cfg: createEmptyCFG(), - runtime: createEmptyRuntime() + runtime: createEmptyRuntime(), + metaCircularParser: createParser() }) export const ensureGlobalEnvironmentExist = (context: Context) => { @@ -131,6 +136,34 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn defineSymbol(context, 'array_length', misc.array_length) } + if (context.chapter >= 4) { + defineSymbol(context, 'stringify', JSON.stringify) + defineSymbol(context, 'parse', + function () { + return context.metaCircularParser + .parse.apply(context.metaCircularParser, arguments) + }); + defineSymbol(context, 'apply_in_underlying_javascript', function( + fun: Function, + args: Value + ) { + const res = [] + var i = 0 + while (!(args.length === 0)) { + res[i] = args[0] + i = i + 1 + args = args[1] + } + return fun.apply(fun, res) + }) + defineSymbol(context, 'is_number', misc.is_number) + defineSymbol(context, 'is_array', misc.is_array) + defineSymbol(context, 'is_object', misc.is_object) + defineSymbol(context, 'is_string', misc.is_string) + defineSymbol(context, 'is_function', misc.is_function) + defineSymbol(context, 'is_boolean', misc.is_boolean) + } + if (context.chapter >= Infinity) { // previously week 4 defineSymbol(context, 'alert', alert) @@ -140,7 +173,6 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn defineSymbol(context, 'assoc', list.assoc) defineSymbol(context, 'draw', visualiseList) // previously week 6 - defineSymbol(context, 'is_number', misc.is_number) } } diff --git a/src/stdlib/metacircular-interpreter/Makefile b/src/stdlib/metacircular-interpreter/Makefile new file mode 100644 index 000000000..b11d71cce --- /dev/null +++ b/src/stdlib/metacircular-interpreter/Makefile @@ -0,0 +1,33 @@ +INTERPRETER_CORE = lib/exports.js.tpl \ + lib/interpreter/interpreter.js \ + lib/interpreter/json2.js \ + lib/interpreter/parser.jison.tpl \ + lib/util/io.js + +PARSER = lib/interpreter/parser.js + +.PHONY: environment academy + +all: environment + +# removed from dependencies for environment: ../list.js ../object.js ../stream.js +environment: lib/interpreter/parser.js + +clean: + rm -f jediscript-*.js + +distclean: clean + rm -f lib/*.js + +academy: environment + node generate.js --interpreter 5 --without_jquery + node generate.js --interpreter 8 --without_jquery + node generate.js --interpreter 13 --without_jquery --debug + +offline_zip: environment + node generate.js --interpreter 5 + node generate.js --interpreter 8 + node generate.js --interpreter 13 + +$(PARSER): $(INTERPRETER_CORE) + node generate.js --environment diff --git a/src/stdlib/metacircular-interpreter/README.md b/src/stdlib/metacircular-interpreter/README.md new file mode 100644 index 000000000..388427cba --- /dev/null +++ b/src/stdlib/metacircular-interpreter/README.md @@ -0,0 +1,32 @@ +# JediScript Meta-Circular Evaluator +####_vastly more up-to-date instructions, in nice Markdown format._ + +This project comprises 4 main components: + +1. The parser, written in Jison +2. The interpreter, written in legal JediScript +3. The scratch project templates, which are a combination of JediScript, JavaScript, and Markup-JS (a templating engine) +4. The project generator (`generate.js`) + +These all work together to form the functional evaluator. + +## Setting up the environment +1. This project depends on node.js. Install [node.js](http://nodejs.org) for your platform. +2. Using the shell for your platform, run `envsetup.{sh|bat}`. This will obtain the necessary installation dependencies and generate the development versions of the templates. + - Note that your Jison install will be patched to throw SyntaxError exceptions when parse errors occur. This may affect your other Jison dependents, if any. +2 (alternative) . Just run `npm install` and all the dependencies should be magically installed. +3. If you have made changes to the templates, generate new development libraries by running `generate.js --environment`. +4. `scratch.html` in the root directory of the project has got the evaluator-in-evaluator code being part of `test3`. Use that to test the interpreter interpreting itself. + +## Generating Student Scratch Projects +In addition to generating the development libraries, the templates can be used in concert with the generator to produce scratch projects which only contain valid JediScript elements for any given week. Generate these by running `generate.js --week N`. + +If you are modifying the templates, note that: + +- When modifying the Jison template source, Jison blocks within Markup-JS blocks (i.e. Jison declarations within the `{{if}}` or other blocks) must have `$$` escaped to `$$$`. This is because Markup-JS will remove one `$`, leaving invalid Jison declarations +- If new user-defined functions must be provided to the student, update `export.js`. `export.js` contains a list of key-value pairs, which will be registered in the interpreter so the student can access them from his script file. +- By default, the generated scratch project will have the parser screen the input from the student's script tags and evaluate it. The student's code can still be directly evaluated by the browser's JavaScript engine by passing `--native` (`--no-native` will equivalently enable interpreted mode. But that's the default) +- The generator will send all output through to Google's Closure compiler, both to shrink the codebase and also to optimise the code. Passing `--debug` while generating the package will suppress this, so that the generator (or the libraries) can be debugged. + +## Unit Testing +I've coded unit tests for the interpreter. Open `test.html`, the test suite will run automatically. This uses the parser and other libraries generated by `generate.js --environment`, so be sure to run it before any testing. diff --git a/src/stdlib/metacircular-interpreter/count/count-tokens.js b/src/stdlib/metacircular-interpreter/count/count-tokens.js new file mode 100644 index 000000000..ef72bcafc --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/count-tokens.js @@ -0,0 +1,81 @@ + +var jison = require("./lib/interpreter/parser-week-13"); + +function parse(text) { + return new jison.Parser().parse(text); +} + +function findSource(text, start_line, start_col, end_line, end_col) { + var lines = text.replace(/\r/g, '').split('\n'); + + --start_line, --end_line; // 0-based indexing for lines + // cols are already 0-based + + var range = []; + for (var i=start_line; i<=end_line; i++) { + range.push(lines[i]); + } + + if (range.length === 1) { + range[0] = range[0].slice(start_col, end_col+1); + return range[0]; + } else { + range[0] = range[0].slice(start_col); + range[range.length-1] = range[range.length-1].slice(0, end_col+1); + return range.join('\n'); + } +} + +function listToArray(xs) { + var result = []; + while (xs.length !== 0) { + result.push(xs[0]); + xs = xs[1]; + } + return result; +} + +function findTopLevelFunctionDeclarations(text) { + var ast = listToArray(parse(text)); + var declarations = ast.filter(function (node) { + return node.tag === 'var_definition' + && node.value + && node.value.tag === 'function_definition'; + }).map(function (node) { + var loc = node.value.location; + return { + name: node.variable, + source: findSource(text, loc.start_line, loc.start_col, loc.end_line, loc.end_col) + }; + }); + return declarations; +} + +// Invert symbol object so we can easily lookup symbol names + +var symbols = new jison.Parser().symbols_; +var symbolName = {}; +Object.keys(symbols).forEach(function (key) { + symbolName[symbols[key]] = key; +}); + +function lex(input) { + var lexer = new jison.Parser().lexer; + lexer.setInput(input); + var token; + var tokens = []; + while (symbolName[token = lexer.lex()] !== 'EOF') { + tokens.push(symbolName[token]); + } + return tokens; +} + +module.exports = { + count: function(program) { + var declarations = findTopLevelFunctionDeclarations(program); + declarations.forEach(function (item) { + item.count = lex(item.source).length; + }); + return declarations; + } +}; \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/count/example.js b/src/stdlib/metacircular-interpreter/count/example.js new file mode 100644 index 000000000..aad1c52c0 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/example.js @@ -0,0 +1,8 @@ + +var fs = require('fs'); +var count = require('./count-tokens').count; + +var input = "function x()\n{return 1;}\nfunction y()\n{return 1;}\nfunction z()\n{return 10;}"; + +console.log(count(input)); +console.log(count(fs.readFileSync('shouldbe36.js', 'utf8'))); diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/nodes.js b/src/stdlib/metacircular-interpreter/count/lib/interpreter/nodes.js new file mode 100644 index 000000000..08e40a1b5 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/nodes.js @@ -0,0 +1,531 @@ +/*globals define*/ +/** @module nodes + * Functions for manipulating a JediScript AST. + * @author Joel Low + */ + function is_null(xs) { + return xs === null; + } + + function is_undefined_value(value) { + return value === undefined; + } + + function is_number(xs) { + return typeof xs === 'number'; + } + + function is_NaN(x) { + return is_number(x) && isNaN(x); + } + + function is_string(xs) { + return typeof xs === 'string'; + } + + function is_boolean(xs) { + return typeof xs === 'boolean'; + } + + function is_object(xs) { + return typeof xs === 'object' || is_function(xs); + } + + function is_array(xs) { + return is_object(xs) && (xs instanceof Array); + } + + function pair(a, b) { + return [a, b]; + } + + function is_empty_list(pr) { + return is_pair(pr) && pr.length === 0; + } + + function head(pr) { + if (is_pair(pr) && !is_empty_list(pr)) { + return pr[0]; + } else { + return undefined; + } + } + + function tail(pr) { + if (is_pair(pr) && !is_empty_list(pr)) { + return pr[1]; + } else { + return undefined; + } + } + + function is_pair(xs) { + return is_array(xs) && (xs.length === 0 || xs.length === 2); + } + + function is_list(xs) { + return is_pair(xs) && (is_empty_list(xs) || is_list(tail(xs))); + } + + function is_function(xs) { + return typeof xs === 'function'; + } + + function is_tagged_object(object, tag) { + return is_object(object) && object.tag === tag; + } + + module.exports = { + stmt_line: function(stmt) { + return stmt.line; + }, + + is_undefined_value: is_undefined_value, + is_number: is_number, + is_string: is_string, + is_boolean: is_boolean, + pair: pair, + is_empty_list: is_empty_list, + head: head, + tail: tail, + + no_op: function() { + return null; + }, + + is_sequence: is_list, + empty_stmt: is_empty_list, + last_stmt: function(stmts) { + return is_empty_list(tail(stmts)); + }, + first_stmt: head, + rest_stmts: tail, + + if_statement: function(predicate, consequent, alternative, line_number) { + return { + tag: 'if', + predicate: predicate, + consequent: consequent, + alternative: alternative, + line: line_number + }; + }, + + is_if_statement: function(stmt) { + return is_tagged_object(stmt, 'if'); + }, + + if_predicate: function(stmt) { + return stmt.predicate; + }, + + if_consequent: function(stmt) { + return stmt.consequent; + }, + + if_alternative: function(stmt) { + return stmt.alternative; + }, + + while_statement: function(predicate, statements, line_number) { + return { + tag: 'while', + predicate: predicate, + statements: statements, + line: line_number + }; + }, + + is_while_statement: function(stmt) { + return is_tagged_object(stmt, 'while'); + }, + + while_predicate: function(stmt) { + return stmt.predicate; + }, + + while_statements: function(stmt) { + return stmt.statements; + }, + + for_statement: function(initialiser, predicate, finaliser, statements, line_number) { + return { + tag: 'for', + initialiser: initialiser, + predicate: predicate, + finaliser: finaliser, + statements: statements, + line: line_number + }; + }, + + is_for_statement: function(stmt) { + return is_tagged_object(stmt, 'for'); + }, + + for_initialiser: function(stmt) { + return stmt.initialiser; + }, + + for_predicate: function(stmt) { + return stmt.predicate; + }, + + for_finaliser: function(stmt) { + return stmt.finaliser; + }, + + for_statements: function(stmt) { + return stmt.statements; + }, + + break_statement: function(line_number) { + return { + tag: 'break_statement', + line: line_number + }; + }, + + is_break_statement: function(stmt) { + return is_tagged_object(stmt, 'break_statement'); + }, + + continue_statement: function(line_number) { + return { + tag: 'continue_statement', + line: line_number + }; + }, + + is_continue_statement: function(stmt) { + return is_tagged_object(stmt, 'continue_statement'); + }, + + function_definition: function(identifier, parameters, statements, start_token, end_token) { + return { + tag: 'function_definition', + name: identifier, + parameters: parameters, + body: statements, + location: { + start_line: start_token.first_line, + start_col: start_token.first_column, + start_offset: start_token.range[0], + end_line: end_token.last_line, + end_col: end_token.last_column, + end_offset: end_token.range[1] + }, + line: end_token.last_line - 1 + }; + }, + + is_function_definition: function(stmt) { + return is_tagged_object(stmt, 'function_definition'); + }, + + function_definition_name: function(stmt) { + return stmt.name; + }, + + function_definition_parameters: function(stmt) { + return stmt.parameters; + }, + + function_definition_body: function(stmt) { + return stmt.body; + }, + + function_definition_text_location: function(stmt) { + return stmt.location; + }, + + return_statement: function(expression, line_number) { + return { + tag: 'return_statement', + expression: expression, + line: line_number + }; + }, + + is_return_statement: function(stmt) { + return is_tagged_object(stmt, 'return_statement'); + }, + + return_statement_expression: function(stmt) { + return stmt.expression; + }, + + variable_definition: function(identifier, expression, line_number) { + return { + tag: 'var_definition', + variable: identifier, + value: expression, + line: line_number + }; + }, + + is_var_definition: function(stmt) { + return is_tagged_object(stmt, 'var_definition'); + }, + + var_definition_variable: function(stmt) { + return stmt.variable; + }, + + var_definition_value: function(stmt) { + return stmt.value; + }, + + assignment: function(variable, expression, line_number) { + return { + tag: 'assignment', + variable: variable, + value: expression, + line: line_number + }; + }, + + is_assignment: function(stmt) { + return is_tagged_object(stmt, 'assignment'); + }, + + assignment_variable: function(stmt) { + return stmt.variable; + }, + + assignment_value: function(stmt) { + return stmt.value; + }, + + property_assignment: function(object, property, expression, line_number) { + return { + tag: 'property_assignment', + object: object, + property: property, + value: expression, + line: line_number + }; + }, + + is_property_assignment: function(stmt) { + return is_tagged_object(stmt, 'property_assignment'); + }, + + property_assignment_object: function(stmt) { + return stmt.object; + }, + + property_assignment_property: function(stmt) { + return stmt.property; + }, + + property_assignment_value: function(stmt) { + return stmt.value; + }, + + eager_binary_expression: function(lhs, op, rhs, line_number) { + return this.application(this.variable(op, line_number), [lhs, [rhs, []]], line_number); + }, + + eager_unary_expression: function(op, expr, line_number) { + return this.application(this.variable(op, line_number), [expr, []], line_number); + }, + + boolean_operation: function(lhs, op, rhs, line_number) { + return { + tag: 'boolean_op', + operator: op, + operands: [lhs, [rhs, []]], + line: line_number + }; + }, + + is_boolean_operation: function(stmt) { + return is_tagged_object(stmt, 'boolean_op'); + }, + + property_access: function(object, property, line_number) { + return { + tag: 'property_access', + object: object, + property: property, + line: line_number + }; + }, + + is_property_access: function(stmt) { + return is_tagged_object(stmt, 'property_access'); + }, + + property_access_object: function(stmt) { + return stmt.object; + }, + + property_access_property: function(stmt) { + return stmt.property; + }, + + variable: function(identifier, line_number) { + return { + tag: 'variable', + name: identifier, + line: line_number + }; + }, + + is_variable: function(stmt) { + return is_tagged_object(stmt, 'variable'); + }, + + variable_name: function(stmt) { + return stmt.name; + }, + + application: function(operator, operands, line_number) { + return { + tag: 'application', + operator: operator, + operands: operands, + line: line_number + }; + }, + + is_application: function(stmt) { + return is_tagged_object(stmt, 'application'); + }, + + operator: function(stmt) { + return stmt.operator; + }, + + operands: function(stmt) { + return stmt.operands; + }, + + no_operands: is_empty_list, + first_operand: head, + rest_operands: tail, + + object_method_application: function(object, property, operands, line_number) { + return { + tag: 'object_method_application', + object: object, + property: property, + operands: operands, + line: line_number + }; + }, + + is_object_method_application: function(stmt) { + return is_tagged_object(stmt, 'object_method_application'); + }, + + object: function(stmt) { + return stmt.object; + }, + + object_property: function(stmt) { + return stmt.property; + }, + + construction: function(type, operands, line_number) { + return { + tag: 'construction', + type: type, + operands: operands, + line: line_number + }; + }, + + is_construction: function(stmt) { + return is_tagged_object(stmt, 'construction'); + }, + + construction_type: function(stmt) { + return stmt.type; + }, + + ternary: function(predicate, consequent, alternative, line_number) { + return { + tag: 'ternary', + predicate: predicate, + consequent: consequent, + alternative: alternative, + line: line_number + }; + }, + + is_ternary_statement: function(stmt) { + return is_tagged_object(stmt, 'ternary'); + }, + + ternary_predicate: function(stmt) { + return stmt.predicate; + }, + + ternary_consequent: function(stmt) { + return stmt.consequent; + }, + + ternary_alternative: function(stmt) { + return stmt.alternative; + }, + + is_self_evaluating: function(stmt) { + return is_number(stmt) || is_string(stmt) || is_boolean(stmt); + }, + + empty_list: function(line_number) { + return { + tag: 'empty_list', + line: line_number + }; + }, + + is_empty_list_statement: function(stmt) { + return is_tagged_object(stmt, 'empty_list'); + }, + + array_literal: function(elements, line_number) { + return { + tag: 'arrayinit', + elements: elements, + line: line_number + }; + }, + + is_array_expression: function(stmt) { + return is_tagged_object(stmt, 'arrayinit'); + }, + + array_expression_elements: function(stmt) { + return stmt.elements; + }, + + first_array_element: head, + rest_array_elements: tail, + empty_array_element: is_empty_list, + + object_literal: function(statements, line_number) { + return { + tag: 'object', + pairs: statements, + line: line_number + }; + }, + + is_object_expression: function(stmt) { + return is_tagged_object(stmt, 'object'); + }, + + object_expression_pairs: function(stmt) { + return stmt.pairs; + }, + + first_object_expression_pair: head, + rest_object_expression_pairs: tail, + empty_object_expression_pairs: is_empty_list, + object_expression_pair_key: head, + object_expression_pair_value: tail + }; + diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/nodes.js.patch b/src/stdlib/metacircular-interpreter/count/lib/interpreter/nodes.js.patch new file mode 100644 index 000000000..58380e8de --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/nodes.js.patch @@ -0,0 +1,40 @@ +--- nodes copy.js 2015-09-17 13:56:30.000000000 +0800 ++++ nodes.js 2015-09-17 19:35:47.000000000 +0800 +@@ -3,8 +3,6 @@ + * Functions for manipulating a JediScript AST. + * @author Joel Low + */ +-define(function() { +- 'use strict'; + function is_null(xs) { + return xs === null; + } +@@ -77,7 +75,7 @@ + return is_object(object) && object.tag === tag; + } + +- var module = { ++ module.exports = { + stmt_line: function(stmt) { + return stmt.line; + }, +@@ -326,11 +324,11 @@ + }, + + eager_binary_expression: function(lhs, op, rhs, line_number) { +- return module.application(module.variable(op, line_number), [lhs, [rhs, []]], line_number); ++ return this.application(this.variable(op, line_number), [lhs, [rhs, []]], line_number); + }, + + eager_unary_expression: function(op, expr, line_number) { +- return module.application(module.variable(op, line_number), [expr, []], line_number); ++ return this.application(this.variable(op, line_number), [expr, []], line_number); + }, + + boolean_operation: function(lhs, op, rhs, line_number) { +@@ -531,5 +529,3 @@ + object_expression_pair_value: tail + }; + +- return module; +-}); diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-10.js b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-10.js new file mode 100644 index 000000000..29cc242ff --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-10.js @@ -0,0 +1,874 @@ +/* parser generated by jison 0.4.15 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +var parserWeek10 = (function(){ +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,15],$V1=[1,16],$V2=[1,24],$V3=[1,17],$V4=[1,18],$V5=[1,19],$V6=[1,20],$V7=[1,22],$V8=[1,21],$V9=[1,23],$Va=[1,38],$Vb=[1,29],$Vc=[1,31],$Vd=[1,32],$Ve=[1,33],$Vf=[1,34],$Vg=[1,35],$Vh=[1,36],$Vi=[1,37],$Vj=[16,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,47,54],$Vk=[2,68],$Vl=[1,47],$Vm=[1,43],$Vn=[5,9],$Vo=[5,8,9,16,20,21,24,25,28,29,31,32,36,45,52,56,57,58,59,60,61,67],$Vp=[1,55],$Vq=[1,56],$Vr=[1,57],$Vs=[1,58],$Vt=[1,59],$Vu=[1,60],$Vv=[1,61],$Vw=[1,62],$Vx=[1,63],$Vy=[1,64],$Vz=[1,65],$VA=[1,66],$VB=[1,67],$VC=[1,68],$VD=[1,69],$VE=[1,70],$VF=[1,74],$VG=[1,76],$VH=[9,16,22,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,46,47,54,55,64],$VI=[2,51],$VJ=[1,82],$VK=[2,75],$VL=[5,8,9,16,20,21,22,23,24,25,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,52,54,55,56,57,58,59,60,61,64,67],$VM=[1,90],$VN=[2,79],$VO=[9,16,22,30,31,32,33,34,35,37,38,39,40,41,42,43,44,46,54,55,64],$VP=[22,46],$VQ=[9,16,22,30,31,32,37,38,39,40,41,42,43,44,46,54,55,64],$VR=[9,16,22,30,37,38,39,40,46,54,55,64],$VS=[9,16,22,30,37,38,39,40,41,42,43,44,46,54,55,64],$VT=[1,140]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"program":3,"statements":4,"EOF":5,"statement_block":6,"empty_block":7,"{":8,"}":9,"non_empty_statements":10,"statement":11,"if_statement":12,"while_statement":13,"function_definition":14,"return_statement":15,";":16,"variable_definition":17,"assignment_statement":18,"expression":19,"if":20,"(":21,")":22,"else":23,"while":24,"function":25,"identifier":26,"identifiers":27,"return":28,"var":29,"=":30,"+":31,"-":32,"*":33,"/":34,"%":35,"!":36,"&&":37,"||":38,"===":39,"!==":40,">":41,"<":42,">=":43,"<=":44,"[":45,"]":46,".":47,"constants":48,"expressions":49,"array_literal":50,"object_literal":51,"new":52,"function_expression":53,"?":54,":":55,"STRING":56,"FLOAT_NUMBER":57,"INT_NUMBER":58,"true":59,"false":60,"empty_list":61,"non_empty_object_literal_statements":62,"object_literal_statement":63,",":64,"non_empty_expressions":65,"non_empty_identifiers":66,"Identifier":67,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",8:"{",9:"}",16:";",20:"if",21:"(",22:")",23:"else",24:"while",25:"function",28:"return",29:"var",30:"=",31:"+",32:"-",33:"*",34:"/",35:"%",36:"!",37:"&&",38:"||",39:"===",40:"!==",41:">",42:"<",43:">=",44:"<=",45:"[",46:"]",47:".",52:"new",54:"?",55:":",56:"STRING",57:"FLOAT_NUMBER",58:"INT_NUMBER",59:"true",60:"false",61:"empty_list",64:",",67:"Identifier"}, +productions_: [0,[3,2],[3,2],[3,2],[7,2],[6,3],[4,0],[4,1],[10,2],[10,1],[11,1],[11,1],[11,1],[11,2],[11,2],[11,2],[11,2],[11,1],[12,7],[12,7],[12,7],[12,7],[12,7],[12,7],[13,5],[13,5],[14,6],[14,6],[15,2],[17,4],[18,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,2],[19,2],[19,2],[19,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,4],[19,3],[19,3],[19,1],[19,1],[19,6],[19,1],[19,1],[19,4],[19,6],[19,5],[19,1],[19,5],[48,1],[48,1],[48,1],[48,1],[48,1],[48,1],[50,3],[51,3],[51,1],[62,3],[62,1],[63,3],[53,5],[53,5],[49,1],[49,0],[65,3],[65,1],[27,1],[27,0],[66,3],[66,1],[26,1]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: case 2: case 3: + return $$[$0-1]; +break; +case 4: + this.$ = [] +break; +case 5: case 49: + this.$ = $$[$0-1]; +break; +case 6: case 75: case 79: + this.$ = []; +break; +case 8: + + if ($$[$0-1] === Nodes.no_op()) { + this.$ = $$[$0]; + } else { + this.$ = Nodes.pair($$[$0-1], $$[$0]); + } + +break; +case 9: + + if ($$[$0] === Nodes.no_op()) { + this.$ = []; + } else { + this.$ = Nodes.pair($$[$0], []); + } + +break; +case 17: + this.$ = Nodes.no_op(); +break; +case 18: case 19: case 20: case 21: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 22: case 23: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], Nodes.pair($$[$0], []), yylineno); +break; +case 24: case 25: + this.$ = Nodes.while_statement($$[$0-2], $$[$0], yylineno) +break; +case 26: case 27: + this.$ = Nodes.variable_definition($$[$0-4], Nodes.function_definition($$[$0-4], $$[$0-2], $$[$0], _$[$0-5], _$[$0]), yylineno); +break; +case 28: + this.$ = Nodes.return_statement($$[$0], yylineno); +break; +case 29: + this.$ = Nodes.variable_definition($$[$0-2], $$[$0], yylineno); +break; +case 30: + + if ($$[$0-2].tag === 'variable') { + this.$ = Nodes.assignment($$[$0-2], $$[$0], yylineno); + + } else if ($$[$0-2].tag === 'property_access') { + this.$ = Nodes.property_assignment($$[$0-2].object, $$[$0-2].property, $$[$0], yylineno); + + } else { + error('parse error in line ' + yylineno + ": " + yytext); + } + +break; +case 31: case 32: case 33: case 34: case 35: case 41: case 42: case 43: case 44: case 45: case 46: + this.$ = Nodes.eager_binary_expression($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 36: case 37: + this.$ = Nodes.eager_binary_expression(0, $$[$0-1], $$[$0], yylineno); +break; +case 38: + this.$ = Nodes.eager_unary_expression($$[$0-1], $$[$0], yylineno); +break; +case 39: case 40: + this.$ = Nodes.boolean_operation($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 47: + this.$ = Nodes.property_access($$[$0-3], $$[$0-1], yylineno); +break; +case 48: + this.$ = Nodes.property_access($$[$0-2], $$[$0], yylineno); +break; +case 51: + this.$ = Nodes.variable($$[$0], yylineno); +break; +case 52: + this.$ = Nodes.application($$[$0-4], $$[$0-1], yylineno); +break; +case 55: + this.$ = Nodes.application(Nodes.variable($$[$0-3], yylineno), $$[$0-1], yylineno); +break; +case 56: + this.$ = Nodes.object_method_application($$[$0-5], $$[$0-3], $$[$0-1], yylineno); +break; +case 57: + this.$ = Nodes.construction($$[$0-3], $$[$0-1], yylineno); +break; +case 59: + this.$ = Nodes.ternary($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 60: case 82: + this.$ = yytext; +break; +case 61: + this.$ = parseFloat(yytext); +break; +case 62: + this.$ = parseInt(yytext, 10); +break; +case 63: + this.$ = true; +break; +case 64: + this.$ = false; +break; +case 65: + this.$ = Nodes.empty_list(yylineno); +break; +case 66: + this.$ = Nodes.array_literal($$[$0-1], yylineno); +break; +case 67: + this.$ = Nodes.object_literal($$[$0-1], yylineno); +break; +case 68: + this.$ = Nodes.object_literal([], yylineno); +break; +case 69: case 71: case 76: case 80: + this.$ = Nodes.pair($$[$0-2], $$[$0]); +break; +case 70: case 77: case 81: + this.$ = Nodes.pair($$[$0], []); +break; +case 72: case 73: + this.$ = Nodes.function_definition('lambda', $$[$0-2], $$[$0], _$[$0-4], _$[$0]); +break; +case 74: case 78: + this.$ = $$[$0]; +break; +} +}, +table: [{3:1,4:2,5:[2,6],6:3,7:4,8:[1,6],10:5,11:7,12:8,13:9,14:10,15:11,16:$V0,17:12,18:13,19:14,20:$V1,21:$V2,24:$V3,25:$V4,26:26,28:$V5,29:$V6,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{1:[3]},{5:[1,39]},{5:[1,40]},o($Vj,$Vk,{5:[1,41]}),{5:[2,7]},{7:48,8:$Vl,9:$Vm,10:42,11:7,12:8,13:9,14:10,15:11,16:$V0,17:12,18:13,19:14,20:$V1,21:$V2,24:$V3,25:$V4,26:46,28:$V5,29:$V6,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,62:44,63:45,67:$Vi},o($Vn,[2,9],{11:7,12:8,13:9,14:10,15:11,17:12,18:13,19:14,48:25,26:26,50:27,51:28,53:30,7:48,10:49,8:$Vl,16:$V0,20:$V1,21:$V2,24:$V3,25:$V4,28:$V5,29:$V6,31:$V7,32:$V8,36:$V9,45:$Va,52:$Vb,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi}),o($Vo,[2,10]),o($Vo,[2,11]),o($Vo,[2,12]),{16:[1,50]},{16:[1,51]},{16:[1,52]},{16:[1,53],30:[1,54],31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE},o($Vo,[2,17]),{21:[1,71]},{21:[1,72]},{21:$VF,26:73,67:$Vi},{7:48,8:$Vl,19:75,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{26:77,67:$Vi},{7:48,8:$Vl,19:78,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:79,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:80,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:81,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},o($VH,[2,50]),o($VH,$VI,{21:$VJ}),o($VH,[2,53]),o($VH,[2,54]),{26:83,67:$Vi},o($VH,[2,58]),o($VH,[2,60]),o($VH,[2,61]),o($VH,[2,62]),o($VH,[2,63]),o($VH,[2,64]),o($VH,[2,65]),o([9,16,21,22,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,46,47,54,55,64],[2,82]),{7:48,8:$Vl,19:86,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,46:$VK,48:25,49:84,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,65:85,67:$Vi},{1:[2,1]},{1:[2,2]},{1:[2,3]},{9:[1,87]},o($VL,[2,4]),{9:[1,88]},{9:[2,70],64:[1,89]},o($Vj,$VI,{21:$VJ,55:$VM}),{9:$Vm,26:91,62:44,63:45,67:$Vi},o($VH,$Vk),o($Vn,[2,8]),o($Vo,[2,13]),o($Vo,[2,14]),o($Vo,[2,15]),o($Vo,[2,16]),{7:48,8:$Vl,19:92,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:93,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:94,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:95,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:96,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:97,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:98,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:99,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:100,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:101,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:102,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:103,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:104,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:105,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:106,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{26:107,67:$Vi},{7:48,8:$Vl,19:108,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:109,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{7:48,8:$Vl,19:110,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{21:[1,111]},{22:$VN,26:114,27:112,66:113,67:$Vi},{16:[2,28],31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE},{21:$VF},{30:[1,115]},o($VO,[2,36],{45:$VC,47:$VD}),o($VO,[2,37],{45:$VC,47:$VD}),o($VO,[2,38],{45:$VC,47:$VD}),{22:[1,116],31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE},{7:48,8:$Vl,19:86,21:$V2,22:$VK,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,49:117,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,65:85,67:$Vi},{21:[1,118]},{46:[1,119]},o($VP,[2,74]),o($VP,[2,77],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE,64:[1,120]}),o($VL,[2,5]),o($VH,[2,67]),{26:91,62:121,63:45,67:$Vi},{7:48,8:$Vl,19:122,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{55:$VM},{16:[2,30],31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE},o($VQ,[2,31],{33:$Vr,34:$Vs,35:$Vt,45:$VC,47:$VD}),o($VQ,[2,32],{33:$Vr,34:$Vs,35:$Vt,45:$VC,47:$VD}),o($VO,[2,33],{45:$VC,47:$VD}),o($VO,[2,34],{45:$VC,47:$VD}),o($VO,[2,35],{45:$VC,47:$VD}),o([9,16,22,30,37,38,46,54,55,64],[2,39],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD}),o([9,16,22,30,38,46,54,55,64],[2,40],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD}),o($VR,[2,41],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD}),o($VR,[2,42],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD}),o($VS,[2,43],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,45:$VC,47:$VD}),o($VS,[2,44],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,45:$VC,47:$VD}),o($VS,[2,45],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,45:$VC,47:$VD}),o($VS,[2,46],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,45:$VC,47:$VD}),{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,46:[1,123],47:$VD,54:$VE},o($VH,[2,48],{21:[1,124]}),{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE,55:[1,125]},{22:[1,126],31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE},{22:[1,127],31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE},{22:$VN,26:114,27:128,66:113,67:$Vi},{22:[1,129]},{22:[2,78]},{22:[2,81],64:[1,130]},{7:48,8:$Vl,19:131,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},o($VH,[2,49],{21:[1,132]}),{22:[1,133]},{7:48,8:$Vl,19:86,21:$V2,22:$VK,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,49:134,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,65:85,67:$Vi},o($VH,[2,66]),{7:48,8:$Vl,19:86,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,65:135,67:$Vi},{9:[2,69]},o([9,64],[2,71],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE}),o($VH,[2,47]),{7:48,8:$Vl,19:86,21:$V2,22:$VK,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,49:136,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,65:85,67:$Vi},{7:48,8:$Vl,19:137,21:$V2,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},{6:138,7:139,8:$VT},{6:141,7:142,8:$VT},{22:[1,143]},{6:144,7:145,8:$VT},{26:114,66:146,67:$Vi},{16:[2,29],31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE},{7:48,8:$Vl,19:86,21:$V2,22:$VK,25:$VG,26:26,31:$V7,32:$V8,36:$V9,45:$Va,48:25,49:147,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,65:85,67:$Vi},o($VH,[2,55]),{22:[1,148]},o($VP,[2,76]),{22:[1,149]},o([9,16,22,30,46,55,64],[2,59],{31:$Vp,32:$Vq,33:$Vr,34:$Vs,35:$Vt,37:$Vu,38:$Vv,39:$Vw,40:$Vx,41:$Vy,42:$Vz,43:$VA,44:$VB,45:$VC,47:$VD,54:$VE}),{23:[1,150]},{23:[1,151]},{7:48,8:$Vl,9:$Vm,10:42,11:7,12:8,13:9,14:10,15:11,16:$V0,17:12,18:13,19:14,20:$V1,21:$V2,24:$V3,25:$V4,26:26,28:$V5,29:$V6,31:$V7,32:$V8,36:$V9,45:$Va,48:25,50:27,51:28,52:$Vb,53:30,56:$Vc,57:$Vd,58:$Ve,59:$Vf,60:$Vg,61:$Vh,67:$Vi},o($Vo,[2,24]),o($Vo,[2,25]),{6:152,7:153,8:$VT},o($VH,[2,72]),o($VH,[2,73]),{22:[2,80]},{22:[1,154]},o($VH,[2,57]),o($VH,[2,56]),{6:155,7:156,8:$VT,12:157,20:$V1},{6:158,7:159,8:$VT,12:160,20:$V1},o($Vo,[2,26]),o($Vo,[2,27]),o($VH,[2,52]),o($Vo,[2,18]),o($Vo,[2,19]),o($Vo,[2,22]),o($Vo,[2,20]),o($Vo,[2,21]),o($Vo,[2,23])], +defaultActions: {5:[2,7],39:[2,1],40:[2,2],41:[2,3],113:[2,78],121:[2,69],146:[2,80]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + function _parseError (msg, hash) { + this.message = msg; + this.hash = hash; + } + _parseError.prototype = new Error(); + + throw new _parseError(str, hash); + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + _token_stack: + function lex() { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; + +/* lib/parser/includes/nodes.js*/ +var Nodes = require('./nodes'); +; + +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:/* skip single-line comments */ +break; +case 1:/* skip multi-line comments */ +break; +case 2:/* skip whitespace */ +break; +case 3:return 25 +break; +case 4:return 'INVALID' +break; +case 5:return 28 +break; +case 6:return 20 +break; +case 7:return 23 +break; +case 8:return 24 +break; +case 9:return 'for' +break; +case 10:return 'case' +break; +case 11:return 'default' +break; +case 12:return 52 +break; +case 13:return 'break' +break; +case 14:return 'continue' +break; +case 15:return 29 +break; +case 16:return 39 +break; +case 17:return 30 +break; +case 18:return 8 +break; +case 19:return 9 +break; +case 20:return 16 +break; +case 21:return 64 +break; +case 22:return 59 +break; +case 23:return 60 +break; +case 24:return 61 +break; +case 25:return 45 +break; +case 26:return 46 +break; +case 27:return 47 +break; +case 28: this.begin('DoubleQuotedString'); this.string = ''; +break; +case 29: this.begin('SingleQuotedString'); this.string = ''; +break; +case 30:this.begin('QuotedStringEscape'); +break; +case 31: yy_.yytext = this.string; this.string = undefined; this.popState(); return 56; +break; +case 32: yy_.yytext = this.string; this.string = undefined; this.popState(); return 56; +break; +case 33: /* The newlines are there because we can span strings across lines using \ */ + switch (yy_.yytext) { + case '\r\n': + case '\n': break; + case 'b': this.string += '\b'; break; + case 'n': this.string += '\n'; break; + case 'r': this.string += '\r'; break; + case 't': this.string += '\t'; break; + case "'": this.string += "'"; break; + case '"': this.string += '"'; break; + case '\\': this.string += '\\'; break; + default: this.string += '\\' + $1; break; + } + + this.popState(); + +break; +case 34:this.string += yy_.yytext; +break; +case 35:this.string += yy_.yytext; +break; +case 36:return 67 /* TODO: non-ASCII identifiers */ +break; +case 37:return 57 /* 3.1, 3.1e-7 */ +break; +case 38:return 58 +break; +case 39:return 31 +break; +case 40:return 32 +break; +case 41:return 33 +break; +case 42:return 34 +break; +case 43:return 35 +break; +case 44:return 40 +break; +case 45:return 44 +break; +case 46:return 43 +break; +case 47:return 42 +break; +case 48:return 41 +break; +case 49:return 36 +break; +case 50:return 37 +break; +case 51:return 38 +break; +case 52:return 21 +break; +case 53:return 22 +break; +case 54:return 54 +break; +case 55:return 55 +break; +case 56:return 5 +break; +case 57:return 'INVALID' +break; +} +}, +rules: [/^(?:\/\/([^\n\r]*))/,/^(?:\/\*([\u0000-\uffff]*?)\*\/)/,/^(?:\s+)/,/^(?:function\b)/,/^(?:return\s*\n)/,/^(?:return\b)/,/^(?:if\b)/,/^(?:else\b)/,/^(?:while\b)/,/^(?:for\b)/,/^(?:case\b)/,/^(?:default\b)/,/^(?:new\b)/,/^(?:break\b)/,/^(?:continue\b)/,/^(?:var\b)/,/^(?:===)/,/^(?:=)/,/^(?:\{)/,/^(?:\})/,/^(?:;)/,/^(?:,)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:\[\])/,/^(?:\[)/,/^(?:\])/,/^(?:\.)/,/^(?:")/,/^(?:')/,/^(?:\\)/,/^(?:")/,/^(?:')/,/^(?:(.|\r\n|\n))/,/^(?:[^"\\]*)/,/^(?:[^'\\]*)/,/^(?:[A-Za-z_][A-Za-z0-9_]*)/,/^(?:[0-9]+(\.[0-9]+)?([eE][\-+]?[0-9]+)?\b)/,/^(?:[0-9]+\b)/,/^(?:\+)/,/^(?:-)/,/^(?:\*)/,/^(?:\/)/,/^(?:%)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:<)/,/^(?:>)/,/^(?:!)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\()/,/^(?:\))/,/^(?:\?)/,/^(?::)/,/^(?:$)/,/^(?:.)/], +conditions: {"QuotedStringEscape":{"rules":[33],"inclusive":false},"SingleQuotedString":{"rules":[30,32,35],"inclusive":false},"DoubleQuotedString":{"rules":[30,31,34],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer;parser.lexer.options.ranges = true; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); + + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = parserWeek10; +exports.Parser = parserWeek10.Parser; +exports.parse = function () { return parserWeek10.parse.apply(parserWeek10, arguments); }; +exports.main = function commonjsMain(args) { + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); +}; +if (typeof module !== 'undefined' && require.main === module) { + exports.main(process.argv.slice(1)); +} +} \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-10.js.patch b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-10.js.patch new file mode 100644 index 000000000..1e1d5828a --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-10.js.patch @@ -0,0 +1,11 @@ +--- parser-week-10 copy.js 2015-09-17 19:42:23.000000000 +0800 ++++ parser-week-10.js 2015-09-17 19:45:31.000000000 +0800 +@@ -378,7 +378,7 @@ + }}; + + /* lib/parser/includes/nodes.js*/ +-var Nodes = require('lib/parser/nodes'); ++var Nodes = require('./nodes'); + ; + + /* generated by jison-lex 0.3.4 */ diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-13.js b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-13.js new file mode 100644 index 000000000..de8d309af --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-13.js @@ -0,0 +1,883 @@ +/* parser generated by jison 0.4.15 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +var parserWeek13 = (function(){ +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,18],$V1=[1,19],$V2=[1,30],$V3=[1,20],$V4=[1,21],$V5=[1,22],$V6=[1,23],$V7=[1,24],$V8=[1,25],$V9=[1,26],$Va=[1,28],$Vb=[1,27],$Vc=[1,29],$Vd=[1,44],$Ve=[1,35],$Vf=[1,37],$Vg=[1,38],$Vh=[1,39],$Vi=[1,40],$Vj=[1,41],$Vk=[1,42],$Vl=[1,43],$Vm=[16,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,55,62],$Vn=[2,82],$Vo=[1,53],$Vp=[1,49],$Vq=[5,9],$Vr=[5,8,9,16,23,24,27,28,31,32,33,36,37,39,40,44,53,60,64,65,66,67,68,69,75],$Vs=[1,62],$Vt=[1,63],$Vu=[1,64],$Vv=[1,65],$Vw=[1,66],$Vx=[1,67],$Vy=[1,68],$Vz=[1,69],$VA=[1,70],$VB=[1,71],$VC=[1,72],$VD=[1,73],$VE=[1,74],$VF=[1,75],$VG=[1,76],$VH=[1,77],$VI=[1,78],$VJ=[1,83],$VK=[1,85],$VL=[9,16,25,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,62,63,72],$VM=[2,65],$VN=[1,91],$VO=[2,89],$VP=[5,8,9,16,23,24,25,26,27,28,31,32,33,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,60,62,63,64,65,66,67,68,69,72,75],$VQ=[1,99],$VR=[2,93],$VS=[9,16,25,38,39,40,41,42,43,45,46,47,48,49,50,51,52,54,62,63,72],$VT=[25,54],$VU=[9,16,25,38,39,40,45,46,47,48,49,50,51,52,54,62,63,72],$VV=[9,16,25,38,45,46,47,48,54,62,63,72],$VW=[9,16,25,38,45,46,47,48,49,50,51,52,54,62,63,72],$VX=[1,154]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"program":3,"statements":4,"EOF":5,"statement_block":6,"empty_block":7,"{":8,"}":9,"non_empty_statements":10,"statement":11,"if_statement":12,"while_statement":13,"for_statement":14,"break_statement":15,";":16,"continue_statement":17,"function_definition":18,"return_statement":19,"variable_definition":20,"assignment_statement":21,"expression":22,"if":23,"(":24,")":25,"else":26,"while":27,"for":28,"for_initialiser":29,"for_finaliser":30,"break":31,"continue":32,"function":33,"identifier":34,"identifiers":35,"return":36,"var":37,"=":38,"+":39,"-":40,"*":41,"/":42,"%":43,"!":44,"&&":45,"||":46,"===":47,"!==":48,">":49,"<":50,">=":51,"<=":52,"[":53,"]":54,".":55,"constants":56,"expressions":57,"array_literal":58,"object_literal":59,"new":60,"function_expression":61,"?":62,":":63,"STRING":64,"FLOAT_NUMBER":65,"INT_NUMBER":66,"true":67,"false":68,"empty_list":69,"non_empty_object_literal_statements":70,"object_literal_statement":71,",":72,"non_empty_expressions":73,"non_empty_identifiers":74,"Identifier":75,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",8:"{",9:"}",16:";",23:"if",24:"(",25:")",26:"else",27:"while",28:"for",31:"break",32:"continue",33:"function",36:"return",37:"var",38:"=",39:"+",40:"-",41:"*",42:"/",43:"%",44:"!",45:"&&",46:"||",47:"===",48:"!==",49:">",50:"<",51:">=",52:"<=",53:"[",54:"]",55:".",60:"new",62:"?",63:":",64:"STRING",65:"FLOAT_NUMBER",66:"INT_NUMBER",67:"true",68:"false",69:"empty_list",72:",",75:"Identifier"}, +productions_: [0,[3,2],[3,2],[3,2],[7,2],[6,3],[4,0],[4,1],[10,2],[10,1],[11,1],[11,1],[11,1],[11,2],[11,2],[11,1],[11,2],[11,2],[11,2],[11,2],[11,1],[12,7],[12,7],[12,7],[12,7],[12,7],[12,7],[13,5],[13,5],[14,9],[14,9],[29,1],[29,1],[29,1],[29,0],[30,1],[30,1],[30,0],[15,1],[17,1],[18,6],[18,6],[19,2],[20,4],[21,3],[22,3],[22,3],[22,3],[22,3],[22,3],[22,2],[22,2],[22,2],[22,3],[22,3],[22,3],[22,3],[22,3],[22,3],[22,3],[22,3],[22,4],[22,3],[22,3],[22,1],[22,1],[22,6],[22,1],[22,1],[22,4],[22,6],[22,5],[22,1],[22,5],[56,1],[56,1],[56,1],[56,1],[56,1],[56,1],[58,3],[59,3],[59,1],[70,3],[70,1],[71,3],[61,5],[61,5],[57,1],[57,0],[73,3],[73,1],[35,1],[35,0],[74,3],[74,1],[34,1]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: case 2: case 3: + return $$[$0-1]; +break; +case 4: + this.$ = [] +break; +case 5: case 63: + this.$ = $$[$0-1]; +break; +case 6: case 89: case 93: + this.$ = []; +break; +case 8: + + if ($$[$0-1] === Nodes.no_op()) { + this.$ = $$[$0]; + } else { + this.$ = Nodes.pair($$[$0-1], $$[$0]); + } + +break; +case 9: + + if ($$[$0] === Nodes.no_op()) { + this.$ = []; + } else { + this.$ = Nodes.pair($$[$0], []); + } + +break; +case 20: + this.$ = Nodes.no_op(); +break; +case 21: case 22: case 23: case 24: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 25: case 26: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], Nodes.pair($$[$0], []), yylineno); +break; +case 27: case 28: + this.$ = Nodes.while_statement($$[$0-2], $$[$0], yylineno) +break; +case 29: case 30: + this.$ = Nodes.for_statement($$[$0-6], $$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 38: + this.$ = Nodes.break_statement(yylineno); +break; +case 39: + this.$ = Nodes.continue_statement(yylineno); +break; +case 40: case 41: + this.$ = Nodes.variable_definition($$[$0-4], Nodes.function_definition($$[$0-4], $$[$0-2], $$[$0], _$[$0-5], _$[$0]), yylineno); +break; +case 42: + this.$ = Nodes.return_statement($$[$0], yylineno); +break; +case 43: + this.$ = Nodes.variable_definition($$[$0-2], $$[$0], yylineno); +break; +case 44: + + if ($$[$0-2].tag === 'variable') { + this.$ = Nodes.assignment($$[$0-2], $$[$0], yylineno); + + } else if ($$[$0-2].tag === 'property_access') { + this.$ = Nodes.property_assignment($$[$0-2].object, $$[$0-2].property, $$[$0], yylineno); + + } else { + error('parse error in line ' + yylineno + ": " + yytext); + } + +break; +case 45: case 46: case 47: case 48: case 49: case 55: case 56: case 57: case 58: case 59: case 60: + this.$ = Nodes.eager_binary_expression($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 50: case 51: + this.$ = Nodes.eager_binary_expression(0, $$[$0-1], $$[$0], yylineno); +break; +case 52: + this.$ = Nodes.eager_unary_expression($$[$0-1], $$[$0], yylineno); +break; +case 53: case 54: + this.$ = Nodes.boolean_operation($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 61: + this.$ = Nodes.property_access($$[$0-3], $$[$0-1], yylineno); +break; +case 62: + this.$ = Nodes.property_access($$[$0-2], $$[$0], yylineno); +break; +case 65: + this.$ = Nodes.variable($$[$0], yylineno); +break; +case 66: + this.$ = Nodes.application($$[$0-4], $$[$0-1], yylineno); +break; +case 69: + this.$ = Nodes.application(Nodes.variable($$[$0-3], yylineno), $$[$0-1], yylineno); +break; +case 70: + this.$ = Nodes.object_method_application($$[$0-5], $$[$0-3], $$[$0-1], yylineno); +break; +case 71: + this.$ = Nodes.construction($$[$0-3], $$[$0-1], yylineno); +break; +case 73: + this.$ = Nodes.ternary($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 74: case 96: + this.$ = yytext; +break; +case 75: + this.$ = parseFloat(yytext); +break; +case 76: + this.$ = parseInt(yytext, 10); +break; +case 77: + this.$ = true; +break; +case 78: + this.$ = false; +break; +case 79: + this.$ = Nodes.empty_list(yylineno); +break; +case 80: + this.$ = Nodes.array_literal($$[$0-1], yylineno); +break; +case 81: + this.$ = Nodes.object_literal($$[$0-1], yylineno); +break; +case 82: + this.$ = Nodes.object_literal([], yylineno); +break; +case 83: case 85: case 90: case 94: + this.$ = Nodes.pair($$[$0-2], $$[$0]); +break; +case 84: case 91: case 95: + this.$ = Nodes.pair($$[$0], []); +break; +case 86: case 87: + this.$ = Nodes.function_definition('lambda', $$[$0-2], $$[$0], _$[$0-4], _$[$0]); +break; +case 88: case 92: + this.$ = $$[$0]; +break; +} +}, +table: [{3:1,4:2,5:[2,6],6:3,7:4,8:[1,6],10:5,11:7,12:8,13:9,14:10,15:11,16:$V0,17:12,18:13,19:14,20:15,21:16,22:17,23:$V1,24:$V2,27:$V3,28:$V4,31:$V5,32:$V6,33:$V7,34:32,36:$V8,37:$V9,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{1:[3]},{5:[1,45]},{5:[1,46]},o($Vm,$Vn,{5:[1,47]}),{5:[2,7]},{7:54,8:$Vo,9:$Vp,10:48,11:7,12:8,13:9,14:10,15:11,16:$V0,17:12,18:13,19:14,20:15,21:16,22:17,23:$V1,24:$V2,27:$V3,28:$V4,31:$V5,32:$V6,33:$V7,34:52,36:$V8,37:$V9,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,70:50,71:51,75:$Vl},o($Vq,[2,9],{11:7,12:8,13:9,14:10,15:11,17:12,18:13,19:14,20:15,21:16,22:17,56:31,34:32,58:33,59:34,61:36,7:54,10:55,8:$Vo,16:$V0,23:$V1,24:$V2,27:$V3,28:$V4,31:$V5,32:$V6,33:$V7,36:$V8,37:$V9,39:$Va,40:$Vb,44:$Vc,53:$Vd,60:$Ve,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl}),o($Vr,[2,10]),o($Vr,[2,11]),o($Vr,[2,12]),{16:[1,56]},{16:[1,57]},o($Vr,[2,15]),{16:[1,58]},{16:[1,59]},{16:[1,60]},{16:[1,61],38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI},o($Vr,[2,20]),{24:[1,79]},{24:[1,80]},{24:[1,81]},{16:[2,38]},{16:[2,39]},{24:$VJ,34:82,75:$Vl},{7:54,8:$Vo,22:84,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{34:86,75:$Vl},{7:54,8:$Vo,22:87,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:88,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:89,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:90,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},o($VL,[2,64]),o($VL,$VM,{24:$VN}),o($VL,[2,67]),o($VL,[2,68]),{34:92,75:$Vl},o($VL,[2,72]),o($VL,[2,74]),o($VL,[2,75]),o($VL,[2,76]),o($VL,[2,77]),o($VL,[2,78]),o($VL,[2,79]),o([9,16,24,25,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,62,63,72],[2,96]),{7:54,8:$Vo,22:95,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,54:$VO,56:31,57:93,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,73:94,75:$Vl},{1:[2,1]},{1:[2,2]},{1:[2,3]},{9:[1,96]},o($VP,[2,4]),{9:[1,97]},{9:[2,84],72:[1,98]},o($Vm,$VM,{24:$VN,63:$VQ}),{9:$Vp,34:100,70:50,71:51,75:$Vl},o($VL,$Vn),o($Vq,[2,8]),o($Vr,[2,13]),o($Vr,[2,14]),o($Vr,[2,16]),o($Vr,[2,17]),o($Vr,[2,18]),o($Vr,[2,19]),{7:54,8:$Vo,22:101,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:102,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:103,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:104,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:105,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:106,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:107,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:108,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:109,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:110,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:111,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:112,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:113,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:114,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:115,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{34:116,75:$Vl},{7:54,8:$Vo,22:117,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:118,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,22:119,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{7:54,8:$Vo,16:[2,34],20:122,21:123,22:121,24:$V2,29:120,33:$VK,34:32,37:$V9,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{24:[1,124]},{25:$VR,34:127,35:125,74:126,75:$Vl},{16:[2,42],39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI},{24:$VJ},{38:[1,128]},o($VS,[2,50],{53:$VG,55:$VH}),o($VS,[2,51],{53:$VG,55:$VH}),o($VS,[2,52],{53:$VG,55:$VH}),{25:[1,129],39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI},{7:54,8:$Vo,22:95,24:$V2,25:$VO,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,57:130,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,73:94,75:$Vl},{24:[1,131]},{54:[1,132]},o($VT,[2,88]),o($VT,[2,91],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI,72:[1,133]}),o($VP,[2,5]),o($VL,[2,81]),{34:100,70:134,71:51,75:$Vl},{7:54,8:$Vo,22:135,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{63:$VQ},o([16,25],[2,44],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI}),o($VU,[2,45],{41:$Vv,42:$Vw,43:$Vx,53:$VG,55:$VH}),o($VU,[2,46],{41:$Vv,42:$Vw,43:$Vx,53:$VG,55:$VH}),o($VS,[2,47],{53:$VG,55:$VH}),o($VS,[2,48],{53:$VG,55:$VH}),o($VS,[2,49],{53:$VG,55:$VH}),o([9,16,25,38,45,46,54,62,63,72],[2,53],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH}),o([9,16,25,38,46,54,62,63,72],[2,54],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH}),o($VV,[2,55],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH}),o($VV,[2,56],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH}),o($VW,[2,57],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,53:$VG,55:$VH}),o($VW,[2,58],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,53:$VG,55:$VH}),o($VW,[2,59],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,53:$VG,55:$VH}),o($VW,[2,60],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,53:$VG,55:$VH}),{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,54:[1,136],55:$VH,62:$VI},o($VL,[2,62],{24:[1,137]}),{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI,63:[1,138]},{25:[1,139],39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI},{25:[1,140],39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI},{16:[1,141]},{16:[2,31],38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI},{16:[2,32]},{16:[2,33]},{25:$VR,34:127,35:142,74:126,75:$Vl},{25:[1,143]},{25:[2,92]},{25:[2,95],72:[1,144]},{7:54,8:$Vo,22:145,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},o($VL,[2,63],{24:[1,146]}),{25:[1,147]},{7:54,8:$Vo,22:95,24:$V2,25:$VO,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,57:148,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,73:94,75:$Vl},o($VL,[2,80]),{7:54,8:$Vo,22:95,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,73:149,75:$Vl},{9:[2,83]},o([9,72],[2,85],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI}),o($VL,[2,61]),{7:54,8:$Vo,22:95,24:$V2,25:$VO,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,57:150,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,73:94,75:$Vl},{7:54,8:$Vo,22:151,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{6:152,7:153,8:$VX},{6:155,7:156,8:$VX},{7:54,8:$Vo,22:157,24:$V2,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},{25:[1,158]},{6:159,7:160,8:$VX},{34:127,74:161,75:$Vl},{16:[2,43],39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI},{7:54,8:$Vo,22:95,24:$V2,25:$VO,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,57:162,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,73:94,75:$Vl},o($VL,[2,69]),{25:[1,163]},o($VT,[2,90]),{25:[1,164]},o([9,16,25,38,54,63,72],[2,73],{39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI}),{26:[1,165]},{26:[1,166]},{7:54,8:$Vo,9:$Vp,10:48,11:7,12:8,13:9,14:10,15:11,16:$V0,17:12,18:13,19:14,20:15,21:16,22:17,23:$V1,24:$V2,27:$V3,28:$V4,31:$V5,32:$V6,33:$V7,34:32,36:$V8,37:$V9,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},o($Vr,[2,27]),o($Vr,[2,28]),{16:[1,167],39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI},{6:168,7:169,8:$VX},o($VL,[2,86]),o($VL,[2,87]),{25:[2,94]},{25:[1,170]},o($VL,[2,71]),o($VL,[2,70]),{6:171,7:172,8:$VX,12:173,23:$V1},{6:174,7:175,8:$VX,12:176,23:$V1},{7:54,8:$Vo,21:178,22:179,24:$V2,25:[2,37],30:177,33:$VK,34:32,39:$Va,40:$Vb,44:$Vc,53:$Vd,56:31,58:33,59:34,60:$Ve,61:36,64:$Vf,65:$Vg,66:$Vh,67:$Vi,68:$Vj,69:$Vk,75:$Vl},o($Vr,[2,40]),o($Vr,[2,41]),o($VL,[2,66]),o($Vr,[2,21]),o($Vr,[2,22]),o($Vr,[2,25]),o($Vr,[2,23]),o($Vr,[2,24]),o($Vr,[2,26]),{25:[1,180]},{25:[2,35]},{25:[2,36],38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,43:$Vx,45:$Vy,46:$Vz,47:$VA,48:$VB,49:$VC,50:$VD,51:$VE,52:$VF,53:$VG,55:$VH,62:$VI},{6:181,7:182,8:$VX},o($Vr,[2,29]),o($Vr,[2,30])], +defaultActions: {5:[2,7],22:[2,38],23:[2,39],45:[2,1],46:[2,2],47:[2,3],122:[2,32],123:[2,33],126:[2,92],134:[2,83],161:[2,94],178:[2,35]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + function _parseError (msg, hash) { + this.message = msg; + this.hash = hash; + } + _parseError.prototype = new Error(); + + throw new _parseError(str, hash); + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + _token_stack: + function lex() { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; + +/* lib/parser/includes/nodes.js*/ +var Nodes = require('./nodes'); +; + +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:/* skip single-line comments */ +break; +case 1:/* skip multi-line comments */ +break; +case 2:/* skip whitespace */ +break; +case 3:return 33 +break; +case 4:return 'INVALID' +break; +case 5:return 36 +break; +case 6:return 23 +break; +case 7:return 26 +break; +case 8:return 27 +break; +case 9:return 28 +break; +case 10:return 'case' +break; +case 11:return 'default' +break; +case 12:return 60 +break; +case 13:return 31 +break; +case 14:return 32 +break; +case 15:return 37 +break; +case 16:return 47 +break; +case 17:return 38 +break; +case 18:return 8 +break; +case 19:return 9 +break; +case 20:return 16 +break; +case 21:return 72 +break; +case 22:return 67 +break; +case 23:return 68 +break; +case 24:return 69 +break; +case 25:return 53 +break; +case 26:return 54 +break; +case 27:return 55 +break; +case 28: this.begin('DoubleQuotedString'); this.string = ''; +break; +case 29: this.begin('SingleQuotedString'); this.string = ''; +break; +case 30:this.begin('QuotedStringEscape'); +break; +case 31: yy_.yytext = this.string; this.string = undefined; this.popState(); return 64; +break; +case 32: yy_.yytext = this.string; this.string = undefined; this.popState(); return 64; +break; +case 33: /* The newlines are there because we can span strings across lines using \ */ + switch (yy_.yytext) { + case '\r\n': + case '\n': break; + case 'b': this.string += '\b'; break; + case 'n': this.string += '\n'; break; + case 'r': this.string += '\r'; break; + case 't': this.string += '\t'; break; + case "'": this.string += "'"; break; + case '"': this.string += '"'; break; + case '\\': this.string += '\\'; break; + default: this.string += '\\' + $1; break; + } + + this.popState(); + +break; +case 34:this.string += yy_.yytext; +break; +case 35:this.string += yy_.yytext; +break; +case 36:return 75 /* TODO: non-ASCII identifiers */ +break; +case 37:return 65 /* 3.1, 3.1e-7 */ +break; +case 38:return 66 +break; +case 39:return 39 +break; +case 40:return 40 +break; +case 41:return 41 +break; +case 42:return 42 +break; +case 43:return 43 +break; +case 44:return 48 +break; +case 45:return 52 +break; +case 46:return 51 +break; +case 47:return 50 +break; +case 48:return 49 +break; +case 49:return 44 +break; +case 50:return 45 +break; +case 51:return 46 +break; +case 52:return 24 +break; +case 53:return 25 +break; +case 54:return 62 +break; +case 55:return 63 +break; +case 56:return 5 +break; +case 57:return 'INVALID' +break; +} +}, +rules: [/^(?:\/\/([^\n\r]*))/,/^(?:\/\*([\u0000-\uffff]*?)\*\/)/,/^(?:\s+)/,/^(?:function\b)/,/^(?:return\s*\n)/,/^(?:return\b)/,/^(?:if\b)/,/^(?:else\b)/,/^(?:while\b)/,/^(?:for\b)/,/^(?:case\b)/,/^(?:default\b)/,/^(?:new\b)/,/^(?:break\b)/,/^(?:continue\b)/,/^(?:var\b)/,/^(?:===)/,/^(?:=)/,/^(?:\{)/,/^(?:\})/,/^(?:;)/,/^(?:,)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:\[\])/,/^(?:\[)/,/^(?:\])/,/^(?:\.)/,/^(?:")/,/^(?:')/,/^(?:\\)/,/^(?:")/,/^(?:')/,/^(?:(.|\r\n|\n))/,/^(?:[^"\\]*)/,/^(?:[^'\\]*)/,/^(?:[A-Za-z_][A-Za-z0-9_]*)/,/^(?:[0-9]+(\.[0-9]+)?([eE][\-+]?[0-9]+)?\b)/,/^(?:[0-9]+\b)/,/^(?:\+)/,/^(?:-)/,/^(?:\*)/,/^(?:\/)/,/^(?:%)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:<)/,/^(?:>)/,/^(?:!)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\()/,/^(?:\))/,/^(?:\?)/,/^(?::)/,/^(?:$)/,/^(?:.)/], +conditions: {"QuotedStringEscape":{"rules":[33],"inclusive":false},"SingleQuotedString":{"rules":[30,32,35],"inclusive":false},"DoubleQuotedString":{"rules":[30,31,34],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer;parser.lexer.options.ranges = true; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); + + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = parserWeek13; +exports.Parser = parserWeek13.Parser; +exports.parse = function () { return parserWeek13.parse.apply(parserWeek13, arguments); }; +exports.main = function commonjsMain(args) { + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); +}; +if (typeof module !== 'undefined' && require.main === module) { + exports.main(process.argv.slice(1)); +} +} \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-13.js.patch b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-13.js.patch new file mode 100644 index 000000000..0a3dacc15 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-13.js.patch @@ -0,0 +1,11 @@ +--- parser-week-13 copy.js 2015-09-17 19:42:19.000000000 +0800 ++++ parser-week-13.js 2015-09-17 19:45:22.000000000 +0800 +@@ -387,7 +387,7 @@ + }}; + + /* lib/parser/includes/nodes.js*/ +-var Nodes = require('lib/parser/nodes'); ++var Nodes = require('./nodes'); + ; + + /* generated by jison-lex 0.3.4 */ diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-3.js b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-3.js new file mode 100644 index 000000000..3cbd69dc8 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-3.js @@ -0,0 +1,843 @@ +/* parser generated by jison 0.4.15 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +var parserWeek3 = (function(){ +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,6],$V1=[1,13],$V2=[1,14],$V3=[1,21],$V4=[1,15],$V5=[1,16],$V6=[1,17],$V7=[1,19],$V8=[1,18],$V9=[1,20],$Va=[1,25],$Vb=[1,26],$Vc=[1,27],$Vd=[1,28],$Ve=[1,29],$Vf=[1,30],$Vg=[1,31],$Vh=[5,9],$Vi=[5,9,15,18,19,22,25,26,28,29,33,48,49,50,51,52,53,57],$Vj=[1,41],$Vk=[1,42],$Vl=[1,43],$Vm=[1,44],$Vn=[1,45],$Vo=[1,46],$Vp=[1,47],$Vq=[1,48],$Vr=[1,49],$Vs=[1,50],$Vt=[1,51],$Vu=[1,52],$Vv=[1,53],$Vw=[1,54],$Vx=[1,55],$Vy=[1,58],$Vz=[1,60],$VA=[15,20,28,29,30,31,32,34,35,36,37,38,39,40,41,42,46,47,55],$VB=[5,9,15,18,19,20,21,22,25,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,46,47,48,49,50,51,52,53,55,57],$VC=[2,64],$VD=[15,20,28,29,30,31,32,34,35,36,37,38,39,40,41,46,47,55],$VE=[2,60],$VF=[15,20,28,29,34,35,36,37,38,39,40,41,46,47,55],$VG=[15,20,34,35,36,37,46,47,55],$VH=[15,20,34,35,36,37,38,39,40,41,46,47,55]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"program":3,"statements":4,"EOF":5,"statement_block":6,"empty_block":7,"{":8,"}":9,"non_empty_statements":10,"statement":11,"if_statement":12,"function_definition":13,"return_statement":14,";":15,"variable_definition":16,"expression":17,"if":18,"(":19,")":20,"else":21,"function":22,"identifier":23,"identifiers":24,"return":25,"var":26,"=":27,"+":28,"-":29,"*":30,"/":31,"%":32,"!":33,"&&":34,"||":35,"===":36,"!==":37,">":38,"<":39,">=":40,"<=":41,".":42,"constants":43,"expressions":44,"function_expression":45,"?":46,":":47,"STRING":48,"FLOAT_NUMBER":49,"INT_NUMBER":50,"true":51,"false":52,"empty_list":53,"non_empty_expressions":54,",":55,"non_empty_identifiers":56,"Identifier":57,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",8:"{",9:"}",15:";",18:"if",19:"(",20:")",21:"else",22:"function",25:"return",26:"var",27:"=",28:"+",29:"-",30:"*",31:"/",32:"%",33:"!",34:"&&",35:"||",36:"===",37:"!==",38:">",39:"<",40:">=",41:"<=",42:".",46:"?",47:":",48:"STRING",49:"FLOAT_NUMBER",50:"INT_NUMBER",51:"true",52:"false",53:"empty_list",55:",",57:"Identifier"}, +productions_: [0,[3,2],[3,2],[3,2],[7,2],[6,3],[4,0],[4,1],[10,2],[10,1],[11,1],[11,1],[11,2],[11,2],[11,2],[11,1],[12,7],[12,7],[12,7],[12,7],[12,7],[12,7],[13,6],[13,6],[14,2],[16,4],[17,3],[17,3],[17,3],[17,3],[17,3],[17,2],[17,2],[17,2],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,1],[17,1],[17,6],[17,4],[17,6],[17,1],[17,5],[43,1],[43,1],[43,1],[43,1],[43,1],[43,1],[45,5],[45,5],[44,1],[44,0],[54,3],[54,1],[24,1],[24,0],[56,3],[56,1],[23,1]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: case 2: case 3: + return $$[$0-1]; +break; +case 4: + this.$ = [] +break; +case 5: case 43: + this.$ = $$[$0-1]; +break; +case 6: case 60: case 64: + this.$ = []; +break; +case 8: + + if ($$[$0-1] === Nodes.no_op()) { + this.$ = $$[$0]; + } else { + this.$ = Nodes.pair($$[$0-1], $$[$0]); + } + +break; +case 9: + + if ($$[$0] === Nodes.no_op()) { + this.$ = []; + } else { + this.$ = Nodes.pair($$[$0], []); + } + +break; +case 15: + this.$ = Nodes.no_op(); +break; +case 16: case 17: case 18: case 19: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 20: case 21: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], Nodes.pair($$[$0], []), yylineno); +break; +case 22: case 23: + this.$ = Nodes.variable_definition($$[$0-4], Nodes.function_definition($$[$0-4], $$[$0-2], $$[$0], _$[$0-5], _$[$0]), yylineno); +break; +case 24: + this.$ = Nodes.return_statement($$[$0], yylineno); +break; +case 25: + this.$ = Nodes.variable_definition($$[$0-2], $$[$0], yylineno); +break; +case 26: case 27: case 28: case 29: case 30: case 36: case 37: case 38: case 39: case 40: case 41: + this.$ = Nodes.eager_binary_expression($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 31: case 32: + this.$ = Nodes.eager_binary_expression(0, $$[$0-1], $$[$0], yylineno); +break; +case 33: + this.$ = Nodes.eager_unary_expression($$[$0-1], $$[$0], yylineno); +break; +case 34: case 35: + this.$ = Nodes.boolean_operation($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 42: + this.$ = Nodes.property_access($$[$0-2], $$[$0], yylineno); +break; +case 45: + this.$ = Nodes.variable($$[$0], yylineno); +break; +case 46: + this.$ = Nodes.application($$[$0-4], $$[$0-1], yylineno); +break; +case 47: + this.$ = Nodes.application(Nodes.variable($$[$0-3], yylineno), $$[$0-1], yylineno); +break; +case 48: + this.$ = Nodes.object_method_application($$[$0-5], $$[$0-3], $$[$0-1], yylineno); +break; +case 50: + this.$ = Nodes.ternary($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 51: case 67: + this.$ = yytext; +break; +case 52: + this.$ = parseFloat(yytext); +break; +case 53: + this.$ = parseInt(yytext, 10); +break; +case 54: + this.$ = true; +break; +case 55: + this.$ = false; +break; +case 56: + this.$ = Nodes.empty_list(yylineno); +break; +case 57: case 58: + this.$ = Nodes.function_definition('lambda', $$[$0-2], $$[$0], _$[$0-4], _$[$0]); +break; +case 59: case 63: + this.$ = $$[$0]; +break; +case 61: case 65: + this.$ = Nodes.pair($$[$0-2], $$[$0]); +break; +case 62: case 66: + this.$ = Nodes.pair($$[$0], []); +break; +} +}, +table: [{3:1,4:2,5:[2,6],6:3,7:4,8:$V0,10:5,11:7,12:8,13:9,14:10,15:$V1,16:11,17:12,18:$V2,19:$V3,22:$V4,23:23,25:$V5,26:$V6,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{1:[3]},{5:[1,32]},{5:[1,33]},{5:[1,34]},{5:[2,7]},{9:[1,36],10:35,11:7,12:8,13:9,14:10,15:$V1,16:11,17:12,18:$V2,19:$V3,22:$V4,23:23,25:$V5,26:$V6,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},o($Vh,[2,9],{11:7,12:8,13:9,14:10,16:11,17:12,43:22,23:23,45:24,10:37,15:$V1,18:$V2,19:$V3,22:$V4,25:$V5,26:$V6,28:$V7,29:$V8,33:$V9,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg}),o($Vi,[2,10]),o($Vi,[2,11]),{15:[1,38]},{15:[1,39]},{15:[1,40],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},o($Vi,[2,15]),{19:[1,56]},{19:$Vy,23:57,57:$Vg},{17:59,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{23:61,57:$Vg},{17:62,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:63,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:64,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:65,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},o($VA,[2,44]),o($VA,[2,45],{19:[1,66]}),o($VA,[2,49]),o($VA,[2,51]),o($VA,[2,52]),o($VA,[2,53]),o($VA,[2,54]),o($VA,[2,55]),o($VA,[2,56]),o([15,19,20,27,28,29,30,31,32,34,35,36,37,38,39,40,41,42,46,47,55],[2,67]),{1:[2,1]},{1:[2,2]},{1:[2,3]},{9:[1,67]},o($VB,[2,4]),o($Vh,[2,8]),o($Vi,[2,12]),o($Vi,[2,13]),o($Vi,[2,14]),{17:68,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:69,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:70,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:71,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:72,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:73,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:74,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:75,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:76,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:77,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:78,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:79,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:80,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{23:81,57:$Vg},{17:82,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:83,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{19:[1,84]},{20:$VC,23:87,24:85,56:86,57:$Vg},{15:[2,24],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{19:$Vy},{27:[1,88]},o($VD,[2,31],{42:$Vw}),o($VD,[2,32],{42:$Vw}),o($VD,[2,33],{42:$Vw}),{20:[1,89],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{17:92,19:$V3,20:$VE,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,44:90,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:91,57:$Vg},o($VB,[2,5]),o($VF,[2,26],{30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VF,[2,27],{30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VD,[2,28],{42:$Vw}),o($VD,[2,29],{42:$Vw}),o($VD,[2,30],{42:$Vw}),o([15,20,34,35,46,47,55],[2,34],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o([15,20,35,46,47,55],[2,35],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o($VG,[2,36],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o($VG,[2,37],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o($VH,[2,38],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VH,[2,39],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VH,[2,40],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VH,[2,41],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VA,[2,42],{19:[1,93]}),{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx,47:[1,94]},{20:[1,95],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{20:$VC,23:87,24:96,56:86,57:$Vg},{20:[1,97]},{20:[2,63]},{20:[2,66],55:[1,98]},{17:99,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},o($VA,[2,43],{19:[1,100]}),{20:[1,101]},{20:[2,59]},{20:[2,62],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx,55:[1,102]},{17:92,19:$V3,20:$VE,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,44:103,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:91,57:$Vg},{17:104,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{6:105,7:106,8:$V0},{20:[1,107]},{6:108,7:109,8:$V0},{23:87,56:110,57:$Vg},{15:[2,25],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{17:92,19:$V3,20:$VE,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,44:111,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:91,57:$Vg},o($VA,[2,47]),{17:92,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:112,57:$Vg},{20:[1,113]},o([15,20,47,55],[2,50],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx}),{21:[1,114]},{21:[1,115]},{6:116,7:117,8:$V0},o($VA,[2,57]),o($VA,[2,58]),{20:[2,65]},{20:[1,118]},{20:[2,61]},o($VA,[2,48]),{6:119,7:120,8:$V0,12:121,18:$V2},{6:122,7:123,8:$V0,12:124,18:$V2},o($Vi,[2,22]),o($Vi,[2,23]),o($VA,[2,46]),o($Vi,[2,16]),o($Vi,[2,17]),o($Vi,[2,20]),o($Vi,[2,18]),o($Vi,[2,19]),o($Vi,[2,21])], +defaultActions: {5:[2,7],32:[2,1],33:[2,2],34:[2,3],86:[2,63],91:[2,59],110:[2,65],112:[2,61]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + function _parseError (msg, hash) { + this.message = msg; + this.hash = hash; + } + _parseError.prototype = new Error(); + + throw new _parseError(str, hash); + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + _token_stack: + function lex() { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; + +/* lib/parser/includes/nodes.js*/ +var Nodes = require('./nodes'); +; + +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:/* skip single-line comments */ +break; +case 1:/* skip multi-line comments */ +break; +case 2:/* skip whitespace */ +break; +case 3:return 22 +break; +case 4:return 'INVALID' +break; +case 5:return 25 +break; +case 6:return 18 +break; +case 7:return 21 +break; +case 8:return 'while' +break; +case 9:return 'for' +break; +case 10:return 'case' +break; +case 11:return 'default' +break; +case 12:return 'new' +break; +case 13:return 'break' +break; +case 14:return 'continue' +break; +case 15:return 26 +break; +case 16:return 36 +break; +case 17:return 27 +break; +case 18:return 8 +break; +case 19:return 9 +break; +case 20:return 15 +break; +case 21:return 55 +break; +case 22:return 51 +break; +case 23:return 52 +break; +case 24:return 53 +break; +case 25:return '[' +break; +case 26:return ']' +break; +case 27:return 42 +break; +case 28: this.begin('DoubleQuotedString'); this.string = ''; +break; +case 29: this.begin('SingleQuotedString'); this.string = ''; +break; +case 30:this.begin('QuotedStringEscape'); +break; +case 31: yy_.yytext = this.string; this.string = undefined; this.popState(); return 48; +break; +case 32: yy_.yytext = this.string; this.string = undefined; this.popState(); return 48; +break; +case 33: /* The newlines are there because we can span strings across lines using \ */ + switch (yy_.yytext) { + case '\r\n': + case '\n': break; + case 'b': this.string += '\b'; break; + case 'n': this.string += '\n'; break; + case 'r': this.string += '\r'; break; + case 't': this.string += '\t'; break; + case "'": this.string += "'"; break; + case '"': this.string += '"'; break; + case '\\': this.string += '\\'; break; + default: this.string += '\\' + $1; break; + } + + this.popState(); + +break; +case 34:this.string += yy_.yytext; +break; +case 35:this.string += yy_.yytext; +break; +case 36:return 57 /* TODO: non-ASCII identifiers */ +break; +case 37:return 49 /* 3.1, 3.1e-7 */ +break; +case 38:return 50 +break; +case 39:return 28 +break; +case 40:return 29 +break; +case 41:return 30 +break; +case 42:return 31 +break; +case 43:return 32 +break; +case 44:return 37 +break; +case 45:return 41 +break; +case 46:return 40 +break; +case 47:return 39 +break; +case 48:return 38 +break; +case 49:return 33 +break; +case 50:return 34 +break; +case 51:return 35 +break; +case 52:return 19 +break; +case 53:return 20 +break; +case 54:return 46 +break; +case 55:return 47 +break; +case 56:return 5 +break; +case 57:return 'INVALID' +break; +} +}, +rules: [/^(?:\/\/([^\n\r]*))/,/^(?:\/\*([\u0000-\uffff]*?)\*\/)/,/^(?:\s+)/,/^(?:function\b)/,/^(?:return\s*\n)/,/^(?:return\b)/,/^(?:if\b)/,/^(?:else\b)/,/^(?:while\b)/,/^(?:for\b)/,/^(?:case\b)/,/^(?:default\b)/,/^(?:new\b)/,/^(?:break\b)/,/^(?:continue\b)/,/^(?:var\b)/,/^(?:===)/,/^(?:=)/,/^(?:\{)/,/^(?:\})/,/^(?:;)/,/^(?:,)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:\[\])/,/^(?:\[)/,/^(?:\])/,/^(?:\.)/,/^(?:")/,/^(?:')/,/^(?:\\)/,/^(?:")/,/^(?:')/,/^(?:(.|\r\n|\n))/,/^(?:[^"\\]*)/,/^(?:[^'\\]*)/,/^(?:[A-Za-z_][A-Za-z0-9_]*)/,/^(?:[0-9]+(\.[0-9]+)?([eE][\-+]?[0-9]+)?\b)/,/^(?:[0-9]+\b)/,/^(?:\+)/,/^(?:-)/,/^(?:\*)/,/^(?:\/)/,/^(?:%)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:<)/,/^(?:>)/,/^(?:!)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\()/,/^(?:\))/,/^(?:\?)/,/^(?::)/,/^(?:$)/,/^(?:.)/], +conditions: {"QuotedStringEscape":{"rules":[33],"inclusive":false},"SingleQuotedString":{"rules":[30,32,35],"inclusive":false},"DoubleQuotedString":{"rules":[30,31,34],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer;parser.lexer.options.ranges = true; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); + + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = parserWeek3; +exports.Parser = parserWeek3.Parser; +exports.parse = function () { return parserWeek3.parse.apply(parserWeek3, arguments); }; +exports.main = function commonjsMain(args) { + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); +}; +if (typeof module !== 'undefined' && require.main === module) { + exports.main(process.argv.slice(1)); +} +} \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-3.js.patch b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-3.js.patch new file mode 100644 index 000000000..216377ca4 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-3.js.patch @@ -0,0 +1,11 @@ +--- parser-week-3 copy.js 2015-09-17 19:46:10.000000000 +0800 ++++ parser-week-3.js 2015-09-17 19:46:27.000000000 +0800 +@@ -347,7 +347,7 @@ + }}; + + /* lib/parser/includes/nodes.js*/ +-var Nodes = require('lib/parser/nodes'); ++var Nodes = require('./nodes'); + ; + + /* generated by jison-lex 0.3.4 */ diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-4.js b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-4.js new file mode 100644 index 000000000..4c9cd2e9f --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-4.js @@ -0,0 +1,843 @@ +/* parser generated by jison 0.4.15 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +var parserWeek4 = (function(){ +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,6],$V1=[1,13],$V2=[1,14],$V3=[1,21],$V4=[1,15],$V5=[1,16],$V6=[1,17],$V7=[1,19],$V8=[1,18],$V9=[1,20],$Va=[1,25],$Vb=[1,26],$Vc=[1,27],$Vd=[1,28],$Ve=[1,29],$Vf=[1,30],$Vg=[1,31],$Vh=[5,9],$Vi=[5,9,15,18,19,22,25,26,28,29,33,48,49,50,51,52,53,57],$Vj=[1,41],$Vk=[1,42],$Vl=[1,43],$Vm=[1,44],$Vn=[1,45],$Vo=[1,46],$Vp=[1,47],$Vq=[1,48],$Vr=[1,49],$Vs=[1,50],$Vt=[1,51],$Vu=[1,52],$Vv=[1,53],$Vw=[1,54],$Vx=[1,55],$Vy=[1,58],$Vz=[1,60],$VA=[15,20,28,29,30,31,32,34,35,36,37,38,39,40,41,42,46,47,55],$VB=[5,9,15,18,19,20,21,22,25,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,46,47,48,49,50,51,52,53,55,57],$VC=[2,64],$VD=[15,20,28,29,30,31,32,34,35,36,37,38,39,40,41,46,47,55],$VE=[2,60],$VF=[15,20,28,29,34,35,36,37,38,39,40,41,46,47,55],$VG=[15,20,34,35,36,37,46,47,55],$VH=[15,20,34,35,36,37,38,39,40,41,46,47,55]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"program":3,"statements":4,"EOF":5,"statement_block":6,"empty_block":7,"{":8,"}":9,"non_empty_statements":10,"statement":11,"if_statement":12,"function_definition":13,"return_statement":14,";":15,"variable_definition":16,"expression":17,"if":18,"(":19,")":20,"else":21,"function":22,"identifier":23,"identifiers":24,"return":25,"var":26,"=":27,"+":28,"-":29,"*":30,"/":31,"%":32,"!":33,"&&":34,"||":35,"===":36,"!==":37,">":38,"<":39,">=":40,"<=":41,".":42,"constants":43,"expressions":44,"function_expression":45,"?":46,":":47,"STRING":48,"FLOAT_NUMBER":49,"INT_NUMBER":50,"true":51,"false":52,"empty_list":53,"non_empty_expressions":54,",":55,"non_empty_identifiers":56,"Identifier":57,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",8:"{",9:"}",15:";",18:"if",19:"(",20:")",21:"else",22:"function",25:"return",26:"var",27:"=",28:"+",29:"-",30:"*",31:"/",32:"%",33:"!",34:"&&",35:"||",36:"===",37:"!==",38:">",39:"<",40:">=",41:"<=",42:".",46:"?",47:":",48:"STRING",49:"FLOAT_NUMBER",50:"INT_NUMBER",51:"true",52:"false",53:"empty_list",55:",",57:"Identifier"}, +productions_: [0,[3,2],[3,2],[3,2],[7,2],[6,3],[4,0],[4,1],[10,2],[10,1],[11,1],[11,1],[11,2],[11,2],[11,2],[11,1],[12,7],[12,7],[12,7],[12,7],[12,7],[12,7],[13,6],[13,6],[14,2],[16,4],[17,3],[17,3],[17,3],[17,3],[17,3],[17,2],[17,2],[17,2],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,1],[17,1],[17,6],[17,4],[17,6],[17,1],[17,5],[43,1],[43,1],[43,1],[43,1],[43,1],[43,1],[45,5],[45,5],[44,1],[44,0],[54,3],[54,1],[24,1],[24,0],[56,3],[56,1],[23,1]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: case 2: case 3: + return $$[$0-1]; +break; +case 4: + this.$ = [] +break; +case 5: case 43: + this.$ = $$[$0-1]; +break; +case 6: case 60: case 64: + this.$ = []; +break; +case 8: + + if ($$[$0-1] === Nodes.no_op()) { + this.$ = $$[$0]; + } else { + this.$ = Nodes.pair($$[$0-1], $$[$0]); + } + +break; +case 9: + + if ($$[$0] === Nodes.no_op()) { + this.$ = []; + } else { + this.$ = Nodes.pair($$[$0], []); + } + +break; +case 15: + this.$ = Nodes.no_op(); +break; +case 16: case 17: case 18: case 19: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 20: case 21: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], Nodes.pair($$[$0], []), yylineno); +break; +case 22: case 23: + this.$ = Nodes.variable_definition($$[$0-4], Nodes.function_definition($$[$0-4], $$[$0-2], $$[$0], _$[$0-5], _$[$0]), yylineno); +break; +case 24: + this.$ = Nodes.return_statement($$[$0], yylineno); +break; +case 25: + this.$ = Nodes.variable_definition($$[$0-2], $$[$0], yylineno); +break; +case 26: case 27: case 28: case 29: case 30: case 36: case 37: case 38: case 39: case 40: case 41: + this.$ = Nodes.eager_binary_expression($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 31: case 32: + this.$ = Nodes.eager_binary_expression(0, $$[$0-1], $$[$0], yylineno); +break; +case 33: + this.$ = Nodes.eager_unary_expression($$[$0-1], $$[$0], yylineno); +break; +case 34: case 35: + this.$ = Nodes.boolean_operation($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 42: + this.$ = Nodes.property_access($$[$0-2], $$[$0], yylineno); +break; +case 45: + this.$ = Nodes.variable($$[$0], yylineno); +break; +case 46: + this.$ = Nodes.application($$[$0-4], $$[$0-1], yylineno); +break; +case 47: + this.$ = Nodes.application(Nodes.variable($$[$0-3], yylineno), $$[$0-1], yylineno); +break; +case 48: + this.$ = Nodes.object_method_application($$[$0-5], $$[$0-3], $$[$0-1], yylineno); +break; +case 50: + this.$ = Nodes.ternary($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 51: case 67: + this.$ = yytext; +break; +case 52: + this.$ = parseFloat(yytext); +break; +case 53: + this.$ = parseInt(yytext, 10); +break; +case 54: + this.$ = true; +break; +case 55: + this.$ = false; +break; +case 56: + this.$ = Nodes.empty_list(yylineno); +break; +case 57: case 58: + this.$ = Nodes.function_definition('lambda', $$[$0-2], $$[$0], _$[$0-4], _$[$0]); +break; +case 59: case 63: + this.$ = $$[$0]; +break; +case 61: case 65: + this.$ = Nodes.pair($$[$0-2], $$[$0]); +break; +case 62: case 66: + this.$ = Nodes.pair($$[$0], []); +break; +} +}, +table: [{3:1,4:2,5:[2,6],6:3,7:4,8:$V0,10:5,11:7,12:8,13:9,14:10,15:$V1,16:11,17:12,18:$V2,19:$V3,22:$V4,23:23,25:$V5,26:$V6,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{1:[3]},{5:[1,32]},{5:[1,33]},{5:[1,34]},{5:[2,7]},{9:[1,36],10:35,11:7,12:8,13:9,14:10,15:$V1,16:11,17:12,18:$V2,19:$V3,22:$V4,23:23,25:$V5,26:$V6,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},o($Vh,[2,9],{11:7,12:8,13:9,14:10,16:11,17:12,43:22,23:23,45:24,10:37,15:$V1,18:$V2,19:$V3,22:$V4,25:$V5,26:$V6,28:$V7,29:$V8,33:$V9,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg}),o($Vi,[2,10]),o($Vi,[2,11]),{15:[1,38]},{15:[1,39]},{15:[1,40],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},o($Vi,[2,15]),{19:[1,56]},{19:$Vy,23:57,57:$Vg},{17:59,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{23:61,57:$Vg},{17:62,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:63,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:64,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:65,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},o($VA,[2,44]),o($VA,[2,45],{19:[1,66]}),o($VA,[2,49]),o($VA,[2,51]),o($VA,[2,52]),o($VA,[2,53]),o($VA,[2,54]),o($VA,[2,55]),o($VA,[2,56]),o([15,19,20,27,28,29,30,31,32,34,35,36,37,38,39,40,41,42,46,47,55],[2,67]),{1:[2,1]},{1:[2,2]},{1:[2,3]},{9:[1,67]},o($VB,[2,4]),o($Vh,[2,8]),o($Vi,[2,12]),o($Vi,[2,13]),o($Vi,[2,14]),{17:68,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:69,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:70,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:71,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:72,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:73,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:74,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:75,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:76,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:77,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:78,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:79,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:80,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{23:81,57:$Vg},{17:82,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:83,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{19:[1,84]},{20:$VC,23:87,24:85,56:86,57:$Vg},{15:[2,24],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{19:$Vy},{27:[1,88]},o($VD,[2,31],{42:$Vw}),o($VD,[2,32],{42:$Vw}),o($VD,[2,33],{42:$Vw}),{20:[1,89],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{17:92,19:$V3,20:$VE,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,44:90,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:91,57:$Vg},o($VB,[2,5]),o($VF,[2,26],{30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VF,[2,27],{30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VD,[2,28],{42:$Vw}),o($VD,[2,29],{42:$Vw}),o($VD,[2,30],{42:$Vw}),o([15,20,34,35,46,47,55],[2,34],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o([15,20,35,46,47,55],[2,35],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o($VG,[2,36],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o($VG,[2,37],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o($VH,[2,38],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VH,[2,39],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VH,[2,40],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VH,[2,41],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VA,[2,42],{19:[1,93]}),{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx,47:[1,94]},{20:[1,95],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{20:$VC,23:87,24:96,56:86,57:$Vg},{20:[1,97]},{20:[2,63]},{20:[2,66],55:[1,98]},{17:99,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},o($VA,[2,43],{19:[1,100]}),{20:[1,101]},{20:[2,59]},{20:[2,62],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx,55:[1,102]},{17:92,19:$V3,20:$VE,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,44:103,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:91,57:$Vg},{17:104,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{6:105,7:106,8:$V0},{20:[1,107]},{6:108,7:109,8:$V0},{23:87,56:110,57:$Vg},{15:[2,25],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{17:92,19:$V3,20:$VE,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,44:111,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:91,57:$Vg},o($VA,[2,47]),{17:92,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:112,57:$Vg},{20:[1,113]},o([15,20,47,55],[2,50],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx}),{21:[1,114]},{21:[1,115]},{6:116,7:117,8:$V0},o($VA,[2,57]),o($VA,[2,58]),{20:[2,65]},{20:[1,118]},{20:[2,61]},o($VA,[2,48]),{6:119,7:120,8:$V0,12:121,18:$V2},{6:122,7:123,8:$V0,12:124,18:$V2},o($Vi,[2,22]),o($Vi,[2,23]),o($VA,[2,46]),o($Vi,[2,16]),o($Vi,[2,17]),o($Vi,[2,20]),o($Vi,[2,18]),o($Vi,[2,19]),o($Vi,[2,21])], +defaultActions: {5:[2,7],32:[2,1],33:[2,2],34:[2,3],86:[2,63],91:[2,59],110:[2,65],112:[2,61]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + function _parseError (msg, hash) { + this.message = msg; + this.hash = hash; + } + _parseError.prototype = new Error(); + + throw new _parseError(str, hash); + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + _token_stack: + function lex() { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; + +/* lib/parser/includes/nodes.js*/ +var Nodes = require('./nodes'); +; + +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:/* skip single-line comments */ +break; +case 1:/* skip multi-line comments */ +break; +case 2:/* skip whitespace */ +break; +case 3:return 22 +break; +case 4:return 'INVALID' +break; +case 5:return 25 +break; +case 6:return 18 +break; +case 7:return 21 +break; +case 8:return 'while' +break; +case 9:return 'for' +break; +case 10:return 'case' +break; +case 11:return 'default' +break; +case 12:return 'new' +break; +case 13:return 'break' +break; +case 14:return 'continue' +break; +case 15:return 26 +break; +case 16:return 36 +break; +case 17:return 27 +break; +case 18:return 8 +break; +case 19:return 9 +break; +case 20:return 15 +break; +case 21:return 55 +break; +case 22:return 51 +break; +case 23:return 52 +break; +case 24:return 53 +break; +case 25:return '[' +break; +case 26:return ']' +break; +case 27:return 42 +break; +case 28: this.begin('DoubleQuotedString'); this.string = ''; +break; +case 29: this.begin('SingleQuotedString'); this.string = ''; +break; +case 30:this.begin('QuotedStringEscape'); +break; +case 31: yy_.yytext = this.string; this.string = undefined; this.popState(); return 48; +break; +case 32: yy_.yytext = this.string; this.string = undefined; this.popState(); return 48; +break; +case 33: /* The newlines are there because we can span strings across lines using \ */ + switch (yy_.yytext) { + case '\r\n': + case '\n': break; + case 'b': this.string += '\b'; break; + case 'n': this.string += '\n'; break; + case 'r': this.string += '\r'; break; + case 't': this.string += '\t'; break; + case "'": this.string += "'"; break; + case '"': this.string += '"'; break; + case '\\': this.string += '\\'; break; + default: this.string += '\\' + $1; break; + } + + this.popState(); + +break; +case 34:this.string += yy_.yytext; +break; +case 35:this.string += yy_.yytext; +break; +case 36:return 57 /* TODO: non-ASCII identifiers */ +break; +case 37:return 49 /* 3.1, 3.1e-7 */ +break; +case 38:return 50 +break; +case 39:return 28 +break; +case 40:return 29 +break; +case 41:return 30 +break; +case 42:return 31 +break; +case 43:return 32 +break; +case 44:return 37 +break; +case 45:return 41 +break; +case 46:return 40 +break; +case 47:return 39 +break; +case 48:return 38 +break; +case 49:return 33 +break; +case 50:return 34 +break; +case 51:return 35 +break; +case 52:return 19 +break; +case 53:return 20 +break; +case 54:return 46 +break; +case 55:return 47 +break; +case 56:return 5 +break; +case 57:return 'INVALID' +break; +} +}, +rules: [/^(?:\/\/([^\n\r]*))/,/^(?:\/\*([\u0000-\uffff]*?)\*\/)/,/^(?:\s+)/,/^(?:function\b)/,/^(?:return\s*\n)/,/^(?:return\b)/,/^(?:if\b)/,/^(?:else\b)/,/^(?:while\b)/,/^(?:for\b)/,/^(?:case\b)/,/^(?:default\b)/,/^(?:new\b)/,/^(?:break\b)/,/^(?:continue\b)/,/^(?:var\b)/,/^(?:===)/,/^(?:=)/,/^(?:\{)/,/^(?:\})/,/^(?:;)/,/^(?:,)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:\[\])/,/^(?:\[)/,/^(?:\])/,/^(?:\.)/,/^(?:")/,/^(?:')/,/^(?:\\)/,/^(?:")/,/^(?:')/,/^(?:(.|\r\n|\n))/,/^(?:[^"\\]*)/,/^(?:[^'\\]*)/,/^(?:[A-Za-z_][A-Za-z0-9_]*)/,/^(?:[0-9]+(\.[0-9]+)?([eE][\-+]?[0-9]+)?\b)/,/^(?:[0-9]+\b)/,/^(?:\+)/,/^(?:-)/,/^(?:\*)/,/^(?:\/)/,/^(?:%)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:<)/,/^(?:>)/,/^(?:!)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\()/,/^(?:\))/,/^(?:\?)/,/^(?::)/,/^(?:$)/,/^(?:.)/], +conditions: {"QuotedStringEscape":{"rules":[33],"inclusive":false},"SingleQuotedString":{"rules":[30,32,35],"inclusive":false},"DoubleQuotedString":{"rules":[30,31,34],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer;parser.lexer.options.ranges = true; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); + + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = parserWeek4; +exports.Parser = parserWeek4.Parser; +exports.parse = function () { return parserWeek4.parse.apply(parserWeek4, arguments); }; +exports.main = function commonjsMain(args) { + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); +}; +if (typeof module !== 'undefined' && require.main === module) { + exports.main(process.argv.slice(1)); +} +} \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-4.js.patch b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-4.js.patch new file mode 100644 index 000000000..5ffdd1b12 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-4.js.patch @@ -0,0 +1,11 @@ +--- parser-week-4 copy.js 2015-09-17 19:42:35.000000000 +0800 ++++ parser-week-4.js 2015-09-17 19:44:49.000000000 +0800 +@@ -347,7 +347,7 @@ + }}; + + /* lib/parser/includes/nodes.js*/ +-var Nodes = require('lib/parser/nodes'); ++var Nodes = require('./nodes'); + ; + + /* generated by jison-lex 0.3.4 */ diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-5.js b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-5.js new file mode 100644 index 000000000..fa74c4e41 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-5.js @@ -0,0 +1,843 @@ +/* parser generated by jison 0.4.15 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +var parserWeek5 = (function(){ +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,6],$V1=[1,13],$V2=[1,14],$V3=[1,21],$V4=[1,15],$V5=[1,16],$V6=[1,17],$V7=[1,19],$V8=[1,18],$V9=[1,20],$Va=[1,25],$Vb=[1,26],$Vc=[1,27],$Vd=[1,28],$Ve=[1,29],$Vf=[1,30],$Vg=[1,31],$Vh=[5,9],$Vi=[5,9,15,18,19,22,25,26,28,29,33,48,49,50,51,52,53,57],$Vj=[1,41],$Vk=[1,42],$Vl=[1,43],$Vm=[1,44],$Vn=[1,45],$Vo=[1,46],$Vp=[1,47],$Vq=[1,48],$Vr=[1,49],$Vs=[1,50],$Vt=[1,51],$Vu=[1,52],$Vv=[1,53],$Vw=[1,54],$Vx=[1,55],$Vy=[1,58],$Vz=[1,60],$VA=[15,20,28,29,30,31,32,34,35,36,37,38,39,40,41,42,46,47,55],$VB=[5,9,15,18,19,20,21,22,25,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,46,47,48,49,50,51,52,53,55,57],$VC=[2,64],$VD=[15,20,28,29,30,31,32,34,35,36,37,38,39,40,41,46,47,55],$VE=[2,60],$VF=[15,20,28,29,34,35,36,37,38,39,40,41,46,47,55],$VG=[15,20,34,35,36,37,46,47,55],$VH=[15,20,34,35,36,37,38,39,40,41,46,47,55]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"program":3,"statements":4,"EOF":5,"statement_block":6,"empty_block":7,"{":8,"}":9,"non_empty_statements":10,"statement":11,"if_statement":12,"function_definition":13,"return_statement":14,";":15,"variable_definition":16,"expression":17,"if":18,"(":19,")":20,"else":21,"function":22,"identifier":23,"identifiers":24,"return":25,"var":26,"=":27,"+":28,"-":29,"*":30,"/":31,"%":32,"!":33,"&&":34,"||":35,"===":36,"!==":37,">":38,"<":39,">=":40,"<=":41,".":42,"constants":43,"expressions":44,"function_expression":45,"?":46,":":47,"STRING":48,"FLOAT_NUMBER":49,"INT_NUMBER":50,"true":51,"false":52,"empty_list":53,"non_empty_expressions":54,",":55,"non_empty_identifiers":56,"Identifier":57,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",8:"{",9:"}",15:";",18:"if",19:"(",20:")",21:"else",22:"function",25:"return",26:"var",27:"=",28:"+",29:"-",30:"*",31:"/",32:"%",33:"!",34:"&&",35:"||",36:"===",37:"!==",38:">",39:"<",40:">=",41:"<=",42:".",46:"?",47:":",48:"STRING",49:"FLOAT_NUMBER",50:"INT_NUMBER",51:"true",52:"false",53:"empty_list",55:",",57:"Identifier"}, +productions_: [0,[3,2],[3,2],[3,2],[7,2],[6,3],[4,0],[4,1],[10,2],[10,1],[11,1],[11,1],[11,2],[11,2],[11,2],[11,1],[12,7],[12,7],[12,7],[12,7],[12,7],[12,7],[13,6],[13,6],[14,2],[16,4],[17,3],[17,3],[17,3],[17,3],[17,3],[17,2],[17,2],[17,2],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,3],[17,1],[17,1],[17,6],[17,4],[17,6],[17,1],[17,5],[43,1],[43,1],[43,1],[43,1],[43,1],[43,1],[45,5],[45,5],[44,1],[44,0],[54,3],[54,1],[24,1],[24,0],[56,3],[56,1],[23,1]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: case 2: case 3: + return $$[$0-1]; +break; +case 4: + this.$ = [] +break; +case 5: case 43: + this.$ = $$[$0-1]; +break; +case 6: case 60: case 64: + this.$ = []; +break; +case 8: + + if ($$[$0-1] === Nodes.no_op()) { + this.$ = $$[$0]; + } else { + this.$ = Nodes.pair($$[$0-1], $$[$0]); + } + +break; +case 9: + + if ($$[$0] === Nodes.no_op()) { + this.$ = []; + } else { + this.$ = Nodes.pair($$[$0], []); + } + +break; +case 15: + this.$ = Nodes.no_op(); +break; +case 16: case 17: case 18: case 19: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 20: case 21: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], Nodes.pair($$[$0], []), yylineno); +break; +case 22: case 23: + this.$ = Nodes.variable_definition($$[$0-4], Nodes.function_definition($$[$0-4], $$[$0-2], $$[$0], _$[$0-5], _$[$0]), yylineno); +break; +case 24: + this.$ = Nodes.return_statement($$[$0], yylineno); +break; +case 25: + this.$ = Nodes.variable_definition($$[$0-2], $$[$0], yylineno); +break; +case 26: case 27: case 28: case 29: case 30: case 36: case 37: case 38: case 39: case 40: case 41: + this.$ = Nodes.eager_binary_expression($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 31: case 32: + this.$ = Nodes.eager_binary_expression(0, $$[$0-1], $$[$0], yylineno); +break; +case 33: + this.$ = Nodes.eager_unary_expression($$[$0-1], $$[$0], yylineno); +break; +case 34: case 35: + this.$ = Nodes.boolean_operation($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 42: + this.$ = Nodes.property_access($$[$0-2], $$[$0], yylineno); +break; +case 45: + this.$ = Nodes.variable($$[$0], yylineno); +break; +case 46: + this.$ = Nodes.application($$[$0-4], $$[$0-1], yylineno); +break; +case 47: + this.$ = Nodes.application(Nodes.variable($$[$0-3], yylineno), $$[$0-1], yylineno); +break; +case 48: + this.$ = Nodes.object_method_application($$[$0-5], $$[$0-3], $$[$0-1], yylineno); +break; +case 50: + this.$ = Nodes.ternary($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 51: case 67: + this.$ = yytext; +break; +case 52: + this.$ = parseFloat(yytext); +break; +case 53: + this.$ = parseInt(yytext, 10); +break; +case 54: + this.$ = true; +break; +case 55: + this.$ = false; +break; +case 56: + this.$ = Nodes.empty_list(yylineno); +break; +case 57: case 58: + this.$ = Nodes.function_definition('lambda', $$[$0-2], $$[$0], _$[$0-4], _$[$0]); +break; +case 59: case 63: + this.$ = $$[$0]; +break; +case 61: case 65: + this.$ = Nodes.pair($$[$0-2], $$[$0]); +break; +case 62: case 66: + this.$ = Nodes.pair($$[$0], []); +break; +} +}, +table: [{3:1,4:2,5:[2,6],6:3,7:4,8:$V0,10:5,11:7,12:8,13:9,14:10,15:$V1,16:11,17:12,18:$V2,19:$V3,22:$V4,23:23,25:$V5,26:$V6,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{1:[3]},{5:[1,32]},{5:[1,33]},{5:[1,34]},{5:[2,7]},{9:[1,36],10:35,11:7,12:8,13:9,14:10,15:$V1,16:11,17:12,18:$V2,19:$V3,22:$V4,23:23,25:$V5,26:$V6,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},o($Vh,[2,9],{11:7,12:8,13:9,14:10,16:11,17:12,43:22,23:23,45:24,10:37,15:$V1,18:$V2,19:$V3,22:$V4,25:$V5,26:$V6,28:$V7,29:$V8,33:$V9,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg}),o($Vi,[2,10]),o($Vi,[2,11]),{15:[1,38]},{15:[1,39]},{15:[1,40],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},o($Vi,[2,15]),{19:[1,56]},{19:$Vy,23:57,57:$Vg},{17:59,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{23:61,57:$Vg},{17:62,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:63,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:64,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:65,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},o($VA,[2,44]),o($VA,[2,45],{19:[1,66]}),o($VA,[2,49]),o($VA,[2,51]),o($VA,[2,52]),o($VA,[2,53]),o($VA,[2,54]),o($VA,[2,55]),o($VA,[2,56]),o([15,19,20,27,28,29,30,31,32,34,35,36,37,38,39,40,41,42,46,47,55],[2,67]),{1:[2,1]},{1:[2,2]},{1:[2,3]},{9:[1,67]},o($VB,[2,4]),o($Vh,[2,8]),o($Vi,[2,12]),o($Vi,[2,13]),o($Vi,[2,14]),{17:68,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:69,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:70,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:71,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:72,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:73,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:74,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:75,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:76,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:77,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:78,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:79,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:80,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{23:81,57:$Vg},{17:82,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{17:83,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{19:[1,84]},{20:$VC,23:87,24:85,56:86,57:$Vg},{15:[2,24],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{19:$Vy},{27:[1,88]},o($VD,[2,31],{42:$Vw}),o($VD,[2,32],{42:$Vw}),o($VD,[2,33],{42:$Vw}),{20:[1,89],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{17:92,19:$V3,20:$VE,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,44:90,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:91,57:$Vg},o($VB,[2,5]),o($VF,[2,26],{30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VF,[2,27],{30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VD,[2,28],{42:$Vw}),o($VD,[2,29],{42:$Vw}),o($VD,[2,30],{42:$Vw}),o([15,20,34,35,46,47,55],[2,34],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o([15,20,35,46,47,55],[2,35],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o($VG,[2,36],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o($VG,[2,37],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw}),o($VH,[2,38],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VH,[2,39],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VH,[2,40],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VH,[2,41],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,42:$Vw}),o($VA,[2,42],{19:[1,93]}),{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx,47:[1,94]},{20:[1,95],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{20:$VC,23:87,24:96,56:86,57:$Vg},{20:[1,97]},{20:[2,63]},{20:[2,66],55:[1,98]},{17:99,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},o($VA,[2,43],{19:[1,100]}),{20:[1,101]},{20:[2,59]},{20:[2,62],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx,55:[1,102]},{17:92,19:$V3,20:$VE,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,44:103,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:91,57:$Vg},{17:104,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,57:$Vg},{6:105,7:106,8:$V0},{20:[1,107]},{6:108,7:109,8:$V0},{23:87,56:110,57:$Vg},{15:[2,25],28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx},{17:92,19:$V3,20:$VE,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,44:111,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:91,57:$Vg},o($VA,[2,47]),{17:92,19:$V3,22:$Vz,23:23,28:$V7,29:$V8,33:$V9,43:22,45:24,48:$Va,49:$Vb,50:$Vc,51:$Vd,52:$Ve,53:$Vf,54:112,57:$Vg},{20:[1,113]},o([15,20,47,55],[2,50],{28:$Vj,29:$Vk,30:$Vl,31:$Vm,32:$Vn,34:$Vo,35:$Vp,36:$Vq,37:$Vr,38:$Vs,39:$Vt,40:$Vu,41:$Vv,42:$Vw,46:$Vx}),{21:[1,114]},{21:[1,115]},{6:116,7:117,8:$V0},o($VA,[2,57]),o($VA,[2,58]),{20:[2,65]},{20:[1,118]},{20:[2,61]},o($VA,[2,48]),{6:119,7:120,8:$V0,12:121,18:$V2},{6:122,7:123,8:$V0,12:124,18:$V2},o($Vi,[2,22]),o($Vi,[2,23]),o($VA,[2,46]),o($Vi,[2,16]),o($Vi,[2,17]),o($Vi,[2,20]),o($Vi,[2,18]),o($Vi,[2,19]),o($Vi,[2,21])], +defaultActions: {5:[2,7],32:[2,1],33:[2,2],34:[2,3],86:[2,63],91:[2,59],110:[2,65],112:[2,61]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + function _parseError (msg, hash) { + this.message = msg; + this.hash = hash; + } + _parseError.prototype = new Error(); + + throw new _parseError(str, hash); + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + _token_stack: + function lex() { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; + +/* lib/parser/includes/nodes.js*/ +var Nodes = require('./nodes'); +; + +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:/* skip single-line comments */ +break; +case 1:/* skip multi-line comments */ +break; +case 2:/* skip whitespace */ +break; +case 3:return 22 +break; +case 4:return 'INVALID' +break; +case 5:return 25 +break; +case 6:return 18 +break; +case 7:return 21 +break; +case 8:return 'while' +break; +case 9:return 'for' +break; +case 10:return 'case' +break; +case 11:return 'default' +break; +case 12:return 'new' +break; +case 13:return 'break' +break; +case 14:return 'continue' +break; +case 15:return 26 +break; +case 16:return 36 +break; +case 17:return 27 +break; +case 18:return 8 +break; +case 19:return 9 +break; +case 20:return 15 +break; +case 21:return 55 +break; +case 22:return 51 +break; +case 23:return 52 +break; +case 24:return 53 +break; +case 25:return '[' +break; +case 26:return ']' +break; +case 27:return 42 +break; +case 28: this.begin('DoubleQuotedString'); this.string = ''; +break; +case 29: this.begin('SingleQuotedString'); this.string = ''; +break; +case 30:this.begin('QuotedStringEscape'); +break; +case 31: yy_.yytext = this.string; this.string = undefined; this.popState(); return 48; +break; +case 32: yy_.yytext = this.string; this.string = undefined; this.popState(); return 48; +break; +case 33: /* The newlines are there because we can span strings across lines using \ */ + switch (yy_.yytext) { + case '\r\n': + case '\n': break; + case 'b': this.string += '\b'; break; + case 'n': this.string += '\n'; break; + case 'r': this.string += '\r'; break; + case 't': this.string += '\t'; break; + case "'": this.string += "'"; break; + case '"': this.string += '"'; break; + case '\\': this.string += '\\'; break; + default: this.string += '\\' + $1; break; + } + + this.popState(); + +break; +case 34:this.string += yy_.yytext; +break; +case 35:this.string += yy_.yytext; +break; +case 36:return 57 /* TODO: non-ASCII identifiers */ +break; +case 37:return 49 /* 3.1, 3.1e-7 */ +break; +case 38:return 50 +break; +case 39:return 28 +break; +case 40:return 29 +break; +case 41:return 30 +break; +case 42:return 31 +break; +case 43:return 32 +break; +case 44:return 37 +break; +case 45:return 41 +break; +case 46:return 40 +break; +case 47:return 39 +break; +case 48:return 38 +break; +case 49:return 33 +break; +case 50:return 34 +break; +case 51:return 35 +break; +case 52:return 19 +break; +case 53:return 20 +break; +case 54:return 46 +break; +case 55:return 47 +break; +case 56:return 5 +break; +case 57:return 'INVALID' +break; +} +}, +rules: [/^(?:\/\/([^\n\r]*))/,/^(?:\/\*([\u0000-\uffff]*?)\*\/)/,/^(?:\s+)/,/^(?:function\b)/,/^(?:return\s*\n)/,/^(?:return\b)/,/^(?:if\b)/,/^(?:else\b)/,/^(?:while\b)/,/^(?:for\b)/,/^(?:case\b)/,/^(?:default\b)/,/^(?:new\b)/,/^(?:break\b)/,/^(?:continue\b)/,/^(?:var\b)/,/^(?:===)/,/^(?:=)/,/^(?:\{)/,/^(?:\})/,/^(?:;)/,/^(?:,)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:\[\])/,/^(?:\[)/,/^(?:\])/,/^(?:\.)/,/^(?:")/,/^(?:')/,/^(?:\\)/,/^(?:")/,/^(?:')/,/^(?:(.|\r\n|\n))/,/^(?:[^"\\]*)/,/^(?:[^'\\]*)/,/^(?:[A-Za-z_][A-Za-z0-9_]*)/,/^(?:[0-9]+(\.[0-9]+)?([eE][\-+]?[0-9]+)?\b)/,/^(?:[0-9]+\b)/,/^(?:\+)/,/^(?:-)/,/^(?:\*)/,/^(?:\/)/,/^(?:%)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:<)/,/^(?:>)/,/^(?:!)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\()/,/^(?:\))/,/^(?:\?)/,/^(?::)/,/^(?:$)/,/^(?:.)/], +conditions: {"QuotedStringEscape":{"rules":[33],"inclusive":false},"SingleQuotedString":{"rules":[30,32,35],"inclusive":false},"DoubleQuotedString":{"rules":[30,31,34],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer;parser.lexer.options.ranges = true; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); + + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = parserWeek5; +exports.Parser = parserWeek5.Parser; +exports.parse = function () { return parserWeek5.parse.apply(parserWeek5, arguments); }; +exports.main = function commonjsMain(args) { + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); +}; +if (typeof module !== 'undefined' && require.main === module) { + exports.main(process.argv.slice(1)); +} +} \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-5.js.patch b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-5.js.patch new file mode 100644 index 000000000..d206fed4f --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-5.js.patch @@ -0,0 +1,11 @@ +--- parser-week-5 copy.js 2015-09-17 19:42:32.000000000 +0800 ++++ parser-week-5.js 2015-09-17 19:44:59.000000000 +0800 +@@ -347,7 +347,7 @@ + }}; + + /* lib/parser/includes/nodes.js*/ +-var Nodes = require('lib/parser/nodes'); ++var Nodes = require('./nodes'); + ; + + /* generated by jison-lex 0.3.4 */ diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-8.js b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-8.js new file mode 100644 index 000000000..1d83edaa3 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-8.js @@ -0,0 +1,856 @@ +/* parser generated by jison 0.4.15 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +var parserWeek8 = (function(){ +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,6],$V1=[1,15],$V2=[1,16],$V3=[1,24],$V4=[1,17],$V5=[1,18],$V6=[1,19],$V7=[1,20],$V8=[1,22],$V9=[1,21],$Va=[1,23],$Vb=[1,28],$Vc=[1,29],$Vd=[1,30],$Ve=[1,31],$Vf=[1,32],$Vg=[1,33],$Vh=[1,34],$Vi=[5,9],$Vj=[5,9,16,20,21,24,25,28,29,31,32,36,51,52,53,54,55,56,60],$Vk=[1,46],$Vl=[1,47],$Vm=[1,48],$Vn=[1,49],$Vo=[1,50],$Vp=[1,51],$Vq=[1,52],$Vr=[1,53],$Vs=[1,54],$Vt=[1,55],$Vu=[1,56],$Vv=[1,57],$Vw=[1,58],$Vx=[1,59],$Vy=[1,60],$Vz=[1,64],$VA=[1,66],$VB=[16,22,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,49,50,58],$VC=[5,9,16,20,21,22,23,24,25,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,49,50,51,52,53,54,55,56,58,60],$VD=[2,69],$VE=[16,22,30,31,32,33,34,35,37,38,39,40,41,42,43,44,49,50,58],$VF=[2,65],$VG=[16,22,30,31,32,37,38,39,40,41,42,43,44,49,50,58],$VH=[16,22,30,37,38,39,40,49,50,58],$VI=[16,22,30,37,38,39,40,41,42,43,44,49,50,58]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"program":3,"statements":4,"EOF":5,"statement_block":6,"empty_block":7,"{":8,"}":9,"non_empty_statements":10,"statement":11,"if_statement":12,"while_statement":13,"function_definition":14,"return_statement":15,";":16,"variable_definition":17,"assignment_statement":18,"expression":19,"if":20,"(":21,")":22,"else":23,"while":24,"function":25,"identifier":26,"identifiers":27,"return":28,"var":29,"=":30,"+":31,"-":32,"*":33,"/":34,"%":35,"!":36,"&&":37,"||":38,"===":39,"!==":40,">":41,"<":42,">=":43,"<=":44,".":45,"constants":46,"expressions":47,"function_expression":48,"?":49,":":50,"STRING":51,"FLOAT_NUMBER":52,"INT_NUMBER":53,"true":54,"false":55,"empty_list":56,"non_empty_expressions":57,",":58,"non_empty_identifiers":59,"Identifier":60,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",8:"{",9:"}",16:";",20:"if",21:"(",22:")",23:"else",24:"while",25:"function",28:"return",29:"var",30:"=",31:"+",32:"-",33:"*",34:"/",35:"%",36:"!",37:"&&",38:"||",39:"===",40:"!==",41:">",42:"<",43:">=",44:"<=",45:".",49:"?",50:":",51:"STRING",52:"FLOAT_NUMBER",53:"INT_NUMBER",54:"true",55:"false",56:"empty_list",58:",",60:"Identifier"}, +productions_: [0,[3,2],[3,2],[3,2],[7,2],[6,3],[4,0],[4,1],[10,2],[10,1],[11,1],[11,1],[11,1],[11,2],[11,2],[11,2],[11,2],[11,1],[12,7],[12,7],[12,7],[12,7],[12,7],[12,7],[13,5],[13,5],[14,6],[14,6],[15,2],[17,4],[18,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,2],[19,2],[19,2],[19,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,3],[19,1],[19,1],[19,6],[19,4],[19,6],[19,1],[19,5],[46,1],[46,1],[46,1],[46,1],[46,1],[46,1],[48,5],[48,5],[47,1],[47,0],[57,3],[57,1],[27,1],[27,0],[59,3],[59,1],[26,1]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: case 2: case 3: + return $$[$0-1]; +break; +case 4: + this.$ = [] +break; +case 5: case 48: + this.$ = $$[$0-1]; +break; +case 6: case 65: case 69: + this.$ = []; +break; +case 8: + + if ($$[$0-1] === Nodes.no_op()) { + this.$ = $$[$0]; + } else { + this.$ = Nodes.pair($$[$0-1], $$[$0]); + } + +break; +case 9: + + if ($$[$0] === Nodes.no_op()) { + this.$ = []; + } else { + this.$ = Nodes.pair($$[$0], []); + } + +break; +case 17: + this.$ = Nodes.no_op(); +break; +case 18: case 19: case 20: case 21: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 22: case 23: + this.$ = Nodes.if_statement($$[$0-4], $$[$0-2], Nodes.pair($$[$0], []), yylineno); +break; +case 24: case 25: + this.$ = Nodes.while_statement($$[$0-2], $$[$0], yylineno) +break; +case 26: case 27: + this.$ = Nodes.variable_definition($$[$0-4], Nodes.function_definition($$[$0-4], $$[$0-2], $$[$0], _$[$0-5], _$[$0]), yylineno); +break; +case 28: + this.$ = Nodes.return_statement($$[$0], yylineno); +break; +case 29: + this.$ = Nodes.variable_definition($$[$0-2], $$[$0], yylineno); +break; +case 30: + + if ($$[$0-2].tag === 'variable') { + this.$ = Nodes.assignment($$[$0-2], $$[$0], yylineno); + + } else { + error('parse error in line ' + yylineno + ": " + yytext); + } + +break; +case 31: case 32: case 33: case 34: case 35: case 41: case 42: case 43: case 44: case 45: case 46: + this.$ = Nodes.eager_binary_expression($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 36: case 37: + this.$ = Nodes.eager_binary_expression(0, $$[$0-1], $$[$0], yylineno); +break; +case 38: + this.$ = Nodes.eager_unary_expression($$[$0-1], $$[$0], yylineno); +break; +case 39: case 40: + this.$ = Nodes.boolean_operation($$[$0-2], $$[$0-1], $$[$0], yylineno); +break; +case 47: + this.$ = Nodes.property_access($$[$0-2], $$[$0], yylineno); +break; +case 50: + this.$ = Nodes.variable($$[$0], yylineno); +break; +case 51: + this.$ = Nodes.application($$[$0-4], $$[$0-1], yylineno); +break; +case 52: + this.$ = Nodes.application(Nodes.variable($$[$0-3], yylineno), $$[$0-1], yylineno); +break; +case 53: + this.$ = Nodes.object_method_application($$[$0-5], $$[$0-3], $$[$0-1], yylineno); +break; +case 55: + this.$ = Nodes.ternary($$[$0-4], $$[$0-2], $$[$0], yylineno); +break; +case 56: case 72: + this.$ = yytext; +break; +case 57: + this.$ = parseFloat(yytext); +break; +case 58: + this.$ = parseInt(yytext, 10); +break; +case 59: + this.$ = true; +break; +case 60: + this.$ = false; +break; +case 61: + this.$ = Nodes.empty_list(yylineno); +break; +case 62: case 63: + this.$ = Nodes.function_definition('lambda', $$[$0-2], $$[$0], _$[$0-4], _$[$0]); +break; +case 64: case 68: + this.$ = $$[$0]; +break; +case 66: case 70: + this.$ = Nodes.pair($$[$0-2], $$[$0]); +break; +case 67: case 71: + this.$ = Nodes.pair($$[$0], []); +break; +} +}, +table: [{3:1,4:2,5:[2,6],6:3,7:4,8:$V0,10:5,11:7,12:8,13:9,14:10,15:11,16:$V1,17:12,18:13,19:14,20:$V2,21:$V3,24:$V4,25:$V5,26:26,28:$V6,29:$V7,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{1:[3]},{5:[1,35]},{5:[1,36]},{5:[1,37]},{5:[2,7]},{9:[1,39],10:38,11:7,12:8,13:9,14:10,15:11,16:$V1,17:12,18:13,19:14,20:$V2,21:$V3,24:$V4,25:$V5,26:26,28:$V6,29:$V7,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},o($Vi,[2,9],{11:7,12:8,13:9,14:10,15:11,17:12,18:13,19:14,46:25,26:26,48:27,10:40,16:$V1,20:$V2,21:$V3,24:$V4,25:$V5,28:$V6,29:$V7,31:$V8,32:$V9,36:$Va,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh}),o($Vj,[2,10]),o($Vj,[2,11]),o($Vj,[2,12]),{16:[1,41]},{16:[1,42]},{16:[1,43]},{16:[1,44],30:[1,45],31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy},o($Vj,[2,17]),{21:[1,61]},{21:[1,62]},{21:$Vz,26:63,60:$Vh},{19:65,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{26:67,60:$Vh},{19:68,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:69,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:70,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:71,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},o($VB,[2,49]),o($VB,[2,50],{21:[1,72]}),o($VB,[2,54]),o($VB,[2,56]),o($VB,[2,57]),o($VB,[2,58]),o($VB,[2,59]),o($VB,[2,60]),o($VB,[2,61]),o([16,21,22,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,49,50,58],[2,72]),{1:[2,1]},{1:[2,2]},{1:[2,3]},{9:[1,73]},o($VC,[2,4]),o($Vi,[2,8]),o($Vj,[2,13]),o($Vj,[2,14]),o($Vj,[2,15]),o($Vj,[2,16]),{19:74,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:75,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:76,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:77,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:78,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:79,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:80,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:81,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:82,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:83,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:84,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:85,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:86,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:87,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{26:88,60:$Vh},{19:89,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:90,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{19:91,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{21:[1,92]},{22:$VD,26:95,27:93,59:94,60:$Vh},{16:[2,28],31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy},{21:$Vz},{30:[1,96]},o($VE,[2,36],{45:$Vx}),o($VE,[2,37],{45:$Vx}),o($VE,[2,38],{45:$Vx}),{22:[1,97],31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy},{19:100,21:$V3,22:$VF,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,47:98,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,57:99,60:$Vh},o($VC,[2,5]),{16:[2,30],31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy},o($VG,[2,31],{33:$Vm,34:$Vn,35:$Vo,45:$Vx}),o($VG,[2,32],{33:$Vm,34:$Vn,35:$Vo,45:$Vx}),o($VE,[2,33],{45:$Vx}),o($VE,[2,34],{45:$Vx}),o($VE,[2,35],{45:$Vx}),o([16,22,30,37,38,49,50,58],[2,39],{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx}),o([16,22,30,38,49,50,58],[2,40],{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx}),o($VH,[2,41],{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx}),o($VH,[2,42],{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx}),o($VI,[2,43],{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,45:$Vx}),o($VI,[2,44],{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,45:$Vx}),o($VI,[2,45],{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,45:$Vx}),o($VI,[2,46],{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,45:$Vx}),o($VB,[2,47],{21:[1,101]}),{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy,50:[1,102]},{22:[1,103],31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy},{22:[1,104],31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy},{22:$VD,26:95,27:105,59:94,60:$Vh},{22:[1,106]},{22:[2,68]},{22:[2,71],58:[1,107]},{19:108,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},o($VB,[2,48],{21:[1,109]}),{22:[1,110]},{22:[2,64]},{22:[2,67],31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy,58:[1,111]},{19:100,21:$V3,22:$VF,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,47:112,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,57:99,60:$Vh},{19:113,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,60:$Vh},{6:114,7:115,8:$V0},{6:116,7:117,8:$V0},{22:[1,118]},{6:119,7:120,8:$V0},{26:95,59:121,60:$Vh},{16:[2,29],31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy},{19:100,21:$V3,22:$VF,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,47:122,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,57:99,60:$Vh},o($VB,[2,52]),{19:100,21:$V3,25:$VA,26:26,31:$V8,32:$V9,36:$Va,46:25,48:27,51:$Vb,52:$Vc,53:$Vd,54:$Ve,55:$Vf,56:$Vg,57:123,60:$Vh},{22:[1,124]},o([16,22,30,50,58],[2,55],{31:$Vk,32:$Vl,33:$Vm,34:$Vn,35:$Vo,37:$Vp,38:$Vq,39:$Vr,40:$Vs,41:$Vt,42:$Vu,43:$Vv,44:$Vw,45:$Vx,49:$Vy}),{23:[1,125]},{23:[1,126]},o($Vj,[2,24]),o($Vj,[2,25]),{6:127,7:128,8:$V0},o($VB,[2,62]),o($VB,[2,63]),{22:[2,70]},{22:[1,129]},{22:[2,66]},o($VB,[2,53]),{6:130,7:131,8:$V0,12:132,20:$V2},{6:133,7:134,8:$V0,12:135,20:$V2},o($Vj,[2,26]),o($Vj,[2,27]),o($VB,[2,51]),o($Vj,[2,18]),o($Vj,[2,19]),o($Vj,[2,22]),o($Vj,[2,20]),o($Vj,[2,21]),o($Vj,[2,23])], +defaultActions: {5:[2,7],35:[2,1],36:[2,2],37:[2,3],94:[2,68],99:[2,64],121:[2,70],123:[2,66]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + function _parseError (msg, hash) { + this.message = msg; + this.hash = hash; + } + _parseError.prototype = new Error(); + + throw new _parseError(str, hash); + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + _token_stack: + function lex() { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; + +/* lib/parser/includes/nodes.js*/ +var Nodes = require('./nodes'); +; + +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:/* skip single-line comments */ +break; +case 1:/* skip multi-line comments */ +break; +case 2:/* skip whitespace */ +break; +case 3:return 25 +break; +case 4:return 'INVALID' +break; +case 5:return 28 +break; +case 6:return 20 +break; +case 7:return 23 +break; +case 8:return 24 +break; +case 9:return 'for' +break; +case 10:return 'case' +break; +case 11:return 'default' +break; +case 12:return 'new' +break; +case 13:return 'break' +break; +case 14:return 'continue' +break; +case 15:return 29 +break; +case 16:return 39 +break; +case 17:return 30 +break; +case 18:return 8 +break; +case 19:return 9 +break; +case 20:return 16 +break; +case 21:return 58 +break; +case 22:return 54 +break; +case 23:return 55 +break; +case 24:return 56 +break; +case 25:return '[' +break; +case 26:return ']' +break; +case 27:return 45 +break; +case 28: this.begin('DoubleQuotedString'); this.string = ''; +break; +case 29: this.begin('SingleQuotedString'); this.string = ''; +break; +case 30:this.begin('QuotedStringEscape'); +break; +case 31: yy_.yytext = this.string; this.string = undefined; this.popState(); return 51; +break; +case 32: yy_.yytext = this.string; this.string = undefined; this.popState(); return 51; +break; +case 33: /* The newlines are there because we can span strings across lines using \ */ + switch (yy_.yytext) { + case '\r\n': + case '\n': break; + case 'b': this.string += '\b'; break; + case 'n': this.string += '\n'; break; + case 'r': this.string += '\r'; break; + case 't': this.string += '\t'; break; + case "'": this.string += "'"; break; + case '"': this.string += '"'; break; + case '\\': this.string += '\\'; break; + default: this.string += '\\' + $1; break; + } + + this.popState(); + +break; +case 34:this.string += yy_.yytext; +break; +case 35:this.string += yy_.yytext; +break; +case 36:return 60 /* TODO: non-ASCII identifiers */ +break; +case 37:return 52 /* 3.1, 3.1e-7 */ +break; +case 38:return 53 +break; +case 39:return 31 +break; +case 40:return 32 +break; +case 41:return 33 +break; +case 42:return 34 +break; +case 43:return 35 +break; +case 44:return 40 +break; +case 45:return 44 +break; +case 46:return 43 +break; +case 47:return 42 +break; +case 48:return 41 +break; +case 49:return 36 +break; +case 50:return 37 +break; +case 51:return 38 +break; +case 52:return 21 +break; +case 53:return 22 +break; +case 54:return 49 +break; +case 55:return 50 +break; +case 56:return 5 +break; +case 57:return 'INVALID' +break; +} +}, +rules: [/^(?:\/\/([^\n\r]*))/,/^(?:\/\*([\u0000-\uffff]*?)\*\/)/,/^(?:\s+)/,/^(?:function\b)/,/^(?:return\s*\n)/,/^(?:return\b)/,/^(?:if\b)/,/^(?:else\b)/,/^(?:while\b)/,/^(?:for\b)/,/^(?:case\b)/,/^(?:default\b)/,/^(?:new\b)/,/^(?:break\b)/,/^(?:continue\b)/,/^(?:var\b)/,/^(?:===)/,/^(?:=)/,/^(?:\{)/,/^(?:\})/,/^(?:;)/,/^(?:,)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:\[\])/,/^(?:\[)/,/^(?:\])/,/^(?:\.)/,/^(?:")/,/^(?:')/,/^(?:\\)/,/^(?:")/,/^(?:')/,/^(?:(.|\r\n|\n))/,/^(?:[^"\\]*)/,/^(?:[^'\\]*)/,/^(?:[A-Za-z_][A-Za-z0-9_]*)/,/^(?:[0-9]+(\.[0-9]+)?([eE][\-+]?[0-9]+)?\b)/,/^(?:[0-9]+\b)/,/^(?:\+)/,/^(?:-)/,/^(?:\*)/,/^(?:\/)/,/^(?:%)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:<)/,/^(?:>)/,/^(?:!)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\()/,/^(?:\))/,/^(?:\?)/,/^(?::)/,/^(?:$)/,/^(?:.)/], +conditions: {"QuotedStringEscape":{"rules":[33],"inclusive":false},"SingleQuotedString":{"rules":[30,32,35],"inclusive":false},"DoubleQuotedString":{"rules":[30,31,34],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer;parser.lexer.options.ranges = true; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); + + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = parserWeek8; +exports.Parser = parserWeek8.Parser; +exports.parse = function () { return parserWeek8.parse.apply(parserWeek8, arguments); }; +exports.main = function commonjsMain(args) { + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); +}; +if (typeof module !== 'undefined' && require.main === module) { + exports.main(process.argv.slice(1)); +} +} \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-8.js.patch b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-8.js.patch new file mode 100644 index 000000000..f1ea1f184 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/lib/interpreter/parser-week-8.js.patch @@ -0,0 +1,11 @@ +--- parser-week-8 copy.js 2015-09-17 19:42:28.000000000 +0800 ++++ parser-week-8.js 2015-09-17 19:45:11.000000000 +0800 +@@ -360,7 +360,7 @@ + }}; + + /* lib/parser/includes/nodes.js*/ +-var Nodes = require('lib/parser/nodes'); ++var Nodes = require('./nodes'); + ; + + /* generated by jison-lex 0.3.4 */ diff --git a/src/stdlib/metacircular-interpreter/count/readme.md b/src/stdlib/metacircular-interpreter/count/readme.md new file mode 100644 index 000000000..f78a10363 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/readme.md @@ -0,0 +1,7 @@ +# Token Counting + +This directory contains a script for counting the number of tokens in JediScript programs, mainly for scoring purposes in contests. + +Only a single function, `count`, is exposed. It takes a JediScript program in the form of a string and returns a JavaScript object containing token counts, names, and source text of all top-level JediScript functions found therein. + +It depends on tweaked versions of the JediScript runtime parsers, found in `lib/interpreter`. To change the parser used, modify `count-tokens.js`. The default parser is week 13's. diff --git a/src/stdlib/metacircular-interpreter/count/runes.js b/src/stdlib/metacircular-interpreter/count/runes.js new file mode 100644 index 000000000..86312c92d --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/runes.js @@ -0,0 +1,53 @@ +// --- UPDATE HERE --- +var results = [{"entry":"advay-pal-0.gif","score":33.333},{"entry":"ang-ray-yan-1.gif","score":80},{"entry":"cao-wei-0.gif","score":57.778},{"entry":"chan-yu-feng-0.gif","score":63.333},{"entry":"chan-yu-feng-1.gif","score":72.222},{"entry":"chan-yu-feng-2.gif","score":86.667},{"entry":"chia-hui-yim-0.gif","score":25.455},{"entry":"david-jonathan-ten-0.gif","score":70.714},{"entry":"derek-nam-0.gif","score":67.5},{"entry":"duan-yichen-0.gif","score":55.385},{"entry":"gerald-wong-0.gif","score":41.429},{"entry":"goh-yi-rui-0.gif","score":65.556},{"entry":"herbert-ilhan-tanujaya-0.gif","score":50.769},{"entry":"herbert-ilhan-tanujaya-2.gif","score":62.727},{"entry":"irvin-lim-0.gif","score":63.333},{"entry":"jamos-tay-0.gif","score":56.667},{"entry":"jamos-tay-1.gif","score":80},{"entry":"jiayee-0.gif","score":60},{"entry":"kenneth-tan-xin-you-0.gif","score":62.727},{"entry":"kian-jia-ren-0.gif","score":74.167},{"entry":"kian-jia-ren-1.gif","score":58},{"entry":"kian-jia-ren-2.gif","score":53},{"entry":"le-minh-duc-0.gif","score":51},{"entry":"le-minh-duc-1.gif","score":50},{"entry":"le-minh-duc-2.gif","score":30},{"entry":"lee-yan-hwa-0.gif","score":42.5},{"entry":"leon-mak-0.gif","score":47.273},{"entry":"leon-mak-1.gif","score":47.778},{"entry":"leon-mak-2.gif","score":36.923},{"entry":"li-kai-0.gif","score":77.5},{"entry":"li-kai-1.gif","score":56.667},{"entry":"li-kai-2.gif","score":61.667},{"entry":"li-shuang-0.gif","score":30},{"entry":"lim-jie-0.gif","score":35},{"entry":"loh-jia-shun-kenneth-0.gif","score":71.538},{"entry":"loh-jia-shun-kenneth-1.gif","score":61.25},{"entry":"loh-jia-shun-kenneth-2.gif","score":52.5},{"entry":"louis-tan-jun-an-1.gif","score":52.308},{"entry":"mohd-irfan-0.gif","score":24.167},{"entry":"mohd-irfan-1.gif","score":36.25},{"entry":"mohd-irfan-2.gif","score":44.167},{"entry":"ong-qi-yong-0.gif","score":44.444},{"entry":"pang-zheng-yu-2.gif","score":60},{"entry":"ram-janarthan-0.gif","score":57.273},{"entry":"sherina-toh-0.gif","score":82.5},{"entry":"shi-xiyue-2.gif","score":60},{"entry":"syed-abdullah-0.gif","score":34},{"entry":"tang-yew-siang-0.gif","score":64},{"entry":"tang-yew-siang-1.gif","score":56},{"entry":"tang-yew-siang-2.gif","score":76.667},{"entry":"wong-kang-fei-0.gif","score":84.167},{"entry":"wong-kang-fei-1.gif","score":77.5},{"entry":"wong-kang-fei-2.gif","score":76.25},{"entry":"xiao-pu-1.gif","score":69.286},{"entry":"yu-peng-chua-0.gif","score":58.571},{"entry":"yuan-yuchuan-0.gif","score":55.556},{"entry":"zhang-hanming-1.gif","score":67.5},{"entry":"zhuolin-zuo-0.gif","score":40.769},{"entry":"zhuolin-zuo-1.gif","score":52.5},{"entry":"zhuolin-zuo-2.gif","score":48.462}]; +var folder = '3d'; // download and extract tarball, here solutions are in ./3d/ +var extension = '.gif'; +// --- UPDATE ABOVE -- + +var fs = require('fs'); +var count = require('./count-tokens').count; + +var entries = fs.readdirSync(folder); + +var finalScore = {}; + + +for (var i = 0; i < results.length; i ++) { + finalScore[results[i].entry] = {"votes": results[i].score}; +} + +for (var i = 0; i < entries.length; i ++) { + try { + var counted = count(fs.readFileSync(folder + '/' + entries[i], 'utf8')); + } catch (e) { + console.log(entries[i]); + console.log(e); + continue; + } + var filename = getImageName(entries[i]); + for (var j = 0; j < counted.length; j++) { + var entryName = filename + '-' + getEntryId(counted[j].name) + extension; + if (finalScore[entryName] != undefined) { + finalScore[entryName].count = counted[j].count; + finalScore[entryName].score = finalScore[entryName].votes - + Math.pow(2, counted[j].count / 50); + } + } +} + +for (var entry in finalScore) { + if (finalScore.hasOwnProperty(entry)) { + console.log(entry + '\t' + finalScore[entry].votes + '\t' + + finalScore[entry].count + '\t' + finalScore[entry].score); + }; +} + +function getImageName(filename) { + var start = 4; + var end = filename.length - 21; + return filename.substring(start, end); +} + +function getEntryId(name) { + return name.substring(name.length - 1, name.length); +} \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/count/shouldbe36.js b/src/stdlib/metacircular-interpreter/count/shouldbe36.js new file mode 100644 index 000000000..daf82517c --- /dev/null +++ b/src/stdlib/metacircular-interpreter/count/shouldbe36.js @@ -0,0 +1,7 @@ +function martin_henz_3d_contest_0() { + // hollusion + function favorite(index) { + return index === 0 ? heart_bb : black_bb; + } + return overlay(favorite(0), favorite(1)); // I'm gonna win this +} diff --git a/src/stdlib/metacircular-interpreter/envsetup.bat b/src/stdlib/metacircular-interpreter/envsetup.bat new file mode 100644 index 000000000..0b4f1ce83 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/envsetup.bat @@ -0,0 +1,5 @@ +npm install --global gcc-rest jison markup-js node-zip nomnom +npm link gcc-rest jison markup-js node-zip nomnom +patch -i jison.patch node_modules\jison\lib\jison.js + +node generate.js --environment diff --git a/src/stdlib/metacircular-interpreter/envsetup.sh b/src/stdlib/metacircular-interpreter/envsetup.sh new file mode 100755 index 000000000..ffc05322d --- /dev/null +++ b/src/stdlib/metacircular-interpreter/envsetup.sh @@ -0,0 +1,4 @@ +npm install gcc-rest jison markup-js node-zip nomnom +patch -i jison.patch node_modules/jison/lib/jison.js + +node generate.js --environment diff --git a/src/stdlib/metacircular-interpreter/generate.js b/src/stdlib/metacircular-interpreter/generate.js new file mode 100644 index 000000000..221292bdb --- /dev/null +++ b/src/stdlib/metacircular-interpreter/generate.js @@ -0,0 +1,349 @@ +/* + * Generate.js + * Joel Low + * + * Generates source files from template files. + */ + +var fs = require('fs'), + gcc = require('gcc-rest'), + http = require('http'), + Jison = require('jison'), + Mark = require('markup-js/src/markup'), + zip = require('node-zip'), + nomnom = require('nomnom'), + IO = require('./lib/util/io'); + +//Constants +var jqueryLatestPath = '/jquery-latest.js'; +var jqueryLatestMinPath = '/jquery-latest.min.js'; +var jqueryLatestUrl = 'http://code.jquery.com' + jqueryLatestPath; + +//Set Closure Compiler parameters +gcc.params({ + output_info : ['compiled_code', 'errors', 'warnings', 'statistics'], + language : 'ECMASCRIPT5', + compilation_level: 'ADVANCED_OPTIMIZATIONS', + warning_level : 'VERBOSE', + externs_url : jqueryLatestUrl +}); + +//Replace code before compiling +gcc.replace(/'use strict';/g, ''); + +nomnom.script('generate'). + option('environment', { + flag: true, + help: 'Generates the JavaScript source files for developing this ' + + 'distribution from the templates.' + }). + option('package', { + help: 'Generates a source distribution for students, with JediScript ' + + 'week WEEK support.', + metavar: 'WEEK' + }). + option('interpreter', { + help: 'Generates just the interpreter script, with JediScript week WEEK ' + + 'support. This is to generate a script for publishing within ' + + 'JFDI\'s CodeEval framework', + metavar: 'WEEK' + }). + option('debug', { + help: 'Used together with --package to generate the distribution ' + + 'without minifying the output.', + flag: true + }). + option('native', { + help: 'Used together with --package to generate packages which only ' + + 'do syntax checking on input.', + flag: true + }). + option('without_jquery', { + help: 'Excludes jQuery from the package, use this if jQuery will be ' + + 'provided by other means.', + flag: true + }); + +exports.main = function() { + args = nomnom.parse(); + if (args.environment) { + generateEnvironment(); + } else if (args.package) { + generatePackage(args.package, args.debug, args.native, args.without_jquery); + } else if (args.interpreter) { + generateInterpreter(args.interpreter, args.debug, args.native, args.without_jquery); + } else { + console.error("No operation specified."); + console.error(nomnom.getUsage()); + IO.exit(1); + } +} + +/** + * Renders a given template. + * + * @param string source The path to the template file, relative to the current + * working directory. + * @param object context An object containing the variables used in the template. + * @return string The rendered template file. + */ +function renderTemplate(source, context) { + var template = IO.read(IO.join(IO.cwd(), source)); + return Mark.up(template, context); +} + +/** + * Renders a given template to file. + * + * @param string source The path to the template file, relative to the current + * working directory. + * @param string dest The path where the rendered template will be saved, + * relative to the current working directory. + * @param object context An object containing the variables used in the template. + */ +function renderTemplateToFile(source, dest, context) { + IO.write(IO.join(IO.cwd(), dest), renderTemplate(source, context)); +} + +function generateEnvironment() { + var maxWeek = 15; + + //First generate the parser for the given week. + console.log("Generating parser..."); + var parserRendered = renderTemplate("lib/interpreter/parser.jison.tpl", { + week: maxWeek + }); + IO.write(IO.join(IO.cwd(), "lib/interpreter/parser.jison"), parserRendered); + var generator = new Jison.Generator(parserRendered, {}); + IO.write(IO.join(IO.cwd(), "lib/interpreter/parser.js"), generator.generate()); + + //Generate the list library for the given week. + // console.log("Generating list library..."); + // renderTemplateToFile("../list.js.tpl", "../list.js", { + // week: maxWeek + // }); + + // //Generate the object-oriented programming library + // console.log("Generating Object-Oriented Programming library..."); + // renderTemplateToFile("../object.js.tpl", "../object.js", { + // week: maxWeek + // }); + + // //Generate the streams library + // console.log("Generating streams library..."); + // renderTemplateToFile("../stream.js.tpl", "../stream.js", { + // week: maxWeek + // }); + + // //Generate the exports + // console.log("Generating exports..."); + // renderTemplateToFile("lib/exports.js.tpl", "lib/exports.js", { + // week: maxWeek + // }); +} + +function generateInterpreter(week, debug, native, without_jquery, writeBack) { + //Our default write-out + if (!writeBack) { + writeBack = function(code) { + //Merge jQuery with the rest of our code. + code = + (without_jquery ? '' : IO.read(IO.join(IO.cwd(), ".tmp/jquery.js")) + "\n\n") + + code; + + //Build our basename. + var basename = "jediscript-week-" + week; + + //And write-out + IO.write(IO.join(IO.cwd(), basename + ".js"), code); + } + } + + //Create our temporary and output folders + function mkdir(path) { + console.log(path); + try { + fs.statSync(IO.join(IO.cwd(), path)); + } catch (Exception) { + fs.mkdir(IO.join(IO.cwd(), path)); + } + } + mkdir(".tmp"); + mkdir("out"); + mkdir("out/lib"); + + //First generate the parser for the given week. + console.log("Generating parser..."); + var parserRendered = renderTemplate("lib/interpreter/parser.jison.tpl", { + week: week + }); + IO.write(IO.join(IO.cwd(), ".tmp/parser.js.jison"), parserRendered); + var generator = new Jison.Generator(parserRendered, {}); + IO.write(IO.join(IO.cwd(), ".tmp/parser.js"), generator.generate()); + + //Generate the list library for the given week. + // console.log("Generating list library..."); + // renderTemplateToFile("../list.js.tpl", ".tmp/list.js", { + // week: week + // }); + + // //Generate the object-oriented programming library + // console.log("Generating Object-Oriented Programming library..."); + // renderTemplateToFile("../object.js.tpl", ".tmp/object.js", { + // week: week + // }); + + // //Generate the streams library + // console.log("Generating streams library..."); + // renderTemplateToFile("../stream.js.tpl", ".tmp/stream.js", { + // week: week + // }); + + //Generate the exports + // console.log("Generating exports..."); + // renderTemplateToFile("lib/exports.js.tpl", ".tmp/exports.js", { + // week: week + // }); + + //Generate the JediScript thunk library + console.log("Generating bridge..."); + if (!without_jquery) { + renderTemplateToFile("lib/jediscript.js.tpl", ".tmp/jediscript.js", { + week: week, + native: native + }); + } else { + IO.write(IO.join(IO.cwd(), ".tmp/jediscript.js"), ""); + } + + //And get jQuery + if (without_jquery === undefined || !without_jquery) { + console.log("Downloading jQuery..."); + + var options = { + hostname: 'code.jquery.com', + port: 80, + path: debug ? jqueryLatestPath : jqueryLatestMinPath, + method: 'GET' + }; + + http.get(options, function(res) { + var jquery = ""; + res.on("data", function(chunk) { + jquery += chunk; + }); + res.on("end", function() { + IO.write(IO.join(IO.cwd(), ".tmp/jquery.js"), jquery); + + //Indicate the version of jQuery we linked against + var jqueryVersion = / jQuery .*v([0-9.]+)( |$)/im.exec(jquery)[1]; + if (!jqueryVersion) { + console.error("Unknown download: jQuery version could not be " + + "determined."); + IO.exit(1); + } + console.log("Using downloaded jQuery " + jqueryVersion + "."); + gcc.header("// This file was compiled using Google Closure Compiler\n" + + "// and linked against jQuery v" + jqueryVersion + "\n"); + compilePackage(); + }); + }).on("error", function(e) { + console.error("Could not download jQuery: " + e.message); + }); + } else { + gcc.header("// This file was compiled using Google Closure Compiler\n"); + IO.write(IO.join(IO.cwd(), ".tmp/jquery.js"), ""); + compilePackage(); + } + + //Callback function for after jQuery has been downloaded. + function compilePackage() { + if (debug) { + var combined = ''; + var concatOutput = function(path) { + return '//---------------------------------------------------' + + '--------------\n//From file: ' + path + '\n\n' + + IO.read(path) + '\n'; + }; + +// combined += concatOutput(IO.join(IO.cwd(), ".tmp/list.js")); +// combined += concatOutput(IO.join(IO.cwd(), "../misc.js")); +// +// combined += concatOutput(IO.join(IO.cwd(), ".tmp/object.js")); +// combined += concatOutput(IO.join(IO.cwd(), ".tmp/stream.js")); + + combined += concatOutput(IO.join(IO.cwd(), "lib/interpreter/json2.js")); + combined += concatOutput(IO.join(IO.cwd(), ".tmp/parser.js")); + combined += concatOutput(IO.join(IO.cwd(), "lib/interpreter/interpreter.js")); + combined += concatOutput(IO.join(IO.cwd(), ".tmp/jediscript.js")); + + //Prevent these symbols from being renamed + combined += concatOutput(IO.join(IO.cwd(), ".tmp/exports.js")); + writeBack(combined); + } else { + console.log("Compiling using the Google Closure Compiler..."); + + //Compile using Google Closure: + //Include the required libraries for functionality. + // gcc.addFile(IO.join(IO.cwd(), ".tmp/list.js")); + // gcc.addFile(IO.join(IO.cwd(), "../misc.js")); + + // gcc.addFile(IO.join(IO.cwd(), ".tmp/object.js")); + // gcc.addFile(IO.join(IO.cwd(), ".tmp/stream.js")); + + gcc.addFile(IO.join(IO.cwd(), "lib/interpreter/json2.js")); + gcc.addFile(IO.join(IO.cwd(), ".tmp/parser.js")); + gcc.addFile(IO.join(IO.cwd(), "lib/interpreter/interpreter.js")); + gcc.addFile(IO.join(IO.cwd(), ".tmp/jediscript.js")); + + //Prevent these symbols from being renamed + gcc.addFile(IO.join(IO.cwd(), ".tmp/exports.js")); + + //Compile and write output to compiled.js + gcc.compile(writeBack); + } + } +} + +function generatePackage(week, debug, native, without_jquery) { + generateInterpreter(week, debug, native, without_jquery, writeOutput); + + //Callback function after our sources have been compiled by GCC. + function writeOutput(code) { + //Merge jQuery with the rest of our code. + IO.write(IO.join(IO.cwd(), "out/lib/jediscript.js"), + IO.read(IO.join(IO.cwd(), ".tmp/jquery.js")) + "\n\n" + + code); + + //Zip the package up. + var package = new zip(); + var basename = "JediScript Week " + week; + package = package.folder(basename); + + function zipFolder(folder, package) { + var files = fs.readdirSync(folder); + for (var i = 0; i != files.length; ++i) { + var path = IO.join(folder, files[i]); + var stat = fs.statSync(path); + if (stat.isDirectory()) { + zipFolder(path, package.folder(files[i])); + } else { + package.file(files[i], IO.read(path, "base64"), { + base64: true + }); + } + } + } + zipFolder(IO.join(IO.cwd(), "out"), package); + + + IO.write(IO.join(IO.cwd(), basename + ".zip"), + new Buffer(package.generate({ + base64: true, + compression: "DEFLATE" + }), 'base64')); + } +} + +if (typeof process !== "undefined" || require.main === module) + exports.main(); diff --git a/src/stdlib/metacircular-interpreter/jison.patch b/src/stdlib/metacircular-interpreter/jison.patch new file mode 100644 index 000000000..f60ef686a --- /dev/null +++ b/src/stdlib/metacircular-interpreter/jison.patch @@ -0,0 +1,11 @@ +--- jison/lib/jison.js 2013-09-02 07:15:05.000000000 +0800 ++++ jison/lib/jison.js 2014-08-16 09:23:01.418143400 +0800 +@@ -1204,6 +1204,8 @@ + function parseError (str, hash) { + if (hash.recoverable) { + this.trace(str); ++ } else if (hash.loc && hash.line) { ++ throw new SyntaxError(str, hash.loc, hash.line); + } else { + throw new Error(str); + } diff --git a/src/stdlib/metacircular-interpreter/lib/exports.js b/src/stdlib/metacircular-interpreter/lib/exports.js new file mode 100644 index 000000000..e13670e52 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/lib/exports.js @@ -0,0 +1,147 @@ +/* + * This file defines the symbols which are accessible from student code. + * + * This also will register the given functions with the interpreter. + */ + +/** + * Defines a symbol to be usable within the interpreter, and also globally in + * the event of compiler mangling. + * + * @param string name The name of the symbol to be exported. + * @param mixed symbol The symbol (function, variable, etc) to be exported. + * @param string params The parameter list to show in the obfuscated function. + * Used only when obfuscated is true. + * @param boolean obfuscated Whether to obfuscate the definition of functions. + * Defaults to true. + */ +function export_symbol(name, symbol, params, obfuscated) { + if (symbol === undefined) { + symbol = window[name]; + } + window[name] = symbol; + if (is_function(symbol)) { + if (obfuscated === undefined || obfuscated) { + parser_register_native_function(name, obfuscate(symbol, name, params)); + } else { + parser_register_native_function(name, symbol); + } + } else { + parser_register_native_variable(name, symbol); + } +} + +//Reserve '$' for jQuery when jQuery library itself is not included +window['$'] = $; +//Preserve export_symbol for use by missions (so they can export APIs and +//variables to student code) +window['exportSymbol'] = export_symbol; // Remove in AY2015/2016. +window['export_symbol'] = export_symbol; +window['parse_and_evaluate'] = parse_and_evaluate; +window['parser_register_debug_handler'] = parser_register_debug_handler; + +//Core language +export_symbol("Math", Math); + +export_symbol("String", String); + + +//Misc.js +export_symbol('is_null', is_null, "(x)"); +export_symbol('is_number', is_number, "(x)"); +export_symbol('is_string', is_string, "(x)"); +export_symbol('is_boolean', is_boolean, "(x)"); +export_symbol('is_object', is_object, "(x)"); +export_symbol('is_function', is_function, "(x)"); +export_symbol('is_NaN', is_NaN, "(x)"); +export_symbol('has_own_property', has_own_property); +export_symbol('is_array', is_array, "(x)"); +export_symbol('runtime', runtime); +export_symbol('error', error, "(message)"); +export_symbol('newline', newline); +export_symbol('display', display, "(message)"); +export_symbol('random', random); +export_symbol('timed', timed, "(f)"); +export_symbol('read', read); +export_symbol('write', write); + +export_symbol('parse', parse, "(source_text)"); +export_symbol('apply_in_underlying_javascript', apply_in_underlying_javascript); + + + +//List.js +export_symbol('array_test', array_test); +export_symbol('pair', pair, "(x, y)"); +export_symbol('is_pair', is_pair, "(x)"); +export_symbol('head', head, "(xs)"); +export_symbol('tail', tail, "(xs)"); +export_symbol('is_empty_list', is_empty_list, "(xs)"); +export_symbol('is_list', is_list, "(x)"); +export_symbol('list', list); +export_symbol('list_to_vector', list_to_vector, "(xs)"); +export_symbol('vector_to_list', vector_to_list, "(v)"); +export_symbol('length', length, "(xs)"); +export_symbol('map', map, "(f, xs)"); +export_symbol('build_list', build_list, "(n, f)"); +export_symbol('for_each', for_each, "(f, xs)"); +export_symbol('list_to_string', list_to_string, "(xs)"); +export_symbol('reverse', reverse, "(xs)"); +export_symbol('append', append, "(xs, ys)"); +export_symbol('member', member, "(v, xs)"); +export_symbol('remove', remove, "(v, xs)"); +export_symbol('remove_all', remove_all, "(v, xs)"); +export_symbol('equal', equal, "(x, y)"); + +export_symbol('assoc', assoc, "(v, xs)"); + +export_symbol('filter', filter, "(pred, xs)"); +export_symbol('enum_list', enum_list, "(start, end)"); +export_symbol('list_ref', list_ref, "(xs, n)"); +export_symbol('accumulate', accumulate, "(op, initial, xs)"); + +export_symbol('set_head', set_head, "(xs, x)"); +export_symbol('set_tail', set_tail, "(xs, x)"); + + + + +//Object.js +parser_register_native_function('Object', Object); +export_symbol('is_instance_of', is_instance_of, "(a, b)"); + + + +//Streams.js +export_symbol('stream_tail', stream_tail, "(xs)"); +export_symbol('is_stream', is_stream, "(xs)"); +export_symbol('list_to_stream', list_to_stream, "(xs)"); +export_symbol('stream_to_list', stream_to_list, "(xs)"); +export_symbol('stream', stream); +export_symbol('stream_length', stream_length, "(xs)"); +export_symbol('stream_map', stream_map, "(f, xs)"); +export_symbol('build_stream', build_stream, "(n, f)"); +export_symbol('stream_for_each', stream_for_each, "(f, xs)"); +export_symbol('stream_reverse', stream_reverse, "(xs)"); +export_symbol('stream_to_vector', stream_to_vector, "(xs)"); +export_symbol('stream_append', stream_append, "(xs, ys)"); +export_symbol('stream_member', stream_member, "(v, xs)"); +export_symbol('stream_remove', stream_remove, "(v, xs)"); +export_symbol('stream_remove_all', stream_remove_all, "(v, xs)"); +export_symbol('stream_filter', stream_filter, "(pred, xs)"); +export_symbol('enum_stream', enum_stream, "(start, end)"); +export_symbol('integers_from', integers_from, "(n)"); +export_symbol('eval_stream', eval_stream, "(xs, n)"); +export_symbol('stream_ref', stream_ref, "(xs, n)"); + + + +//Interpreter.js +export_symbol('parse_and_evaluate', parse_and_evaluate); +export_symbol('parser_register_native_function', parser_register_native_function); +export_symbol('parser_register_native_variable', parser_register_native_variable); +export_symbol('is_object', is_object); +export_symbol('JSON', JSON); +export_symbol('Function', Function); +export_symbol('RegExp', RegExp); + diff --git a/src/stdlib/metacircular-interpreter/lib/exports.js.tpl b/src/stdlib/metacircular-interpreter/lib/exports.js.tpl new file mode 100644 index 000000000..91e61bd5e --- /dev/null +++ b/src/stdlib/metacircular-interpreter/lib/exports.js.tpl @@ -0,0 +1,147 @@ +/* + * This file defines the symbols which are accessible from student code. + * + * This also will register the given functions with the interpreter. + */ + +/** + * Defines a symbol to be usable within the interpreter, and also globally in + * the event of compiler mangling. + * + * @param string name The name of the symbol to be exported. + * @param mixed symbol The symbol (function, variable, etc) to be exported. + * @param string params The parameter list to show in the obfuscated function. + * Used only when obfuscated is true. + * @param boolean obfuscated Whether to obfuscate the definition of functions. + * Defaults to true. + */ +function export_symbol(name, symbol, params, obfuscated) { + if (symbol === undefined) { + symbol = window[name]; + } + window[name] = symbol; + if (is_function(symbol)) { + if (obfuscated === undefined || obfuscated) { + parser_register_native_function(name, obfuscate(symbol, name, params)); + } else { + parser_register_native_function(name, symbol); + } + } else { + parser_register_native_variable(name, symbol); + } +} + +//Reserve '$' for jQuery when jQuery library itself is not included +window['$'] = $; +//Preserve export_symbol for use by missions (so they can export APIs and +//variables to student code) +window['exportSymbol'] = export_symbol; // Remove in AY2015/2016. +window['export_symbol'] = export_symbol; +window['parse_and_evaluate'] = parse_and_evaluate; +window['parser_register_debug_handler'] = parser_register_debug_handler; + +//Core language +export_symbol("Math", Math); +{{if week|ormore>6}} +export_symbol("String", String); +{{/if}} + +//Misc.js +export_symbol('is_null', is_null, "(x)"); +export_symbol('is_number', is_number, "(x)"); +export_symbol('is_string', is_string, "(x)"); +export_symbol('is_boolean', is_boolean, "(x)"); +export_symbol('is_object', is_object, "(x)"); +export_symbol('is_function', is_function, "(x)"); +export_symbol('is_NaN', is_NaN, "(x)"); +export_symbol('has_own_property', has_own_property); +export_symbol('is_array', is_array, "(x)"); +export_symbol('runtime', runtime); +export_symbol('error', error, "(message)"); +export_symbol('newline', newline); +export_symbol('display', display, "(message)"); +export_symbol('random', random); +export_symbol('timed', timed, "(f)"); +export_symbol('read', read); +export_symbol('write', write); +{{if week|ormore>12}} +export_symbol('parse', parse, "(source_text)"); +export_symbol('apply_in_underlying_javascript', apply_in_underlying_javascript); +{{/if}} + +{{if week|ormore>5}} +//List.js +export_symbol('array_test', array_test); +export_symbol('pair', pair, "(x, y)"); +export_symbol('is_pair', is_pair, "(x)"); +export_symbol('head', head, "(xs)"); +export_symbol('tail', tail, "(xs)"); +export_symbol('is_empty_list', is_empty_list, "(xs)"); +export_symbol('is_list', is_list, "(x)"); +export_symbol('list', list); +export_symbol('list_to_vector', list_to_vector, "(xs)"); +export_symbol('vector_to_list', vector_to_list, "(v)"); +export_symbol('length', length, "(xs)"); +export_symbol('map', map, "(f, xs)"); +export_symbol('build_list', build_list, "(n, f)"); +export_symbol('for_each', for_each, "(f, xs)"); +export_symbol('list_to_string', list_to_string, "(xs)"); +export_symbol('reverse', reverse, "(xs)"); +export_symbol('append', append, "(xs, ys)"); +export_symbol('member', member, "(v, xs)"); +export_symbol('remove', remove, "(v, xs)"); +export_symbol('remove_all', remove_all, "(v, xs)"); +export_symbol('equal', equal, "(x, y)"); +{{if week|ormore>8}} +export_symbol('assoc', assoc, "(v, xs)"); +{{/if}} +export_symbol('filter', filter, "(pred, xs)"); +export_symbol('enum_list', enum_list, "(start, end)"); +export_symbol('list_ref', list_ref, "(xs, n)"); +export_symbol('accumulate', accumulate, "(op, initial, xs)"); +{{if week|ormore>8}} +export_symbol('set_head', set_head, "(xs, x)"); +export_symbol('set_tail', set_tail, "(xs, x)"); +{{/if}} +{{/if}} + +{{if week|ormore>10}} +//Object.js +parser_register_native_function('Object', Object); +export_symbol('is_instance_of', is_instance_of, "(a, b)"); +{{/if}} + +{{if week|ormore>11}} +//Streams.js +export_symbol('stream_tail', stream_tail, "(xs)"); +export_symbol('is_stream', is_stream, "(xs)"); +export_symbol('list_to_stream', list_to_stream, "(xs)"); +export_symbol('stream_to_list', stream_to_list, "(xs)"); +export_symbol('stream', stream); +export_symbol('stream_length', stream_length, "(xs)"); +export_symbol('stream_map', stream_map, "(f, xs)"); +export_symbol('build_stream', build_stream, "(n, f)"); +export_symbol('stream_for_each', stream_for_each, "(f, xs)"); +export_symbol('stream_reverse', stream_reverse, "(xs)"); +export_symbol('stream_to_vector', stream_to_vector, "(xs)"); +export_symbol('stream_append', stream_append, "(xs, ys)"); +export_symbol('stream_member', stream_member, "(v, xs)"); +export_symbol('stream_remove', stream_remove, "(v, xs)"); +export_symbol('stream_remove_all', stream_remove_all, "(v, xs)"); +export_symbol('stream_filter', stream_filter, "(pred, xs)"); +export_symbol('enum_stream', enum_stream, "(start, end)"); +export_symbol('integers_from', integers_from, "(n)"); +export_symbol('eval_stream', eval_stream, "(xs, n)"); +export_symbol('stream_ref', stream_ref, "(xs, n)"); +{{/if}} + +{{if week|ormore>12}} +//Interpreter.js +export_symbol('parse_and_evaluate', parse_and_evaluate); +export_symbol('parser_register_native_function', parser_register_native_function); +export_symbol('parser_register_native_variable', parser_register_native_variable); +export_symbol('is_object', is_object); +export_symbol('JSON', JSON); +export_symbol('Function', Function); +export_symbol('RegExp', RegExp); +{{/if}} diff --git a/src/stdlib/metacircular-interpreter/lib/interpreter/interpreter.js b/src/stdlib/metacircular-interpreter/lib/interpreter/interpreter.js new file mode 100644 index 000000000..154ea4f96 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/lib/interpreter/interpreter.js @@ -0,0 +1,1050 @@ +/** + * Parses the given string and returns the evaluated result. + * + * @param String string The string to evaluate. + * @returns The result of evaluating the given expression/program text. + */ +var parse_and_evaluate = undefined; +/** + * Registers a native JavaScript function for use within the interpreter. + * + * @param String name The name of the function to expose. + * @param Function func The Function to export. + */ +var parser_register_native_function = undefined; +/** + * Registers a native JavaScript variable for use within the interpreter. + * + * @param String name The name of the variable to expose. + * @param Object object The Object to export. + */ +var parser_register_native_variable = undefined; +/** + * Registers a native JavaScript handler for when a debug context is changed. + * + * @param Function handler The callback handling all such requests. This + * callback accepts one argument, the line of the + * call. If this is null, then there is no debug + * context active. + */ +var parser_register_debug_handler = undefined; + +(function() { +function stmt_line(stmt) { + return stmt.line; +} +function is_tagged_object(stmt,the_tag) { + return is_object(stmt) && + stmt.tag === the_tag; +} + +function is_self_evaluating(stmt) { + return is_number(stmt) || + is_string(stmt) || + is_boolean(stmt); +} + +function is_empty_list_statement(stmt) { + return is_tagged_object(stmt,"empty_list"); +} + +function evaluate_empty_list_statement(input_text,stmt,env) { + return []; +} + +function make_undefined_value() { + return undefined; +} + +function is_undefined_value(value) { + return value === undefined; +} + +function is_variable(stmt) { + return is_tagged_object(stmt,"variable"); +} + +function variable_name(stmt) { + return stmt.name; +} + +function enclosing_environment(env) { + return tail(env); +} +function first_frame(env) { + return head(env); +} +var the_empty_environment = []; +function is_empty_environment(env) { + return is_empty_list(env); +} +function enclose_by(frame,env) { + return pair(frame,env); +} + +function lookup_variable_value(variable,env) { + function env_loop(env) { + if (is_empty_environment(env)) { + error("Unbound variable: " + variable); + } else if (has_binding_in_frame(variable,first_frame(env))) { + return first_frame(env)[variable]; + } else { + return env_loop(enclosing_environment(env)); + } + } + var val = env_loop(env); + return val; +} + +function is_assignment(stmt) { + return is_tagged_object(stmt,"assignment"); +} +function assignment_variable(stmt) { + return stmt.variable; +} +function assignment_value(stmt) { + return stmt.value; +} + +function set_variable_value(variable,value,env) { + function env_loop(env) { + if (is_empty_environment(env)) { + error("Undeclared variable in assignment: " + variable_name(variable)); + } else if (has_binding_in_frame(variable_name(variable),first_frame(env))) { + add_binding_to_frame(variable_name(variable),value,first_frame(env)); + } else { + env_loop(enclosing_environment(env)); + } + } + env_loop(env); + return undefined; +} + +function evaluate_assignment(input_text,stmt,env) { + var value = evaluate(input_text,assignment_value(stmt),env); + set_variable_value(assignment_variable(stmt), + value, + env); + return value; +} + +function is_array_expression(stmt) { + return is_tagged_object(stmt,"arrayinit"); +} + +function array_expression_elements(stmt) { + return stmt.elements; +} + +function evaluate_array_expression(input_text,stmt, env) { + var evaluated_elements = map(function(p) { + return evaluate(input_text,p,env); + }, + array_expression_elements(stmt)); + + return list_to_vector(evaluated_elements); +} + +function is_object_expression(stmt) { + return is_tagged_object(stmt,"object"); +} + +function object_expression_pairs(stmt) { + return stmt.pairs; +} + +function evaluate_object_expression(input_text,stmt,env) { + var evaluated_pairs = map(function(p) { + return pair(evaluate(input_text,head(p),env), + evaluate(input_text,tail(p),env)); + }, + object_expression_pairs(stmt)); + + function make_object(pairs_to_handle, constructed_object) { + if (is_empty_list(pairs_to_handle)) { + return constructed_object; + } else { + constructed_object[head(head(pairs_to_handle))] = + tail(head(pairs_to_handle)); + return make_object(tail(pairs_to_handle), constructed_object); + } + } + return make_object(evaluated_pairs,{}); +} + + + +function is_property_assignment(stmt) { + return is_tagged_object(stmt,"property_assignment"); +} + +function property_assignment_object(stmt) { + return stmt.object; +} + +function property_assignment_property(stmt) { + return stmt.property; +} + +function property_assignment_value(stmt) { + return stmt.value; +} + +function evaluate_property_assignment(input_text,stmt,env) { + var obj = evaluate(input_text,property_assignment_object(stmt),env); + var property = evaluate(input_text,property_assignment_property(stmt),env); + var value = evaluate(input_text,property_assignment_value(stmt),env); + obj[property] = value; + return value; +} + +function is_property_access(stmt) { + var x = is_tagged_object(stmt,"property_access"); + return x; +} + +function property_access_object(stmt) { + return stmt.object; +} + +function property_access_property(stmt) { + return stmt.property; +} + +/** + * Evaluates a property access statement. + */ +function evaluate_property_access(input_text,statement,env) { + var objec = evaluate(input_text,property_access_object(statement),env); + var property = evaluate(input_text,property_access_property(statement),env); + return evaluate_object_property_access(objec, property); +} + +/** + * Actually does the property access. + */ +function evaluate_object_property_access(object, property) { + var result = object[property]; + + //We need to post-process the return value. Because objects can be native + //we need to marshal native member functions into our primitive tag. + return wrap_native_value(result); +} + +function is_var_definition(stmt) { + return is_tagged_object(stmt,"var_definition"); +} +function var_definition_variable(stmt) { + return stmt.variable; +} +function var_definition_value(stmt) { + return stmt.value; +} + +function make_frame(variables,values) { + if (is_empty_list(variables) && is_empty_list(values)) { + return {}; + } else { + var frame = make_frame(tail(variables),tail(values)); + frame[head(variables)] = head(values); + return frame; + } +} + +function add_binding_to_frame(variable,value,frame) { + frame[variable] = value; + return undefined; +} +function has_binding_in_frame(variable,frame) { + return has_own_property(frame, variable); +} + +function define_variable(variable,value,env) { + var frame = first_frame(env); + return add_binding_to_frame(variable,value,frame); +} + +function evaluate_var_definition(input_text,stmt,env) { + define_variable(var_definition_variable(stmt), + evaluate(input_text,var_definition_value(stmt),env), + env); + return undefined; +} + +function is_if_statement(stmt) { + return is_tagged_object(stmt,"if"); +} +function if_predicate(stmt) { + return stmt.predicate; +} +function if_consequent(stmt) { + return stmt.consequent; +} +function if_alternative(stmt) { + return stmt.alternative; +} + +function is_true(x) { + return ! is_false(x); +} +function is_false(x) { + return x === false || x === 0 || x === "" || is_undefined_value(x) || is_NaN(x); +} + +function is_boolean_operation(stmt) { + return is_tagged_object(stmt, "boolean_op"); +} + +function evaluate_boolean_operation(input_text,stmt, args, env) { + var lhs = evaluate(input_text,list_ref(args, 0), env); + if (operator(stmt) === '||') { + if (lhs) { + return lhs; + } else { + return evaluate(input_text,list_ref(args, 1), env); + } + } else if (operator(stmt) === '&&') { + if (!lhs) { + return lhs; + } else { + return evaluate(input_text,list_ref(args, 1), env); + } + } else { + error("Unknown binary operator: " + operator(stmt), stmt_line(stmt)); + } +} + +function evaluate_if_statement(input_text,stmt,env) { + if (is_true(evaluate(input_text,if_predicate(stmt),env))) { + return evaluate(input_text,if_consequent(stmt),env); + } else { + return evaluate(input_text,if_alternative(stmt),env); + } +} + +function is_ternary_statement(stmt) { + return is_tagged_object(stmt, "ternary"); +} +function ternary_predicate(stmt) { + return stmt.predicate; +} +function ternary_consequent(stmt) { + return stmt.consequent; +} +function ternary_alternative(stmt) { + return stmt.alternative; +} +function evaluate_ternary_statement(input_text,stmt, env) { + if (is_true(evaluate(input_text,ternary_predicate(stmt), env))) { + return evaluate(input_text,ternary_consequent(stmt), env); + } else { + return evaluate(input_text,ternary_alternative(stmt), env); + } +} + +function is_while_statement(stmt) { + return is_tagged_object(stmt, "while"); +} +function while_predicate(stmt) { + return stmt.predicate; +} +function while_statements(stmt) { + return stmt.statements; +} +function evaluate_while_statement(input_text,stmt, env) { + var result = undefined; + while (is_true(evaluate(input_text,while_predicate(stmt), env))) { + var new_result = evaluate(input_text,while_statements(stmt), env); + if (is_return_value(new_result) || + is_tail_recursive_return_value(new_result)) { + return new_result; + } else if (is_break_value(new_result)) { + break; + } else if (is_continue_value(new_result)) { + continue; + } else { + result = new_result; + } + } + return result; +} + +function is_for_statement(stmt) { + return is_tagged_object(stmt, "for"); +} +function for_initialiser(stmt) { + return stmt.initialiser; +} +function for_predicate(stmt) { + return stmt.predicate; +} +function for_finaliser(stmt) { + return stmt.finaliser; +} +function for_statements(stmt) { + return stmt.statements; +} +function evaluate_for_statement(input_text,stmt, env) { + var result = undefined; + for (evaluate(input_text,for_initialiser(stmt), env); + is_true(evaluate(input_text,for_predicate(stmt), env)); + evaluate(input_text,for_finaliser(stmt), env)) { + var new_result = evaluate(input_text,for_statements(stmt), env); + + if (is_return_value(new_result) || + is_tail_recursive_return_value(new_result)) { + return new_result; + } else if (is_break_value(new_result)) { + break; + } else if (is_continue_value(new_result)) { + continue; + } else { + result = new_result; + } + } + return result; +} + +function is_function_definition(stmt) { + return is_tagged_object(stmt,"function_definition"); +} + +function function_definition_name(stmt) { + return stmt.name; +} +function function_definition_parameters(stmt) { + return stmt.parameters; +} +function function_definition_body(stmt) { + return stmt.body; +} +function function_definition_text_location(stmt) { + return stmt.location; +} + +function evaluate_function_definition(input_text,stmt,env) { + return make_function_value( + input_text, + function_definition_name(stmt), + function_definition_parameters(stmt), + function_definition_body(stmt), + function_definition_text_location(stmt), + env); +} +function make_function_value(input_text,name,parameters,body,location,env) { + var result = (new Function("apply", "wrap_native_value", + "return function " + name + "() {\n\ + var args = map(wrap_native_value, vector_to_list(arguments));\n\ + return apply(arguments.callee, args, this);\n\ + }"))(apply, wrap_native_value); + result.tag = "function_value"; + result.parameters = parameters; + result.body = body; + result.source_text = input_text; + result.environment = env; + + var text = get_input_text(input_text,location.start_line, location.start_col, + location.end_line, location.end_col); + result.toString = function() { + return text; + }; + result.toSource = result.toString; + return result; +} +function is_compound_function_value(f) { + return is_tagged_object(f,"function_value"); +} +function function_value_parameters(value) { + return value.parameters; +} +function function_value_body(value) { + return value.body; +} +function function_value_environment(value) { + return value.environment; +} +function function_value_name(value) { + return value.name; +} +function function_value_source_text(value) { + return value.source_text; +} + +function is_construction(stmt) { + return is_tagged_object(stmt, "construction"); +} +function construction_type(stmt) { + return stmt.type; +} +function evaluate_construction_statement(input_text,stmt, env) { + var typename = evaluate(input_text,construction_type(stmt), env); + var type = lookup_variable_value(typename, env); + var result = undefined; + var extraResult = undefined; + if (is_primitive_function(type)) { + result = Object.create(primitive_implementation(type).prototype); + } else { + //TODO: This causes some problems because we add more fields to the prototype of the object. + result = Object.create(type.prototype); + } + + extraResult = apply(type, list_of_values(input_text,operands(stmt),env), result); + + //EcmaScript 5.1 Section 13.2.2 [[Construct]] + if (is_object(extraResult)) { + return extraResult + } else { + return result; + } +} + +function is_sequence(stmt) { + return is_list(stmt); +} +function empty_stmt(stmts) { + return is_empty_list(stmts); +} +function last_stmt(stmts) { + return is_empty_list(tail(stmts)); +} +function first_stmt(stmts) { + return head(stmts); +} +function rest_stmts(stmts) { + return tail(stmts); +} + +function evaluate_sequence(input_text,stmts,env) { + while (!empty_stmt(stmts)) { + var statement_result = evaluate(input_text,first_stmt(stmts), env); + if (last_stmt(stmts)) { + return statement_result; + } else if (is_return_value(statement_result) || + is_tail_recursive_return_value(statement_result)) { + return statement_result; + } else if (is_break_value(statement_result) || + is_continue_value(statement_result)) { + return statement_result; + } else { + stmts = rest_stmts(stmts); + } + } +} + +function is_application(stmt) { + return is_tagged_object(stmt,"application"); +} +function is_object_method_application(stmt) { + return is_tagged_object(stmt,"object_method_application"); +} +function operator(stmt) { + return stmt.operator; +} +function operands(stmt) { + return stmt.operands; +} +function no_operands(ops) { + return is_empty_list(ops); +} +function first_operand(ops) { + return head(ops); +} +function rest_operands(ops) { + return tail(ops); +} +function object(stmt) { + return stmt.object; +} +function object_property(stmt) { + return stmt.property; +} + +function is_primitive_function(fun) { + return is_tagged_object(fun,"primitive"); +} +function primitive_implementation(fun) { + return fun; +} + +// This function is used to map whatever a native JavaScript function returns, +// and tags it such that the interpreter knows what to do with it. +// apply_in_underlying_javascript marshals interpreter to native; this handles +// the other direction. +function wrap_native_value(val) { + if (is_function(val) && val.tag === undefined) { + return make_primitive_function_object(val); + } else { + return val; + } +} +function apply_primitive_function(fun,argument_list,object) { + return wrap_native_value( + apply_in_underlying_javascript.call(object,primitive_implementation(fun), + argument_list) + ); +} + +function extend_environment(vars,vals,base_env) { + var var_length = length(vars); + var val_length = length(vals); + if (var_length === val_length) { + var new_frame = make_frame(vars,vals); + return enclose_by(new_frame,base_env); + } else if (var_length < val_length) { + error("Too many arguments supplied: " + JSON.stringify(vars) + + JSON.stringify(vals)); + } else { + error("Too few arguments supplied: " + JSON.stringify(vars) + + JSON.stringify(vals)); + } +} + +function is_break_statement(stmt) { + return is_tagged_object(stmt, "break_statement"); +} + +function make_break_value() { + return { tag: "break_value" }; +} + +function is_break_value(value) { + return is_tagged_object(value, "break_value"); +} + +function is_continue_statement(stmt) { + return is_tagged_object(stmt, "continue_statement"); +} + +function make_continue_value() { + return { tag: "continue_value" }; +} + +function is_continue_value(value) { + return is_tagged_object(value, "continue_value"); +} + +function is_return_statement(stmt) { + return is_tagged_object(stmt,"return_statement"); +} +function return_statement_expression(stmt) { + return stmt.expression; +} + +function make_return_value(content) { + return { tag: "return_value", content: content }; +} +function is_return_value(value) { + return is_tagged_object(value,"return_value"); +} +function return_value_content(value) { + return value.content; +} +function make_tail_recursive_return_value(fun, args, obj, env) { + return { tag: "tail_recursive_return_value", fun: fun, args: args, obj: obj, env: env }; +} +function is_tail_recursive_return_value(value) { + return is_tagged_object(value, "tail_recursive_return_value"); +} +function tail_recursive_function(value) { + return value.fun; +} +function tail_recursive_arguments(value) { + return value.args; +} +function tail_recursive_object(value) { + return value.obj; +} +function tail_recursive_environment(value) { + return value.env; +} + +function apply(fun,args,obj) { + var result = undefined; + while (result === undefined || is_tail_recursive_return_value(result)) { + if (is_primitive_function(fun)) { + return apply_primitive_function(fun,args,obj); + } else if (is_compound_function_value(fun)) { + if (length(function_value_parameters(fun)) === length(args)) { + var env = extend_environment(function_value_parameters(fun), + args, + function_value_environment(fun)); + if (obj && is_object(obj)) { + add_binding_to_frame("this", obj, first_frame(env)); + } else {} + + //We have to pass in the source text we had at the function evaluation + //time because we might evaluate new functions within and those would + //require original input (since we hold references to the original + //source text) + var result = evaluate(function_value_source_text(fun),function_value_body(fun), env); + if (is_return_value(result)) { + return return_value_content(result); + } else if (is_tail_recursive_return_value(result)) { + fun = tail_recursive_function(result); + args = tail_recursive_arguments(result); + obj = tail_recursive_object(result); + env = tail_recursive_environment(result); + } else if (is_break_value(result) || is_continue_value(result)) { + error("break and continue not allowed outside of function."); + } else { + return undefined; + } + } else { + error('Incorrect number of arguments supplied for function ' + + function_value_name(fun)); + } + } else if (fun === undefined) { + error("Unknown function type for application: undefined"); + } else { + error("Unknown function type for application: " + JSON.stringify(fun), + stmt_line(fun)); + } + } +} + +function list_of_values(input_text,exps,env) { + if (no_operands(exps)) { + return []; + } else { + return pair(evaluate(input_text,first_operand(exps),env), + list_of_values(input_text,rest_operands(exps),env)); + } +} + +var primitive_functions = + list( + //Builtin functions + pair("alert", alert), + pair("prompt", prompt), + pair("parseInt", parseInt), + + //List library functions + pair("pair", pair), + pair("head", head), + pair("tail", tail), + pair("list", list), + pair("length", length), + pair("map", map), + pair("is_empty_list", is_empty_list), + + //Intepreter functions + pair("parse", parse), + pair("error", error), + + //Primitive functions + pair("+", function(x,y) { return x + y; }), + pair("-", function(x,y) { return x - y; }), + pair("*", function(x,y) { return x * y; }), + pair("/", function(x,y) { return x / y; }), + pair("%", function(x,y) { return x % y; }), + pair("===", function(x,y) { return x === y; }), + pair("!==", function(x,y) { return x !== y; }), + pair("<", function(x,y) { return x < y; }), + pair(">", function(x,y) { return x > y; }), + pair("<=", function(x,y) { return x <= y; }), + pair(">=", function(x,y) { return x >= y; }), + pair("!", function(x) { return ! x; }) + ); + +function primitive_function_names() { + return map(function(x) { return head(x); }, + primitive_functions); +} + +function primitive_function_objects() { + return map( + function(f) { + if (!is_compound_function_value(tail(f))) { + return make_primitive_function_object(tail(f)); + } else { + return tail(f); + } + }, + primitive_functions); +} + +function make_primitive_function_object(primitive_function) { + if (primitive_function.tag && primitive_function.tag !== "primitive") { + error('Cannot tag an already tagged object: ' + JSON.stringify(primitive_function) + '/' + primitive_function + '/' + primitive_function.tag); + } else {} + primitive_function.tag = "primitive"; + return primitive_function; +} + +var expires = undefined; +function evaluate(input_text,stmt,env) { + if ((new Date()).getTime() > expires) { + error('Time limit exceeded.'); + } else if (is_self_evaluating(stmt)) { + return stmt; + } else if (is_empty_list_statement(stmt)) { + return evaluate_empty_list_statement(input_text,stmt,env); + } else if (is_variable(stmt)) { + return lookup_variable_value(variable_name(stmt),env); + } else if (is_assignment(stmt)) { + return evaluate_assignment(input_text,stmt,env); + } else if (is_var_definition(stmt)) { + return evaluate_var_definition(input_text,stmt,env); + } else if (is_if_statement(stmt)) { + return evaluate_if_statement(input_text,stmt,env); + } else if (is_ternary_statement(stmt)) { + return evaluate_ternary_statement(input_text,stmt,env); + } else if (is_while_statement(stmt)) { + return evaluate_while_statement(input_text,stmt,env); + } else if (is_for_statement(stmt)) { + return evaluate_for_statement(input_text,stmt,env); + } else if (is_function_definition(stmt)) { + return evaluate_function_definition(input_text,stmt,env); + } else if (is_sequence(stmt)) { + return evaluate_sequence(input_text,stmt,env); + } else if (is_boolean_operation(stmt)) { + return evaluate_boolean_operation(input_text, + stmt, + operands(stmt), + env); + } else if (is_application(stmt)) { + var fun = evaluate(input_text,operator(stmt),env); + var args = list_of_values(input_text,operands(stmt),env); + var context = object(stmt) ? evaluate(input_text,object(stmt),env) : window; + + // We need to be careful. If we are calling debug() then we need + // to give the environment to throw. + if (fun === debug_break) { + debug_break(env, stmt_line(stmt)); + // no return, exception thrown + } else { + return apply(fun, args, context); + } + } else if (is_object_method_application(stmt)) { + var obj = object(stmt) ? evaluate(input_text,object(stmt),env) : window; + if (!is_object(obj)) { + error('Cannot apply object method on non-object'); + } else { + var op = evaluate_object_property_access(obj, + evaluate(input_text, object_property(stmt), env)); + return apply(op, + list_of_values(input_text, operands(stmt), env), + obj); + } + } else if (is_break_statement(stmt)) { + return make_break_value(); + } else if (is_continue_statement(stmt)) { + return make_continue_value(); + } else if (is_return_statement(stmt)) { + //Tail-call optimisation. + //Tail-calls are return statements which have no deferred operations, + //and they return the result of another function call. + if (is_application(return_statement_expression(stmt)) && + is_variable(operator(return_statement_expression(stmt)))) { + //Over here, if our return expression is simply an expression, we return + //a deferred evaluation. Apply will see these, and run it in a while + //loop instead. + // + //To make Apply homogenous, we need to do some voodoo to evaluate + //the operands in the function application, but NOT actually apply + //the function. + var fun = evaluate(input_text,operator(return_statement_expression(stmt)), env); + var arguments = list_of_values(input_text,operands(return_statement_expression(stmt)), env); + var obj = object(stmt) ? evaluate(input_text,object(return_statement_expression(stmt)), env) : window; + return make_tail_recursive_return_value(fun, arguments, obj, env); + } else { + return make_return_value( + evaluate(input_text,return_statement_expression(stmt), + env)); + } + } else if (is_array_expression(stmt)) { + return evaluate_array_expression(input_text,stmt,env); + } else if (is_object_expression(stmt)) { + return evaluate_object_expression(input_text,stmt,env); + } else if (is_construction(stmt)) { + return evaluate_construction_statement(input_text,stmt,env); + } else if (is_property_access(stmt)) { + return evaluate_property_access(input_text,stmt,env); + } else if (is_property_assignment(stmt)) { + return evaluate_property_assignment(input_text,stmt,env); + } else { + error("Unknown expression type: " + JSON.stringify(stmt), + stmt_line(stmt)); + } +} + +function evaluate_toplevel(input_text,stmt,env) { + var value = evaluate(input_text,stmt,env); + if (is_return_value(value) || is_tail_recursive_return_value(value)) { + error("return not allowed outside of function definition"); + } else if (is_break_value(value) || is_continue_value(value)) { + error("break and continue not allowed outside of function."); + } else { + return value; + } +} + +/// The top-level environment. +var the_global_environment = (function() { + var initial_env = extend_environment(primitive_function_names(), + primitive_function_objects(), + the_empty_environment); + define_variable("undefined", make_undefined_value(), initial_env); + define_variable("NaN", NaN, initial_env); + define_variable("Infinity", Infinity, initial_env); + define_variable("window", window, initial_env); + define_variable("debug", debug_break, initial_env); + define_variable("debug_resume", + make_primitive_function_object(debug_resume), + initial_env); + return initial_env; +})(); + +/// For initialising /other/ toplevel environments. +/// +/// By default this is the global environment. However, if a program forces early +/// termination, we will install the current environment so that we can evaluate +/// expressions in the "debug" environment. This allows debugging. +var environment_stack = [the_global_environment]; +environment_stack.top = function() { + if (this.length === 0) { + return null; + } else { + return this[this.length - 1]; + } +}; + +function driver_loop() { + var program_string = read("Enter your program here: "); + var program_syntax = parse(program_string); + if (is_tagged_object(program_syntax,"exit")) { + return "interpreter completed"; + } else { + var output = evaluate_toplevel( + string.replace(new RegExp('\r\n', 'g'), '\n').replace(new RegExp('\r', 'g'), '\n').split('\n'), + program_syntax, environment_stack.top()); + write(output); + return driver_loop(); + } +} + +function get_input_text(input_text, start_line, start_col, end_line, end_col) { + //Fix index-from-line 1 + start_line = start_line - 1; + end_line = end_line - 1; + + if (start_line === end_line) { + return input_text[start_line].substr(start_col, end_col - start_col + 1); + } else { + var result = ''; + var i = start_line; + result = result + input_text[start_line].substr(start_col) + '\n'; + + for (i = i + 1; i < end_line; i = i + 1) { + result = result + input_text[i] + '\n'; + } + + result = result + input_text[end_line].substr(0, end_col + 1); + return result; + } +} + +/// \section Debugging support +function DebugException(environment, line) { + this.environment = environment; + this.line = line; +} + +/// The registered debug handler. If this is set, when debug_break is called, +/// this handler will get triggered with the line number of the triggering +/// call. +var debug_handler = null; + +/// Breaks the interpreter, throwing the environment to the top level. +function debug_break(env, line) { + throw new DebugException(env, line); +} + +/// Handles the exception generated by debug_break, installing it to +/// the top level. +function debug_handle(exception) { + environment_stack.push(exception.environment); + console.warn("Debugger environment initialised."); + + if (debug_handler) { + debug_handler(exception.line); + } +} + +/// Removes the top environment from the environment stack. +function debug_resume() { + if (environment_stack.length > 1) { + environment_stack.pop(); + console.log("Environment restored."); + + if (environment_stack.length === 1 && debug_handler) { + debug_handler(null); + } + } else { + console.log("No environments to restore."); + } +} + +function debug_evaluate_toplevel() { + try { + return evaluate_toplevel.apply(this, arguments); + } catch (e) { + if (e instanceof DebugException) { + debug_handle(e); + } else { + throw e; + } + } +} + +//Public functions +/// Parses and evaluates the given program source text, with an optional timeout +/// where an exception (time limit exceeded) is thrown. +/// \param[in] string The program text string to run as the program code. +/// \param[in] timeout The timeout in milliseconds before code execution is +/// interrupted. +parse_and_evaluate = function(string, timeout) { + if (timeout) { + expires = (new Date()).getTime() + timeout; + } else { + expires = undefined; + } + + var result = debug_evaluate_toplevel( + string.replace(new RegExp('\r\n', 'g'), '\n').replace(new RegExp('\r', 'g'), '\n').split('\n'), + parse(string), + environment_stack.top()); + + // Reset the timeout. + expires = undefined; + return result; +}; + +parser_register_native_function = function(name, func) { + if (!is_function(func) && !is_primitive_function(func)) { + error("parser_register_native_function can only be used to register " + + "functions: " + JSON.stringify(func) + " given."); + } else if (is_primitive_function(func)) { + //No need to wrap another layer of indirection + add_binding_to_frame(name, func, + first_frame(the_global_environment)); + } else { + add_binding_to_frame(name, make_primitive_function_object(func), + first_frame(the_global_environment)); + } +}; + +parser_register_native_variable = function(name, object) { + if (is_object(object) && is_function(object)) { + error("parser_register_native_variable can only be used to register " + + "variables."); + } else { + define_variable(name, object, the_global_environment); + } +}; + +parser_register_debug_handler = function(handler) { + debug_handler = handler; +} + +})(); diff --git a/src/stdlib/metacircular-interpreter/lib/interpreter/json2.js b/src/stdlib/metacircular-interpreter/lib/interpreter/json2.js new file mode 100644 index 000000000..3fb75f841 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/lib/interpreter/json2.js @@ -0,0 +1,486 @@ +/* +json2.js +2012-10-08 + +Public Domain. + +NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + +See http://www.JSON.org/js.html + + +This code should be minified before deployment. +See http://javascript.crockford.com/jsmin.html + +USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO +NOT CONTROL. + + +This file creates a global JSON object containing two methods: stringify +and parse. + +JSON.stringify(value, replacer, space) +value any JavaScript value, usually an object or array. + +replacer an optional parameter that determines how object +values are stringified for objects. It can be a +function or an array of strings. + +space an optional parameter that specifies the indentation +of nested structures. If it is omitted, the text will +be packed without extra whitespace. If it is a number, +it will specify the number of spaces to indent at each +level. If it is a string (such as '\t' or ' '), +it contains the characters used to indent at each level. + +This method produces a JSON text from a JavaScript value. + +When an object value is found, if the object contains a toJSON +method, its toJSON method will be called and the result will be +stringified. A toJSON method does not serialize: it returns the +value represented by the name/value pair that should be serialized, +or undefined if nothing should be serialized. The toJSON method +will be passed the key associated with the value, and this will be +bound to the value + +For example, this would serialize Dates as ISO strings. + +Date.prototype.toJSON = function (key) { +function f(n) { +// Format integers to have at least two digits. +return n < 10 ? '0' + n : n; +} + +return this.getUTCFullYear() + '-' + +f(this.getUTCMonth() + 1) + '-' + +f(this.getUTCDate()) + 'T' + +f(this.getUTCHours()) + ':' + +f(this.getUTCMinutes()) + ':' + +f(this.getUTCSeconds()) + 'Z'; +}; + +You can provide an optional replacer method. It will be passed the +key and value of each member, with this bound to the containing +object. The value that is returned from your method will be +serialized. If your method returns undefined, then the member will +be excluded from the serialization. + +If the replacer parameter is an array of strings, then it will be +used to select the members to be serialized. It filters the results +such that only members with keys listed in the replacer array are +stringified. + +Values that do not have JSON representations, such as undefined or +functions, will not be serialized. Such values in objects will be +dropped; in arrays they will be replaced with null. You can use +a replacer function to replace those with JSON values. +JSON.stringify(undefined) returns undefined. + +The optional space parameter produces a stringification of the +value that is filled with line breaks and indentation to make it +easier to read. + +If the space parameter is a non-empty string, then that string will +be used for indentation. If the space parameter is a number, then +the indentation will be that many spaces. + +Example: + +text = JSON.stringify(['e', {pluribus: 'unum'}]); +// text is '["e",{"pluribus":"unum"}]' + + +text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); +// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' + +text = JSON.stringify([new Date()], function (key, value) { +return this[key] instanceof Date ? +'Date(' + this[key] + ')' : value; +}); +// text is '["Date(---current time---)"]' + + +JSON.parse(text, reviver) +This method parses a JSON text to produce an object or array. +It can throw a SyntaxError exception. + +The optional reviver parameter is a function that can filter and +transform the results. It receives each of the keys and values, +and its return value is used instead of the original value. +If it returns what it received, then the structure is not modified. +If it returns undefined then the member is deleted. + +Example: + +// Parse the text. Values that look like ISO date strings will +// be converted to Date objects. + +myData = JSON.parse(text, function (key, value) { +var a; +if (typeof value === 'string') { +a = +/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); +if (a) { +return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], ++a[5], +a[6])); +} +} +return value; +}); + +myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { +var d; +if (typeof value === 'string' && +value.slice(0, 5) === 'Date(' && +value.slice(-1) === ')') { +d = new Date(value.slice(5, -1)); +if (d) { +return d; +} +} +return value; +}); + + +This is a reference implementation. You are free to copy, modify, or +redistribute. +*/ + +/*jslint evil: true, regexp: true */ + +/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, +call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, +getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, +lastIndex, length, parse, prototype, push, replace, slice, stringify, +test, toJSON, toString, valueOf +*/ + + +// Create a JSON object only if one does not already exist. We create the +// methods in a closure to avoid creating global variables. + +if (typeof JSON !== 'object') { + JSON = {}; +} + +(function () { + 'use strict'; + + function f(n) { + // Format integers to have at least two digits. + return n < 10 ? '0' + n : n; + } + + if (typeof Date.prototype.toJSON !== 'function') { + + Date.prototype.toJSON = function (key) { + + return isFinite(this.valueOf()) + ? this.getUTCFullYear() + '-' + + f(this.getUTCMonth() + 1) + '-' + + f(this.getUTCDate()) + 'T' + + f(this.getUTCHours()) + ':' + + f(this.getUTCMinutes()) + ':' + + f(this.getUTCSeconds()) + 'Z' + : null; + }; + + String.prototype.toJSON = + Number.prototype.toJSON = + Boolean.prototype.toJSON = function (key) { + return this.valueOf(); + }; + } + + var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, + escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, + gap, + indent, + meta = { // table of character substitutions + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '"' : '\\"', + '\\': '\\\\' + }, + rep; + + + function quote(string) { + +// If the string contains no control characters, no quote characters, and no +// backslash characters, then we can safely slap some quotes around it. +// Otherwise we must also replace the offending characters with safe escape +// sequences. + + escapable.lastIndex = 0; + return escapable.test(string) ? '"' + string.replace(escapable, function (a) { + var c = meta[a]; + return typeof c === 'string' + ? c + : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); + }) + '"' : '"' + string + '"'; + } + + + function str(key, holder) { + +// Produce a string from holder[key]. + + var i, // The loop counter. + k, // The member key. + v, // The member value. + length, + mind = gap, + partial, + value = holder[key]; + +// If the value has a toJSON method, call it to obtain a replacement value. + + if (value && typeof value === 'object' && + typeof value.toJSON === 'function') { + value = value.toJSON(key); + } + +// If we were called with a replacer function, then call the replacer to +// obtain a replacement value. + + if (typeof rep === 'function') { + value = rep.call(holder, key, value); + } + +// What happens next depends on the value's type. + + switch (typeof value) { + case 'string': + return quote(value); + + case 'number': + +// JSON numbers must be finite. Encode non-finite numbers as null. + + return isFinite(value) ? String(value) : 'null'; + + case 'boolean': + case 'null': + +// If the value is a boolean or null, convert it to a string. Note: +// typeof null does not produce 'null'. The case is included here in +// the remote chance that this gets fixed someday. + + return String(value); + +// If the type is 'object', we might be dealing with an object or an array or +// null. + + case 'object': + +// Due to a specification blunder in ECMAScript, typeof null is 'object', +// so watch out for that case. + + if (!value) { + return 'null'; + } + +// Make an array to hold the partial results of stringifying this object value. + + gap += indent; + partial = []; + +// Is the value an array? + + if (Object.prototype.toString.apply(value) === '[object Array]') { + +// The value is an array. Stringify every element. Use null as a placeholder +// for non-JSON values. + + length = value.length; + for (i = 0; i < length; i += 1) { + partial[i] = str(i, value) || 'null'; + } + +// Join all of the elements together, separated with commas, and wrap them in +// brackets. + + v = partial.length === 0 + ? '[]' + : gap + ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' + : '[' + partial.join(',') + ']'; + gap = mind; + return v; + } + +// If the replacer is an array, use it to select the members to be stringified. + + if (rep && typeof rep === 'object') { + length = rep.length; + for (i = 0; i < length; i += 1) { + if (typeof rep[i] === 'string') { + k = rep[i]; + v = str(k, value); + if (v) { + partial.push(quote(k) + (gap ? ': ' : ':') + v); + } + } + } + } else { + +// Otherwise, iterate through all of the keys in the object. + + for (k in value) { + if (Object.prototype.hasOwnProperty.call(value, k)) { + v = str(k, value); + if (v) { + partial.push(quote(k) + (gap ? ': ' : ':') + v); + } + } + } + } + +// Join all of the member texts together, separated with commas, +// and wrap them in braces. + + v = partial.length === 0 + ? '{}' + : gap + ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' + : '{' + partial.join(',') + '}'; + gap = mind; + return v; + } + } + +// If the JSON object does not yet have a stringify method, give it one. + + if (typeof JSON.stringify !== 'function') { + JSON.stringify = function (value, replacer, space) { + +// The stringify method takes a value and an optional replacer, and an optional +// space parameter, and returns a JSON text. The replacer can be a function +// that can replace values, or an array of strings that will select the keys. +// A default replacer method can be provided. Use of the space parameter can +// produce text that is more easily readable. + + var i; + gap = ''; + indent = ''; + +// If the space parameter is a number, make an indent string containing that +// many spaces. + + if (typeof space === 'number') { + for (i = 0; i < space; i += 1) { + indent += ' '; + } + +// If the space parameter is a string, it will be used as the indent string. + + } else if (typeof space === 'string') { + indent = space; + } + +// If there is a replacer, it must be a function or an array. +// Otherwise, throw an error. + + rep = replacer; + if (replacer && typeof replacer !== 'function' && + (typeof replacer !== 'object' || + typeof replacer.length !== 'number')) { + throw new Error('JSON.stringify'); + } + +// Make a fake root object containing our value under the key of ''. +// Return the result of stringifying the value. + + return str('', {'': value}); + }; + } + + +// If the JSON object does not yet have a parse method, give it one. + + if (typeof JSON.parse !== 'function') { + JSON.parse = function (text, reviver) { + +// The parse method takes a text and an optional reviver function, and returns +// a JavaScript value if the text is a valid JSON text. + + var j; + + function walk(holder, key) { + +// The walk method is used to recursively walk the resulting structure so +// that modifications can be made. + + var k, v, value = holder[key]; + if (value && typeof value === 'object') { + for (k in value) { + if (Object.prototype.hasOwnProperty.call(value, k)) { + v = walk(value, k); + if (v !== undefined) { + value[k] = v; + } else { + delete value[k]; + } + } + } + } + return reviver.call(holder, key, value); + } + + +// Parsing happens in four stages. In the first stage, we replace certain +// Unicode characters with escape sequences. JavaScript handles many characters +// incorrectly, either silently deleting them, or treating them as line endings. + + text = String(text); + cx.lastIndex = 0; + if (cx.test(text)) { + text = text.replace(cx, function (a) { + return '\\u' + + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); + }); + } + +// In the second stage, we run the text against regular expressions that look +// for non-JSON patterns. We are especially concerned with '()' and 'new' +// because they can cause invocation, and '=' because it can cause mutation. +// But just to be safe, we want to reject all unexpected forms. + +// We split the second stage into 4 regexp operations in order to work around +// crippling inefficiencies in IE's and Safari's regexp engines. First we +// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we +// replace all simple value tokens with ']' characters. Third, we delete all +// open brackets that follow a colon or comma or that begin the text. Finally, +// we look to see that the remaining characters are only whitespace or ']' or +// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. + + if (/^[\],:{}\s]*$/ + .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@') + .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']') + .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { + +// In the third stage we use the eval function to compile the text into a +// JavaScript structure. The '{' operator is subject to a syntactic ambiguity +// in JavaScript: it can begin a block or an object literal. We wrap the text +// in parens to eliminate the ambiguity. + + j = eval('(' + text + ')'); + +// In the optional fourth stage, we recursively walk the new structure, passing +// each name/value pair to a reviver function for possible transformation. + + return typeof reviver === 'function' + ? walk({'': j}, '') + : j; + } + +// If the text is not JSON parseable, then a SyntaxError is thrown. + + throw new SyntaxError('JSON.parse'); + }; + } +}()); diff --git a/src/stdlib/metacircular-interpreter/lib/interpreter/parser.jison b/src/stdlib/metacircular-interpreter/lib/interpreter/parser.jison new file mode 100644 index 000000000..bc11e624d --- /dev/null +++ b/src/stdlib/metacircular-interpreter/lib/interpreter/parser.jison @@ -0,0 +1,741 @@ + +/* description: Parses end executes JediScript expressions. */ + +/* lexical grammar */ +%lex +%x DoubleQuotedString +%x SingleQuotedString +%x QuotedStringEscape +%% + + +\/\/([^\n\r]*) /* skip single-line comments */ +\/\*([\u0000-\uffff]*?)\*\/ /* skip multi-line comments */ +\s+ /* skip whitespace */ + +"function" return 'function' +"return" return 'return' +"if" return 'if' +"else" return 'else' +"while" return 'while' +"for" return 'for' +"case" return 'case' +"default" return 'default' +"new" return 'new' +"break" return 'break' +"continue" return 'continue' +"var" return 'var' +"===" return '===' +"=" return '=' +"{" return '{' +"}" return '}' +";" return ';' +"," return ',' +"truee" return 'true' +"false" return 'false' +"[]" return 'emptylist' +"[" return '[' +"]" return ']' +"." return '.' + +'""' return 'EmptyString' +"''" return 'EmptyString' +'"' this.begin('DoubleQuotedString'); +"'" this.begin('SingleQuotedString'); +\\ this.begin('QuotedStringEscape'); +'"' this.popState(); +"'" this.popState(); +(.|\r\n|\n) { this.popState(); return 'QuotedStringEscape'; } /* The newlines are there because we can span strings across lines using \ */ +[^"\\]* return 'QuotedString'; +[^'\\]* return 'QuotedString'; + + +[A-Za-z_][A-Za-z0-9_]* return 'Identifier' /* TODO: non-ASCII identifiers */ + +[0-9]+("."[0-9]+)?([eE][\-+]?[0-9]+)?\b return 'FLOAT_NUMBER' /* 3.1, 3.1e-7 */ +[0-9]+\b return 'INT_NUMBER' + +"+" return '+' +"-" return '-' +"*" return '*' +"/" return '/' +"%" return '%' +"!==" return '!==' +"<=" return '<=' +">=" return '>=' +"<" return '<' +">" return '>' +"!" return '!' +"&&" return '&&' +"||" return '||' +"(" return '(' +")" return ')' +"?" return '?' +":" return ':' + +<> return 'EOF' +. return 'INVALID' + +/lex + +/* operator associations and precedence */ + +%left ';' +%right '=' +%right '?' ':' +%left '||' +%left '&&' +%left '===' '!==' +%left '<' '>' '<=' '>=' +%left '+' '-' +%left '*' '/' '%' +%right '!' UMINUS UPLUS +%left '[' ']' +%left '.' + +%% /* language grammar */ + +program + : statements EOF + { return $1; } + ; + +statements + : + { $$ = []; } + | ';' /* The empty statement */ + { $$ = []; } + | statement statements + { $$ = pair($1, $2); } + | '{' statements '}' + { $$ = $2; } + ; + +statement + : + ifstatement + + | whilestatement + + | forstatement + + + | 'function' identifier '(' identifiers ')' '{' statements '}' + {{ + $$ = { + tag: 'var_definition', + variable: $2, + value: { + tag: 'function_definition', + name: $2, + parameters: $4, + body: $7, + line: yylineno, + location: { + start_line: @1.first_line, + start_col: @1.first_column, + end_line: @8.first_line, + end_col: @8.first_column + } + }, + line: yylineno + }; + }} + | vardefinition + + | assignment ';' + + | expression ';' + | 'return' expression ';' + {{ + $$ = { + tag: 'return_statement', + expression: $2, + line: yylineno + }; + }} + + | break ';' + {{ + $$ = { + tag: 'break_statement', + line: yylineno + }; + }} + | continue ';' + {{ + $$ = { + tag: 'continue_statement', + line: yylineno + }; + }} + + ; + +vardefinition + : + 'var' identifier '=' expression ';' + {{ + $$ = { + tag: 'var_definition', + variable: $2, + value: $4, + line: yylineno + }; + }} + ; + + +assignment + : + expression '=' expression + {{ + if ($1.tag === 'variable') { + $$ = { + tag: 'assignment', + variable: $1, + value: $3, + line: yylineno + }; + + } else if ($1.tag === 'property_access') { + $$ = { + tag: 'property_assignment', + object: $1.object, + property: $1.property, + value: $3, + line: yylineno + }; + + } else { + error('parse error in line ' + yylineno + ": " + yytext); + } + }} + ; + +ifstatement + : + 'if' '(' expression ')' '{' statements '}' 'else' '{' statements '}' + {{ + $$ = { + tag: 'if', + predicate: $3, + consequent: $6, + alternative: $10, + line: yylineno + }; + }} + | 'if' '(' expression ')' '{' statements '}' 'else' ifstatement + {{ + $$ = { + tag: 'if', + predicate: $3, + consequent: $6, + alternative: pair($9, []), + line: yylineno + }; + }} + ; + + +whilestatement + : + 'while' '(' expression ')' '{' statements '}' + {{ + $$ = { + tag: 'while', + predicate: $3, + statements: $6, + line: yylineno + }; + }} + ; + +forstatement + : + 'for' '(' forinitialiser expression ';' forfinaliser ')' '{' statements '}' + {{ + $$ = { + tag: 'for', + initialiser: $3, + predicate: $4, + finaliser: $6, + statements: $9, + line: yylineno + }; + }} + ; + +forinitialiser + : + expression ';' + | vardefinition + | assignment ';' + | ';' + ; + +forfinaliser + : + assignment + | expression + | + ; + + +expression + : + expression '+' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '-' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '*' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '/' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '%' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | '-' expression %prec UMINUS + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $1, + line: yylineno + }, + operands: [0, [$2, []]], + line: yylineno + }; + }} + | '+' expression %prec UPLUS + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $1, + line: yylineno + }, + operands: [0, [$2, []]], + line: yylineno + }; + }} + | '!' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $1, + line: yylineno + }, + operands: [$2, []], + line: yylineno + }; + }} + | expression '&&' expression + {{ + $$ = { + tag: 'boolean_op', + operator: $2, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '||' expression + {{ + $$ = { + tag: 'boolean_op', + operator: $2, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '===' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '!==' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '>' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '<' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '>=' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '<=' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + + | expression '[' expression ']' + {{ + $$ = { + tag: 'property_access', + object: $1, + property: $3, + line: yylineno + }; + }} + + + /* Because we need to use the Math library. */ + | expression '.' identifier + {{ + $$ = { + tag: 'property_access', + object: $1, + property: $3, + line: yylineno + }; + }} + + | '(' expression ')' + {$$ = $2;} + + | constants + + | identifier + {{ + $$ = { + tag: 'variable', + name: $1, + line: yylineno + }; + }} + + | '(' expression ')' '(' expressions ')' + {{ + $$ = { + tag: 'application', + operator: $2, + operands: $5, + line: yylineno + }; + }} + + | '[' expressions ']' + {{ + $$ = { + tag: 'arrayinit', + elements: $2, + line: yylineno + }; + }} + | '{' pairs '}' + {{ + $$ = { + tag: 'object', + pairs: $2, + line: yylineno + }; + }} + + | identifier '(' expressions ')' + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $1, + line: yylineno + }, + operands: $3, + line: yylineno + }; + }} + + | expression '.' identifier '(' expressions ')' + {{ + $$ = { + tag: 'object_method_application', + object: $1, + property: $3, + operands: $5, + line: yylineno + }; + }} + + + | new identifier '(' expressions ')' + {{ + $$ = { + tag: 'construction', + type: $2, + operands: $4, + line: yylineno + }; + }} + + | 'function' '(' identifiers ')' '{' statements '}' + {{ + $$ = { + tag: 'function_definition', + name: 'lambda', + parameters: $3, + body: $6, + line: yylineno, + location: { + start_line: @1.first_line, + start_col: @1.first_column, + end_line: @7.first_line, + end_col: @7.first_column + } + }; + }} + + | expression '?' expression ':' expression + {{ + $$ = { + tag: 'ternary', + predicate: $1, + consequent: $3, + alternative: $5, + line: yylineno + }; + }} + ; + +constants + : + 'FLOAT_NUMBER' + { $$ = parseFloat(yytext); } + + | 'INT_NUMBER' + { $$ = parseInt(yytext, 10); } + + | 'true' + { $$ = true; } + + | 'false' + { $$ = false; } + + | quotedstring + + | 'emptylist' + { $$ = { tag: 'empty_list', line: yylineno }; } + ; + +quotedstring + : + 'EmptyString' + { + $$ = ''; + } + | 'QuotedString' + | 'QuotedStringEscape' + { + switch (yytext) + { + case 'b': $$ = '\b'; break; + case 'n': $$ = '\n'; break; + case 'r': $$ = '\r'; break; + case 't': $$ = '\t'; break; + case "'": $$ = "'"; break; + case '"': $$ = '"'; break; + case '\\': $$ = '\\'; break; + case '\n': + case '\r\n': $$ = ''; break; + default: $$ = '\\' + $1; break; + } + } + | 'QuotedStringEscape' quotedstring + { + switch ($1) + { + case 'b': $$ = '\b'; break; + case 'n': $$ = '\n'; break; + case 'r': $$ = '\r'; break; + case 't': $$ = '\t'; break; + case "'": $$ = "'"; break; + case '"': $$ = '"'; break; + case '\\': $$ = '\\'; break; + case '\n': + case '\r\n': $$ = ''; break; + default: $$ = '\\' + $1; break; + } + $$ += $2; + } + | 'QuotedString' quotedstring + { + $$ = $1 + $2; + } + ; + +expressions + : + nonemptyexpressions + { $$ = $1; } + | /* NOTHING */ + { $$ = []; } + ; + +nonemptyexpressions + : + expression ',' nonemptyexpressions + { $$ = [ $1, $3 ]; } + | expression + { $$ = [ $1, [] ]; } + ; + + +pairs + : + nonemptypairs + { $$ = $1; } + | /* NOTHING */ + { $$ = []; } + ; + +nonemptypairs + : + pair ',' nonemptypairs + { $$ = [ $1, $3 ]; } + | pair + { $$ = [ $1, [] ]; } + ; + +pair + : + identifier ':' expression + { $$ = [ $1, $3 ]; } + ; + +identifiers + : + nonemptyidentifiers + { $$ = $1; } + | /* NOTHING */ + { $$ = []; } + ; + +nonemptyidentifiers + : + identifier ',' nonemptyidentifiers + { $$ = [ $1, $3 ]; } + | identifier + { $$ = [ $1, [] ]; } + ; + +identifier + : + 'Identifier' + { $$ = yytext; } + ; diff --git a/src/stdlib/metacircular-interpreter/lib/interpreter/parser.jison.tpl b/src/stdlib/metacircular-interpreter/lib/interpreter/parser.jison.tpl new file mode 100644 index 000000000..ac853f16c --- /dev/null +++ b/src/stdlib/metacircular-interpreter/lib/interpreter/parser.jison.tpl @@ -0,0 +1,741 @@ + +/* description: Parses end executes JediScript expressions. */ + +/* lexical grammar */ +%lex +%x DoubleQuotedString +%x SingleQuotedString +%x QuotedStringEscape +%% + + +\/\/([^\n\r]*) /* skip single-line comments */ +\/\*([\u0000-\uffff]*?)\*\/ /* skip multi-line comments */ +\s+ /* skip whitespace */ + +"function" return 'function' +"return" return 'return' +"if" return 'if' +"else" return 'else' +"while" return 'while' +"for" return 'for' +"case" return 'case' +"default" return 'default' +"new" return 'new' +"break" return 'break' +"continue" return 'continue' +"var" return 'var' +"===" return '===' +"=" return '=' +"{" return '{' +"}" return '}' +";" return ';' +"," return ',' +"tru" return 'true' +"false" return 'false' +"[]" return 'emptylist' +"[" return '[' +"]" return ']' +"." return '.' + +'""' return 'EmptyString' +"''" return 'EmptyString' +'"' this.begin('DoubleQuotedString'); +"'" this.begin('SingleQuotedString'); +\\ this.begin('QuotedStringEscape'); +'"' this.popState(); +"'" this.popState(); +(.|\r\n|\n) { this.popState(); return 'QuotedStringEscape'; } /* The newlines are there because we can span strings across lines using \ */ +[^"\\]* return 'QuotedString'; +[^'\\]* return 'QuotedString'; + + +[A-Za-z_][A-Za-z0-9_]* return 'Identifier' /* TODO: non-ASCII identifiers */ + +[0-9]+("."[0-9]+)?([eE][\-+]?[0-9]+)?\b return 'FLOAT_NUMBER' /* 3.1, 3.1e-7 */ +[0-9]+\b return 'INT_NUMBER' + +"+" return '+' +"-" return '-' +"*" return '*' +"/" return '/' +"%" return '%' +"!==" return '!==' +"<=" return '<=' +">=" return '>=' +"<" return '<' +">" return '>' +"!" return '!' +"&&" return '&&' +"||" return '||' +"(" return '(' +")" return ')' +"?" return '?' +":" return ':' + +<> return 'EOF' +. return 'INVALID' + +/lex + +/* operator associations and precedence */ + +%left ';' +%right '=' +%right '?' ':' +%left '||' +%left '&&' +%left '===' '!==' +%left '<' '>' '<=' '>=' +%left '+' '-' +%left '*' '/' '%' +%right '!' UMINUS UPLUS +%left '[' ']' +%left '.' + +%% /* language grammar */ + +program + : statements EOF + { return $1; } + ; + +statements + : + { $$ = []; } + | ';' /* The empty statement */ + { $$ = []; } + | statement statements + { $$ = pair($1, $2); } + | '{' statements '}' + { $$ = $2; } + ; + +statement + : + ifstatement +{{if week|ormore>8}} + | whilestatement +{{if week|ormore>13}} + | forstatement +{{/if}} +{{/if}} + | 'function' identifier '(' identifiers ')' '{' statements '}' + {{ + $$ = { + tag: 'var_definition', + variable: $2, + value: { + tag: 'function_definition', + name: $2, + parameters: $4, + body: $7, + line: yylineno, + location: { + start_line: @1.first_line, + start_col: @1.first_column, + end_line: @8.first_line, + end_col: @8.first_column + } + }, + line: yylineno + }; + }} + | vardefinition +{{if week|ormore>8}} + | assignment ';' +{{/if}} + | expression ';' + | 'return' expression ';' + {{ + $$ = { + tag: 'return_statement', + expression: $2, + line: yylineno + }; + }} +{{if week|ormore>13}} + | break ';' + {{ + $$$ = { + tag: 'break_statement', + line: yylineno + }; + }} + | continue ';' + {{ + $$$ = { + tag: 'continue_statement', + line: yylineno + }; + }} +{{/if}} + ; + +vardefinition + : + 'var' identifier '=' expression ';' + {{ + $$ = { + tag: 'var_definition', + variable: $2, + value: $4, + line: yylineno + }; + }} + ; + +{{if week|ormore>8}} +assignment + : + expression '=' expression + {{ + if ($1.tag === 'variable') { + $$$ = { + tag: 'assignment', + variable: $1, + value: $3, + line: yylineno + }; +{{if week|ormore>10}} + } else if ($1.tag === 'property_access') { + $$$$$$ = { + tag: 'property_assignment', + object: $1.object, + property: $1.property, + value: $3, + line: yylineno + }; +{{/if}} + } else { + error('parse error in line ' + yylineno + ": " + yytext); + } + }} + ; +{{/if}} +ifstatement + : + 'if' '(' expression ')' '{' statements '}' 'else' '{' statements '}' + {{ + $$ = { + tag: 'if', + predicate: $3, + consequent: $6, + alternative: $10, + line: yylineno + }; + }} + | 'if' '(' expression ')' '{' statements '}' 'else' ifstatement + {{ + $$ = { + tag: 'if', + predicate: $3, + consequent: $6, + alternative: pair($9, []), + line: yylineno + }; + }} + ; + +{{if week|ormore>8}} +whilestatement + : + 'while' '(' expression ')' '{' statements '}' + {{ + $$$ = { + tag: 'while', + predicate: $3, + statements: $6, + line: yylineno + }; + }} + ; + +forstatement + : + 'for' '(' forinitialiser expression ';' forfinaliser ')' '{' statements '}' + {{ + $$$ = { + tag: 'for', + initialiser: $3, + predicate: $4, + finaliser: $6, + statements: $9, + line: yylineno + }; + }} + ; + +forinitialiser + : + expression ';' + | vardefinition + | assignment ';' + | ';' + ; + +forfinaliser + : + assignment + | expression + | + ; +{{/if}} + +expression + : + expression '+' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '-' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '*' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '/' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '%' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | '-' expression %prec UMINUS + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $1, + line: yylineno + }, + operands: [0, [$2, []]], + line: yylineno + }; + }} + | '+' expression %prec UPLUS + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $1, + line: yylineno + }, + operands: [0, [$2, []]], + line: yylineno + }; + }} + | '!' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $1, + line: yylineno + }, + operands: [$2, []], + line: yylineno + }; + }} + | expression '&&' expression + {{ + $$ = { + tag: 'boolean_op', + operator: $2, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '||' expression + {{ + $$ = { + tag: 'boolean_op', + operator: $2, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '===' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '!==' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '>' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '<' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '>=' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} + | expression '<=' expression + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $2, + line: yylineno + }, + operands: [$1, [$3, []]], + line: yylineno + }; + }} +{{if week|ormore>10}} + | expression '[' expression ']' + {{ + $$$ = { + tag: 'property_access', + object: $1, + property: $3, + line: yylineno + }; + }} +{{/if}} +{{if week|ormore>4}} + /* Because we need to use the Math library. */ + | expression '.' identifier + {{ + $$$ = { + tag: 'property_access', + object: $1, + property: $3, + line: yylineno + }; + }} +{{/if}} + | '(' expression ')' + {$$ = $2;} + + | constants + + | identifier + {{ + $$ = { + tag: 'variable', + name: $1, + line: yylineno + }; + }} + + | '(' expression ')' '(' expressions ')' + {{ + $$ = { + tag: 'application', + operator: $2, + operands: $5, + line: yylineno + }; + }} +{{if week|ormore>10}} + | '[' expressions ']' + {{ + $$$ = { + tag: 'arrayinit', + elements: $2, + line: yylineno + }; + }} + | '{' pairs '}' + {{ + $$$ = { + tag: 'object', + pairs: $2, + line: yylineno + }; + }} +{{/if}} + | identifier '(' expressions ')' + {{ + $$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $1, + line: yylineno + }, + operands: $3, + line: yylineno + }; + }} +{{if week|ormore>4}} + | expression '.' identifier '(' expressions ')' + {{ + $$$ = { + tag: 'object_method_application', + object: $1, + property: $3, + operands: $5, + line: yylineno + }; + }} +{{/if}} +{{if week|ormore>10}} + | new identifier '(' expressions ')' + {{ + $$$ = { + tag: 'construction', + type: $2, + operands: $4, + line: yylineno + }; + }} +{{/if}} + | 'function' '(' identifiers ')' '{' statements '}' + {{ + $$ = { + tag: 'function_definition', + name: 'lambda', + parameters: $3, + body: $6, + line: yylineno, + location: { + start_line: @1.first_line, + start_col: @1.first_column, + end_line: @7.first_line, + end_col: @7.first_column + } + }; + }} + + | expression '?' expression ':' expression + {{ + $$ = { + tag: 'ternary', + predicate: $1, + consequent: $3, + alternative: $5, + line: yylineno + }; + }} + ; + +constants + : + 'FLOAT_NUMBER' + { $$ = parseFloat(yytext); } + + | 'INT_NUMBER' + { $$ = parseInt(yytext, 10); } + + | 'true' + { $$ = true; } + + | 'false' + { $$ = false; } + + | quotedstring + + | 'emptylist' + { $$ = { tag: 'empty_list', line: yylineno }; } + ; + +quotedstring + : + 'EmptyString' + { + $$ = ''; + } + | 'QuotedString' + | 'QuotedStringEscape' + { + switch (yytext) + { + case 'b': $$ = '\b'; break; + case 'n': $$ = '\n'; break; + case 'r': $$ = '\r'; break; + case 't': $$ = '\t'; break; + case "'": $$ = "'"; break; + case '"': $$ = '"'; break; + case '\\': $$ = '\\'; break; + case '\n': + case '\r\n': $$ = ''; break; + default: $$ = '\\' + $1; break; + } + } + | 'QuotedStringEscape' quotedstring + { + switch ($1) + { + case 'b': $$ = '\b'; break; + case 'n': $$ = '\n'; break; + case 'r': $$ = '\r'; break; + case 't': $$ = '\t'; break; + case "'": $$ = "'"; break; + case '"': $$ = '"'; break; + case '\\': $$ = '\\'; break; + case '\n': + case '\r\n': $$ = ''; break; + default: $$ = '\\' + $1; break; + } + $$ += $2; + } + | 'QuotedString' quotedstring + { + $$ = $1 + $2; + } + ; + +expressions + : + nonemptyexpressions + { $$ = $1; } + | /* NOTHING */ + { $$ = []; } + ; + +nonemptyexpressions + : + expression ',' nonemptyexpressions + { $$ = [ $1, $3 ]; } + | expression + { $$ = [ $1, [] ]; } + ; + +{{if week|ormore>5}} +pairs + : + nonemptypairs + { $$$ = $1; } + | /* NOTHING */ + { $$$ = []; } + ; + +nonemptypairs + : + pair ',' nonemptypairs + { $$$ = [ $1, $3 ]; } + | pair + { $$$ = [ $1, [] ]; } + ; + +pair + : + identifier ':' expression + { $$$ = [ $1, $3 ]; } + ; +{{/if}} +identifiers + : + nonemptyidentifiers + { $$ = $1; } + | /* NOTHING */ + { $$ = []; } + ; + +nonemptyidentifiers + : + identifier ',' nonemptyidentifiers + { $$ = [ $1, $3 ]; } + | identifier + { $$ = [ $1, [] ]; } + ; + +identifier + : + 'Identifier' + { $$ = yytext; } + ; diff --git a/src/stdlib/metacircular-interpreter/lib/interpreter/parser.js b/src/stdlib/metacircular-interpreter/lib/interpreter/parser.js new file mode 100644 index 000000000..44104c5ed --- /dev/null +++ b/src/stdlib/metacircular-interpreter/lib/interpreter/parser.js @@ -0,0 +1,1099 @@ +/* parser generated by jison 0.4.18 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +var parser = (function(){ +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[2,2],$V1=[1,3],$V2=[1,5],$V3=[1,9],$V4=[1,23],$V5=[1,13],$V6=[1,14],$V7=[1,15],$V8=[1,19],$V9=[1,16],$Va=[1,17],$Vb=[1,18],$Vc=[1,21],$Vd=[1,20],$Ve=[1,22],$Vf=[1,26],$Vg=[1,27],$Vh=[1,28],$Vi=[1,29],$Vj=[1,30],$Vk=[1,31],$Vl=[1,33],$Vm=[1,35],$Vn=[1,36],$Vo=[1,37],$Vp=[1,34],$Vq=[5,9],$Vr=[5,6,8,9,13,15,21,22,23,24,26,28,29,32,33,37,46,52,55,56,57,58,60,61,62,63,69],$Vs=[1,46],$Vt=[1,49],$Vu=[1,50],$Vv=[1,51],$Vw=[1,52],$Vx=[1,53],$Vy=[1,54],$Vz=[1,55],$VA=[1,56],$VB=[1,57],$VC=[1,58],$VD=[1,59],$VE=[1,60],$VF=[1,61],$VG=[1,62],$VH=[1,63],$VI=[1,64],$VJ=[1,65],$VK=[1,67],$VL=[1,68],$VM=[6,9,17,25,32,33,34,35,36,38,39,40,41,42,43,44,45,46,47,48,53,54,65],$VN=[2,49],$VO=[1,79],$VP=[2,70],$VQ=[1,89],$VR=[2,79],$VS=[6,9,17,25,32,33,34,35,36,38,39,40,41,42,43,44,45,47,53,54,65],$VT=[17,47],$VU=[6,9,17,25,32,33,38,39,40,41,42,43,44,45,47,53,54,65],$VV=[6,9,17,25,38,39,40,41,47,53,54,65],$VW=[6,9,17,25,38,39,40,41,42,43,44,45,47,53,54,65],$VX=[8,13,15,32,33,37,46,52,55,56,57,58,60,61,62,63,69]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"program":3,"statements":4,"EOF":5,";":6,"statement":7,"{":8,"}":9,"ifstatement":10,"whilestatement":11,"forstatement":12,"function":13,"identifier":14,"(":15,"identifiers":16,")":17,"vardefinition":18,"assignment":19,"expression":20,"return":21,"break":22,"continue":23,"var":24,"=":25,"if":26,"else":27,"while":28,"for":29,"forinitialiser":30,"forfinaliser":31,"+":32,"-":33,"*":34,"/":35,"%":36,"!":37,"&&":38,"||":39,"===":40,"!==":41,">":42,"<":43,">=":44,"<=":45,"[":46,"]":47,".":48,"constants":49,"expressions":50,"pairs":51,"new":52,"?":53,":":54,"FLOAT_NUMBER":55,"INT_NUMBER":56,"true":57,"false":58,"quotedstring":59,"emptylist":60,"EmptyString":61,"QuotedString":62,"QuotedStringEscape":63,"nonemptyexpressions":64,",":65,"nonemptypairs":66,"pair":67,"nonemptyidentifiers":68,"Identifier":69,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",6:";",8:"{",9:"}",13:"function",15:"(",17:")",21:"return",22:"break",23:"continue",24:"var",25:"=",26:"if",27:"else",28:"while",29:"for",32:"+",33:"-",34:"*",35:"/",36:"%",37:"!",38:"&&",39:"||",40:"===",41:"!==",42:">",43:"<",44:">=",45:"<=",46:"[",47:"]",48:".",52:"new",53:"?",54:":",55:"FLOAT_NUMBER",56:"INT_NUMBER",57:"true",58:"false",60:"emptylist",61:"EmptyString",62:"QuotedString",63:"QuotedStringEscape",65:",",69:"Identifier"}, +productions_: [0,[3,2],[4,0],[4,1],[4,2],[4,3],[7,1],[7,1],[7,1],[7,8],[7,1],[7,2],[7,2],[7,3],[7,2],[7,2],[18,5],[19,3],[10,11],[10,9],[11,7],[12,10],[30,2],[30,1],[30,2],[30,1],[31,1],[31,1],[31,0],[20,3],[20,3],[20,3],[20,3],[20,3],[20,2],[20,2],[20,2],[20,3],[20,3],[20,3],[20,3],[20,3],[20,3],[20,3],[20,3],[20,4],[20,3],[20,3],[20,1],[20,1],[20,6],[20,3],[20,3],[20,4],[20,6],[20,5],[20,7],[20,5],[49,1],[49,1],[49,1],[49,1],[49,1],[49,1],[59,1],[59,1],[59,1],[59,2],[59,2],[50,1],[50,0],[64,3],[64,1],[51,1],[51,0],[66,3],[66,1],[67,3],[16,1],[16,0],[68,3],[68,1],[14,1]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: + return $$[$0-1]; +break; +case 2: case 3: case 70: case 74: case 79: + this.$ = []; +break; +case 4: + this.$ = pair($$[$0-1], $$[$0]); +break; +case 5: + this.$ = $$[$0-1]; +break; +case 9: + + this.$ = { + tag: 'var_definition', + variable: $$[$0-6], + value: { + tag: 'function_definition', + name: $$[$0-6], + parameters: $$[$0-4], + body: $$[$0-1], + line: yylineno, + location: { + start_line: _$[$0-7].first_line, + start_col: _$[$0-7].first_column, + end_line: _$[$0].first_line, + end_col: _$[$0].first_column + } + }, + line: yylineno + }; + +break; +case 13: + + this.$ = { + tag: 'return_statement', + expression: $$[$0-1], + line: yylineno + }; + +break; +case 14: + + this.$ = { + tag: 'break_statement', + line: yylineno + }; + +break; +case 15: + + this.$ = { + tag: 'continue_statement', + line: yylineno + }; + +break; +case 16: + + this.$ = { + tag: 'var_definition', + variable: $$[$0-3], + value: $$[$0-1], + line: yylineno + }; + +break; +case 17: + + if ($$[$0-2].tag === 'variable') { + this.$ = { + tag: 'assignment', + variable: $$[$0-2], + value: $$[$0], + line: yylineno + }; + + } else if ($$[$0-2].tag === 'property_access') { + this.$ = { + tag: 'property_assignment', + object: $$[$0-2].object, + property: $$[$0-2].property, + value: $$[$0], + line: yylineno + }; + + } else { + error('parse error in line ' + yylineno + ": " + yytext); + } + +break; +case 18: + + this.$ = { + tag: 'if', + predicate: $$[$0-8], + consequent: $$[$0-5], + alternative: $$[$0-1], + line: yylineno + }; + +break; +case 19: + + this.$ = { + tag: 'if', + predicate: $$[$0-6], + consequent: $$[$0-3], + alternative: pair($$[$0], []), + line: yylineno + }; + +break; +case 20: + + this.$ = { + tag: 'while', + predicate: $$[$0-4], + statements: $$[$0-1], + line: yylineno + }; + +break; +case 21: + + this.$ = { + tag: 'for', + initialiser: $$[$0-7], + predicate: $$[$0-6], + finaliser: $$[$0-4], + statements: $$[$0-1], + line: yylineno + }; + +break; +case 29: case 30: case 31: case 32: case 33: case 39: case 40: case 41: case 42: case 43: case 44: + + this.$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $$[$0-1], + line: yylineno + }, + operands: [$$[$0-2], [$$[$0], []]], + line: yylineno + }; + +break; +case 34: case 35: + + this.$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $$[$0-1], + line: yylineno + }, + operands: [0, [$$[$0], []]], + line: yylineno + }; + +break; +case 36: + + this.$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $$[$0-1], + line: yylineno + }, + operands: [$$[$0], []], + line: yylineno + }; + +break; +case 37: case 38: + + this.$ = { + tag: 'boolean_op', + operator: $$[$0-1], + operands: [$$[$0-2], [$$[$0], []]], + line: yylineno + }; + +break; +case 45: + + this.$ = { + tag: 'property_access', + object: $$[$0-3], + property: $$[$0-1], + line: yylineno + }; + +break; +case 46: + + this.$ = { + tag: 'property_access', + object: $$[$0-2], + property: $$[$0], + line: yylineno + }; + +break; +case 47: +this.$ = $$[$0-1]; +break; +case 49: + + this.$ = { + tag: 'variable', + name: $$[$0], + line: yylineno + }; + +break; +case 50: + + this.$ = { + tag: 'application', + operator: $$[$0-4], + operands: $$[$0-1], + line: yylineno + }; + +break; +case 51: + + this.$ = { + tag: 'arrayinit', + elements: $$[$0-1], + line: yylineno + }; + +break; +case 52: + + this.$ = { + tag: 'object', + pairs: $$[$0-1], + line: yylineno + }; + +break; +case 53: + + this.$ = { + tag: 'application', + operator: { + tag: 'variable', + name: $$[$0-3], + line: yylineno + }, + operands: $$[$0-1], + line: yylineno + }; + +break; +case 54: + + this.$ = { + tag: 'object_method_application', + object: $$[$0-5], + property: $$[$0-3], + operands: $$[$0-1], + line: yylineno + }; + +break; +case 55: + + this.$ = { + tag: 'construction', + type: $$[$0-3], + operands: $$[$0-1], + line: yylineno + }; + +break; +case 56: + + this.$ = { + tag: 'function_definition', + name: 'lambda', + parameters: $$[$0-4], + body: $$[$0-1], + line: yylineno, + location: { + start_line: _$[$0-6].first_line, + start_col: _$[$0-6].first_column, + end_line: _$[$0].first_line, + end_col: _$[$0].first_column + } + }; + +break; +case 57: + + this.$ = { + tag: 'ternary', + predicate: $$[$0-4], + consequent: $$[$0-2], + alternative: $$[$0], + line: yylineno + }; + +break; +case 58: + this.$ = parseFloat(yytext); +break; +case 59: + this.$ = parseInt(yytext, 10); +break; +case 60: + this.$ = true; +break; +case 61: + this.$ = false; +break; +case 63: + this.$ = { tag: 'empty_list', line: yylineno }; +break; +case 64: + + this.$ = ''; + +break; +case 66: + + switch (yytext) + { + case 'b': this.$ = '\b'; break; + case 'n': this.$ = '\n'; break; + case 'r': this.$ = '\r'; break; + case 't': this.$ = '\t'; break; + case "'": this.$ = "'"; break; + case '"': this.$ = '"'; break; + case '\\': this.$ = '\\'; break; + case '\n': + case '\r\n': this.$ = ''; break; + default: this.$ = '\\' + $$[$0]; break; + } + +break; +case 67: + + switch ($$[$0-1]) + { + case 'b': this.$ = '\b'; break; + case 'n': this.$ = '\n'; break; + case 'r': this.$ = '\r'; break; + case 't': this.$ = '\t'; break; + case "'": this.$ = "'"; break; + case '"': this.$ = '"'; break; + case '\\': this.$ = '\\'; break; + case '\n': + case '\r\n': this.$ = ''; break; + default: this.$ = '\\' + $$[$0-1]; break; + } + this.$ += $$[$0]; + +break; +case 68: + + this.$ = $$[$0-1] + $$[$0]; + +break; +case 69: case 73: case 78: + this.$ = $$[$0]; +break; +case 71: case 75: case 77: case 80: + this.$ = [ $$[$0-2], $$[$0] ]; +break; +case 72: case 76: case 81: + this.$ = [ $$[$0], [] ]; +break; +case 82: + this.$ = yytext; +break; +} +}, +table: [{3:1,4:2,5:$V0,6:$V1,7:4,8:$V2,10:6,11:7,12:8,13:$V3,14:25,15:$V4,18:10,19:11,20:12,21:$V5,22:$V6,23:$V7,24:$V8,26:$V9,28:$Va,29:$Vb,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{1:[3]},{5:[1,38]},o($Vq,[2,3]),o($Vq,$V0,{7:4,10:6,11:7,12:8,18:10,19:11,20:12,49:24,14:25,59:32,4:39,6:$V1,8:$V2,13:$V3,15:$V4,21:$V5,22:$V6,23:$V7,24:$V8,26:$V9,28:$Va,29:$Vb,32:$Vc,33:$Vd,37:$Ve,46:$Vf,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp}),{4:40,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:44,15:$V4,18:10,19:11,20:12,21:$V5,22:$V6,23:$V7,24:$V8,26:$V9,28:$Va,29:$Vb,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,51:41,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,66:42,67:43,69:$Vp},o($Vr,[2,6]),o($Vr,[2,7]),o($Vr,[2,8]),{14:45,15:$Vs,69:$Vp},o($Vr,[2,10]),{6:[1,47]},{6:[1,48],25:$Vt,32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ},{8:$VK,13:$VL,14:25,15:$V4,20:66,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{6:[1,69]},{6:[1,70]},{15:[1,71]},{15:[1,72]},{15:[1,73]},{14:74,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:75,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:76,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:77,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:78,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},o($VM,[2,48]),o($VM,$VN,{15:$VO}),{8:$VK,13:$VL,14:25,15:$V4,20:82,32:$Vc,33:$Vd,37:$Ve,46:$Vf,47:$VP,49:24,50:80,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,64:81,69:$Vp},{14:83,69:$Vp},o($VM,[2,58]),o($VM,[2,59]),o($VM,[2,60]),o($VM,[2,61]),o($VM,[2,62]),o($VM,[2,63]),o([6,9,15,17,25,32,33,34,35,36,38,39,40,41,42,43,44,45,46,47,48,53,54,65],[2,82]),o($VM,[2,64]),o($VM,[2,65],{59:84,61:$Vm,62:$Vn,63:$Vo}),o($VM,[2,66],{59:85,61:$Vm,62:$Vn,63:$Vo}),{1:[2,1]},o($Vq,[2,4]),{9:[1,86]},{9:[1,87]},{9:[2,73]},{9:[2,76],65:[1,88]},o([6,25,32,33,34,35,36,38,39,40,41,42,43,44,45,46,48,53],$VN,{15:$VO,54:$VQ}),{15:[1,90]},{14:93,16:91,17:$VR,68:92,69:$Vp},o($Vr,[2,11]),o($Vr,[2,12]),{8:$VK,13:$VL,14:25,15:$V4,20:94,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:95,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:96,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:97,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:98,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:99,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:100,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:101,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:102,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:103,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:104,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:105,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:106,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:107,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:108,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{14:109,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:110,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{6:[1,111],32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ},{9:[2,74],14:112,51:41,66:42,67:43,69:$Vp},{15:$Vs},o($Vr,[2,14]),o($Vr,[2,15]),{8:$VK,13:$VL,14:25,15:$V4,20:113,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:114,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{6:[1,119],8:$VK,13:$VL,14:25,15:$V4,18:117,19:118,20:116,24:$V8,30:115,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{25:[1,120]},o($VS,[2,34],{46:$VH,48:$VI}),o($VS,[2,35],{46:$VH,48:$VI}),o($VS,[2,36],{46:$VH,48:$VI}),{17:[1,121],32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ},{8:$VK,13:$VL,14:25,15:$V4,17:$VP,20:82,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,50:122,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,64:81,69:$Vp},{47:[1,123]},o($VT,[2,69]),o($VT,[2,72],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ,65:[1,124]}),{15:[1,125]},o($VM,[2,68]),o($VM,[2,67]),o($Vq,[2,5]),o($VM,[2,52]),{14:112,66:126,67:43,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:127,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{14:93,16:128,17:$VR,68:92,69:$Vp},{17:[1,129]},{17:[2,78]},{17:[2,81],65:[1,130]},o([6,17],[2,17],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ}),o($VU,[2,29],{34:$Vw,35:$Vx,36:$Vy,46:$VH,48:$VI}),o($VU,[2,30],{34:$Vw,35:$Vx,36:$Vy,46:$VH,48:$VI}),o($VS,[2,31],{46:$VH,48:$VI}),o($VS,[2,32],{46:$VH,48:$VI}),o($VS,[2,33],{46:$VH,48:$VI}),o([6,9,17,25,38,39,47,53,54,65],[2,37],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI}),o([6,9,17,25,39,47,53,54,65],[2,38],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI}),o($VV,[2,39],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI}),o($VV,[2,40],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI}),o($VW,[2,41],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,46:$VH,48:$VI}),o($VW,[2,42],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,46:$VH,48:$VI}),o($VW,[2,43],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,46:$VH,48:$VI}),o($VW,[2,44],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,46:$VH,48:$VI}),{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,47:[1,131],48:$VI,53:$VJ},o($VM,[2,46],{15:[1,132]}),{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ,54:[1,133]},o($Vr,[2,13]),{54:$VQ},{17:[1,134],32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ},{17:[1,135],32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ},{8:$VK,13:$VL,14:25,15:$V4,20:136,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{6:[1,137],25:$Vt,32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ},o($VX,[2,23]),{6:[1,138]},o($VX,[2,25]),{8:$VK,13:$VL,14:25,15:$V4,20:139,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},o($VM,[2,47],{15:[1,140]}),{17:[1,141]},o($VM,[2,51]),{8:$VK,13:$VL,14:25,15:$V4,20:82,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,64:142,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,17:$VP,20:82,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,50:143,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,64:81,69:$Vp},{9:[2,75]},o([9,65],[2,77],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ}),{17:[1,144]},{8:[1,145]},{14:93,68:146,69:$Vp},o($VM,[2,45]),{8:$VK,13:$VL,14:25,15:$V4,17:$VP,20:82,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,50:147,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,64:81,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,20:148,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:[1,149]},{8:[1,150]},{6:[1,151],32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ},o($VX,[2,22]),o($VX,[2,24]),{6:[1,152],32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ},{8:$VK,13:$VL,14:25,15:$V4,17:$VP,20:82,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,50:153,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,64:81,69:$Vp},o($VM,[2,53]),o($VT,[2,71]),{17:[1,154]},{8:[1,155]},{4:156,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:25,15:$V4,18:10,19:11,20:12,21:$V5,22:$V6,23:$V7,24:$V8,26:$V9,28:$Va,29:$Vb,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{17:[2,80]},{17:[1,157]},o([6,9,17,25,47,54,65],[2,57],{32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ}),{4:158,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:25,15:$V4,18:10,19:11,20:12,21:$V5,22:$V6,23:$V7,24:$V8,26:$V9,28:$Va,29:$Vb,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{4:159,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:25,15:$V4,18:10,19:11,20:12,21:$V5,22:$V6,23:$V7,24:$V8,26:$V9,28:$Va,29:$Vb,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{8:$VK,13:$VL,14:25,15:$V4,17:[2,28],19:161,20:162,31:160,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},o($Vr,[2,16]),{17:[1,163]},o($VM,[2,55]),{4:164,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:25,15:$V4,18:10,19:11,20:12,21:$V5,22:$V6,23:$V7,24:$V8,26:$V9,28:$Va,29:$Vb,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{9:[1,165]},o($VM,[2,54]),{9:[1,166]},{9:[1,167]},{17:[1,168]},{17:[2,26]},{17:[2,27],25:$Vt,32:$Vu,33:$Vv,34:$Vw,35:$Vx,36:$Vy,38:$Vz,39:$VA,40:$VB,41:$VC,42:$VD,43:$VE,44:$VF,45:$VG,46:$VH,48:$VI,53:$VJ},o($VM,[2,50]),{9:[1,169]},o($VM,[2,56]),{27:[1,170]},o($Vr,[2,20]),{8:[1,171]},o($Vr,[2,9]),{8:[1,172],10:173,26:$V9},{4:174,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:25,15:$V4,18:10,19:11,20:12,21:$V5,22:$V6,23:$V7,24:$V8,26:$V9,28:$Va,29:$Vb,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},{4:175,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:25,15:$V4,18:10,19:11,20:12,21:$V5,22:$V6,23:$V7,24:$V8,26:$V9,28:$Va,29:$Vb,32:$Vc,33:$Vd,37:$Ve,46:$Vf,49:24,52:$Vg,55:$Vh,56:$Vi,57:$Vj,58:$Vk,59:32,60:$Vl,61:$Vm,62:$Vn,63:$Vo,69:$Vp},o($Vr,[2,19]),{9:[1,176]},{9:[1,177]},o($Vr,[2,21]),o($Vr,[2,18])], +defaultActions: {38:[2,1],42:[2,73],92:[2,78],126:[2,75],146:[2,80],161:[2,26]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else if (hash.loc && hash.line) { + throw new SyntaxError(str, hash.loc, hash.line); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + _token_stack: + var lex = function () { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + }; + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:/* skip single-line comments */ +break; +case 1:/* skip multi-line comments */ +break; +case 2:/* skip whitespace */ +break; +case 3:return 13 +break; +case 4:return 21 +break; +case 5:return 26 +break; +case 6:return 27 +break; +case 7:return 28 +break; +case 8:return 29 +break; +case 9:return 'case' +break; +case 10:return 'default' +break; +case 11:return 52 +break; +case 12:return 22 +break; +case 13:return 23 +break; +case 14:return 24 +break; +case 15:return 40 +break; +case 16:return 25 +break; +case 17:return 8 +break; +case 18:return 9 +break; +case 19:return 6 +break; +case 20:return 65 +break; +case 21:return 57 +break; +case 22:return 58 +break; +case 23:return 60 +break; +case 24:return 46 +break; +case 25:return 47 +break; +case 26:return 48 +break; +case 27:return 61 +break; +case 28:return 61 +break; +case 29:this.begin('DoubleQuotedString'); +break; +case 30:this.begin('SingleQuotedString'); +break; +case 31:this.begin('QuotedStringEscape'); +break; +case 32:this.popState(); +break; +case 33:this.popState(); +break; +case 34: this.popState(); return 63; +break; +case 35:return 62; +break; +case 36:return 62; +break; +case 37:return 69 /* TODO: non-ASCII identifiers */ +break; +case 38:return 55 /* 3.1, 3.1e-7 */ +break; +case 39:return 56 +break; +case 40:return 32 +break; +case 41:return 33 +break; +case 42:return 34 +break; +case 43:return 35 +break; +case 44:return 36 +break; +case 45:return 41 +break; +case 46:return 45 +break; +case 47:return 44 +break; +case 48:return 43 +break; +case 49:return 42 +break; +case 50:return 37 +break; +case 51:return 38 +break; +case 52:return 39 +break; +case 53:return 15 +break; +case 54:return 17 +break; +case 55:return 53 +break; +case 56:return 54 +break; +case 57:return 5 +break; +case 58:return 'INVALID' +break; +} +}, +rules: [/^(?:\/\/([^\n\r]*))/,/^(?:\/\*([\u0000-\uffff]*?)\*\/)/,/^(?:\s+)/,/^(?:function\b)/,/^(?:return\b)/,/^(?:if\b)/,/^(?:else\b)/,/^(?:while\b)/,/^(?:for\b)/,/^(?:case\b)/,/^(?:default\b)/,/^(?:new\b)/,/^(?:break\b)/,/^(?:continue\b)/,/^(?:var\b)/,/^(?:===)/,/^(?:=)/,/^(?:\{)/,/^(?:\})/,/^(?:;)/,/^(?:,)/,/^(?:tru\b)/,/^(?:false\b)/,/^(?:\[\])/,/^(?:\[)/,/^(?:\])/,/^(?:\.)/,/^(?:"")/,/^(?:'')/,/^(?:")/,/^(?:')/,/^(?:\\)/,/^(?:")/,/^(?:')/,/^(?:(.|\r\n|\n))/,/^(?:[^"\\]*)/,/^(?:[^'\\]*)/,/^(?:[A-Za-z_][A-Za-z0-9_]*)/,/^(?:[0-9]+(\.[0-9]+)?([eE][\-+]?[0-9]+)?\b)/,/^(?:[0-9]+\b)/,/^(?:\+)/,/^(?:-)/,/^(?:\*)/,/^(?:\/)/,/^(?:%)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:<)/,/^(?:>)/,/^(?:!)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\()/,/^(?:\))/,/^(?:\?)/,/^(?::)/,/^(?:$)/,/^(?:.)/], +conditions: {"QuotedStringEscape":{"rules":[34],"inclusive":false},"SingleQuotedString":{"rules":[31,33,36],"inclusive":false},"DoubleQuotedString":{"rules":[31,32,35],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); + + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = parser; +exports.Parser = parser.Parser; +exports.parse = function () { return parser.parse.apply(parser, arguments); }; +exports.main = function commonjsMain(args) { + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); +}; +if (typeof module !== 'undefined' && require.main === module) { + exports.main(process.argv.slice(1)); +} +} \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/lib/jediscript.js.tpl b/src/stdlib/metacircular-interpreter/lib/jediscript.js.tpl new file mode 100644 index 000000000..accac70f5 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/lib/jediscript.js.tpl @@ -0,0 +1,51 @@ +jQuery(document).ready(function() { + var scripts = jQuery("script[type='text/jediscript'], script[language='jediscript'], " + + "script[language='JediScript']"); + for (var i = 0; i < scripts.length; ++i) { +{{if native}} + if (scripts[i].src) { + jQuery.ajax(scripts[i].src, { + accepts: "text/javascript, text", + dataType: "text", + success: (function(i) { + return function(data, textStatus, jqXHR) { + if (parse(jqXHR.responseText)) { + var newScript = document.createElement("script"); + newScript.src = scripts[i].src; + newScript.type = "text/javascript"; + newScript.charset = "utf-8"; + + scripts[i].parentNode.insertBefore(newScript, scripts[i]); + } + }; + })(i) + }); + } else { + var script = jQuery(scripts[i]).html(); + if (parse(script)) { + var newScript = document.createElement("script"); + newScript.type = "text/javascript"; + newScript.charset = "utf-8"; + newScript.innerHTML = script; + + scripts[i].parentNode.insertBefore(newScript, scripts[i]); + } + } +{{else}} + if (scripts[i].src) { + jQuery.ajax(scripts[i].src, { + accepts: "text/javascript, text", + dataType: "text", + success: (function(i) { + return function(data, textStatus, jqXHR) { + parse_and_evaluate(jqXHR.responseText); + }; + })(i) + }); + } else { + var script = jQuery(scripts[i]).html(); + parse_and_evaluate(script); + } +{{/if}} + } +}); diff --git a/src/stdlib/metacircular-interpreter/lib/util/io.js b/src/stdlib/metacircular-interpreter/lib/util/io.js new file mode 100644 index 000000000..447ab63a6 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/lib/util/io.js @@ -0,0 +1,76 @@ +/* + * Taken from the Jison Utility libraries. + * + * Under the MIT license. + */ + +// node +if (typeof process !== 'undefined') { + +var fs = require('fs'); +var util = require('util'); + +exports.p = util.puts; +exports.cwd = process.cwd; +exports.join = require('path').join; +exports.basename = require('path').basename; +exports.args = process.argv.slice(1); +exports.exit = process.exit; +exports.resolve = require('url').resolve; + +exports.read = function (fname, encoding) { + return fs.readFileSync(fname, encoding || "utf8"); +}; + +exports.write = function (fname, data) { + fs.writeFileSync(fname, data); +}; + +exports.stdin = function (cb) { + var stdin = process.openStdin(), + data = ''; + + stdin.setEncoding('utf8'); + stdin.addListener('data', function (chunk) { + data += chunk; + }); + stdin.addListener('end', function () { + cb(data); + }); +}; + +exports.stdout = function (out) { + process.stdout.write(out); +}; + +// commonjs/narwhal-like +} else { + +var fs = require('file'); +var system = require('system'); + +exports.p = print; +exports.cwd = fs.cwd; +exports.join = fs.join; +exports.basename = fs.basename; +exports.args = system.args.slice(0); +exports.exit = require('os').exit; +exports.resolve = fs.resolve; + +exports.read = function (fname) { + return fs.read(fname); +}; + +exports.write = function (fname, data) { + fs.write(fname, data); +}; + +exports.stdin = function (cb) { + cb(system.stdin.read()); +}; + +exports.stdout = function (out) { + system.stdout.print(out); +}; + +} diff --git a/src/stdlib/metacircular-interpreter/nbproject/project.properties b/src/stdlib/metacircular-interpreter/nbproject/project.properties new file mode 100644 index 000000000..f75f031c5 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/nbproject/project.properties @@ -0,0 +1,20 @@ +auxiliary.org-netbeans-modules-css-prep.less_2e_enabled=false +auxiliary.org-netbeans-modules-css-prep.less_2e_mappings= +auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=false +auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings= +browser=SL[/Browsers/FirefoxBrowser +browser.autorefresh.SL__Browsers_ChromeBrowser=true +browser.autorefresh.SL__Browsers_webviewBrowser=true +browser.highlightselection.SL__Browsers_ChromeBrowser=true +browser.highlightselection.SL__Browsers_webviewBrowser=true +config.folder= +external.project.url= +file.reference.CS1010R-Project=. +file.reference.Joel-tests=tests +file.reference.Project-Joel=. +files.encoding=UTF-8 +server=INTERNAL +site.root.folder=${file.reference.Project-Joel} +start.file=tests/unit_tests.html +test.folder=${file.reference.Joel-tests} +web.context.root=/Project diff --git a/src/stdlib/metacircular-interpreter/nbproject/project.xml b/src/stdlib/metacircular-interpreter/nbproject/project.xml new file mode 100644 index 000000000..4b4b93623 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.web.clientproject + + + Interpreter + + + diff --git a/src/stdlib/metacircular-interpreter/out/project.komodoproject b/src/stdlib/metacircular-interpreter/out/project.komodoproject new file mode 100644 index 000000000..0792bb6e8 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/out/project.komodoproject @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/stdlib/metacircular-interpreter/out/scratch.html b/src/stdlib/metacircular-interpreter/out/scratch.html new file mode 100644 index 000000000..78bb686b3 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/out/scratch.html @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/stdlib/metacircular-interpreter/out/scratch.js b/src/stdlib/metacircular-interpreter/out/scratch.js new file mode 100644 index 000000000..76400e54e --- /dev/null +++ b/src/stdlib/metacircular-interpreter/out/scratch.js @@ -0,0 +1,3 @@ +// File scratch.js: This is the JediScript code that belongs +// to the scratch project +// Write your JediScript code here: diff --git a/src/stdlib/metacircular-interpreter/package-lock.json b/src/stdlib/metacircular-interpreter/package-lock.json new file mode 100644 index 000000000..af4f78e44 --- /dev/null +++ b/src/stdlib/metacircular-interpreter/package-lock.json @@ -0,0 +1,176 @@ +{ + "name": "jediscript", + "version": "0.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "JSONSelect": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.4.0.tgz", + "integrity": "sha1-oI7cxn6z/L6Z7WMIVTRKDPKCu40=" + }, + "JSV": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz", + "integrity": "sha1-0Hf2glVx+CEy+d/67Vh7QCn+/1c=" + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "optional": true + }, + "cjson": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/cjson/-/cjson-0.3.0.tgz", + "integrity": "sha1-5kObkHA9MS/24iJAl76pLOPQKhQ=", + "requires": { + "jsonlint": "1.6.0" + } + }, + "colors": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.5.1.tgz", + "integrity": "sha1-fQAj6usVTo7p/Oddy5I9DtFmd3Q=" + }, + "ebnf-parser": { + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/ebnf-parser/-/ebnf-parser-0.1.10.tgz", + "integrity": "sha1-zR9rpHfFY4xAyX7ZtXLbW6tdgzE=" + }, + "escodegen": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.3.3.tgz", + "integrity": "sha1-8CQBb1qI4Eb9EgBQVek5gC5sXyM=", + "requires": { + "esprima": "~1.1.1", + "estraverse": "~1.5.0", + "esutils": "~1.0.0", + "source-map": "~0.1.33" + } + }, + "esprima": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.1.1.tgz", + "integrity": "sha1-W28VR/TRAuZw4UDFCb5ncdautUk=" + }, + "estraverse": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.5.1.tgz", + "integrity": "sha1-hno+jlip+EYYr7bC3bzZFrfLr3E=" + }, + "esutils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.0.0.tgz", + "integrity": "sha1-gVHTWOIMisx/t0XnRywAJf5JZXA=" + }, + "gcc-rest": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/gcc-rest/-/gcc-rest-0.1.6.tgz", + "integrity": "sha1-ApkXm8VD+CyDLfJLrMPvAfNKWe8=" + }, + "jison": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/jison/-/jison-0.4.18.tgz", + "integrity": "sha512-FKkCiJvozgC7VTHhMJ00a0/IApSxhlGsFIshLW6trWJ8ONX2TQJBBz6DlcO1Gffy4w9LT+uL+PA+CVnUSJMF7w==", + "requires": { + "JSONSelect": "0.4.0", + "cjson": "0.3.0", + "ebnf-parser": "0.1.10", + "escodegen": "1.3.x", + "esprima": "1.1.x", + "jison-lex": "0.3.x", + "lex-parser": "~0.1.3", + "nomnom": "1.5.2" + }, + "dependencies": { + "nomnom": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.5.2.tgz", + "integrity": "sha1-9DRUSKhTz71cDSYyDyR3qwUm/i8=", + "requires": { + "colors": "0.5.x", + "underscore": "1.1.x" + } + }, + "underscore": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.1.7.tgz", + "integrity": "sha1-QLq4S60Z0jAJbo1u9ii/8FXYPbA=" + } + } + }, + "jison-lex": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/jison-lex/-/jison-lex-0.3.4.tgz", + "integrity": "sha1-gcoo2E+ESZ36jFlNzePYo/Jux6U=", + "requires": { + "lex-parser": "0.1.x", + "nomnom": "1.5.2" + }, + "dependencies": { + "nomnom": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.5.2.tgz", + "integrity": "sha1-9DRUSKhTz71cDSYyDyR3qwUm/i8=", + "requires": { + "colors": "0.5.x", + "underscore": "1.1.x" + } + }, + "underscore": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.1.7.tgz", + "integrity": "sha1-QLq4S60Z0jAJbo1u9ii/8FXYPbA=" + } + } + }, + "jsonlint": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/jsonlint/-/jsonlint-1.6.0.tgz", + "integrity": "sha1-iKpGvCiaesk7tGyuLVihh6m7SUo=", + "requires": { + "JSV": ">= 4.0.x", + "nomnom": ">= 1.5.x" + } + }, + "lex-parser": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/lex-parser/-/lex-parser-0.1.4.tgz", + "integrity": "sha1-ZMTwJfF/1Tv7RXY/rrFvAVp0dVA=" + }, + "markup-js": { + "version": "1.5.21", + "resolved": "https://registry.npmjs.org/markup-js/-/markup-js-1.5.21.tgz", + "integrity": "sha1-OJEocDpWWWRXTQ41fhQq3TvkbXk=" + }, + "node-zip": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/node-zip/-/node-zip-1.0.1.tgz", + "integrity": "sha1-FYuKQsTmrNE1Tz1OeeQfuQumwi4=" + }, + "nomnom": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.6.2.tgz", + "integrity": "sha1-hKZqJgF0QI/Ft3oY+IjszET7aXE=", + "requires": { + "colors": "0.5.x", + "underscore": "~1.4.4" + } + }, + "source-map": { + "version": "0.1.43", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", + "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", + "optional": true, + "requires": { + "amdefine": ">=0.0.4" + } + }, + "underscore": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz", + "integrity": "sha1-YaajIBBiKvoHljvzJSA88SI51gQ=" + } + } +} diff --git a/src/stdlib/metacircular-interpreter/package.json b/src/stdlib/metacircular-interpreter/package.json new file mode 100644 index 000000000..d1830a9cf --- /dev/null +++ b/src/stdlib/metacircular-interpreter/package.json @@ -0,0 +1,21 @@ +{ + "name": "jediscript", + "version": "0.0.0", + "description": "This project comprises 4 main components:", + "main": "generate.js", + "directories": { + "test": "tests" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "BSD-2-Clause", + "dependencies": { + "markup-js": "~1.5.16", + "node-zip": "~1.0.1", + "nomnom": "~1.6.1", + "jison": "~0.4.13", + "gcc-rest": "0.1.6" + } +} diff --git a/src/stdlib/metacircular-interpreter/tests/contest_8-1_1.js b/src/stdlib/metacircular-interpreter/tests/contest_8-1_1.js new file mode 100644 index 000000000..65b4f7dcf --- /dev/null +++ b/src/stdlib/metacircular-interpreter/tests/contest_8-1_1.js @@ -0,0 +1,194 @@ +// File: contest_8-1_1.js +function console_log(x) { + return display(x); +} +function search_log(x) { + //return console_log(x); +} +function error_on(condition, message) { + if (condition) { + //throw message; + } else {} +} + +/// \param[in] number_of_crystals The number of crystals we are allowed to break. +/// This will be in the range [3*number_of_params, 200]. +/// \param[in] number_of_params The number of parameters we need to determine +/// This will be in the range [1, 10]. +/// \param[in] force_quantity_upperbound The upper bounds of each parameter. This must +/// be a list of items with length = number_of_params +/// \remarks This must return within 2 minutes. +function force_crystal(number_of_crystals, number_of_params, force_quantity_upperbound) { + if (length(force_quantity_upperbound) !== number_of_params) { + return "Insufficient upper bounds for number of parameters"; + } else {} + + //We have a few algorithms for deciding on ONE parameter of each crystal. + //The fastest is a binary search. But that would require log2(param) * + //number_of_params crystals. + //The slowest but most crystal-preserving algorithm is a linear search + //from the minimum bound to the maximum bound. + //So we need to take a hybrid of both. Since we are given at least N*3 + //crystals, we will use the binary search first to reduce our search area + //then use linear search to find the parameter that breaks. + + //The next problem is deciding how many crystals we want to allocate for + //each parameter. Naively, since we have 3*N crystals, we would allocate + //number_of_crystals / number_of_params crystals for this task. + + /// Determines one parameter of the crystal. + /// \param[in] number_of_crystals Number of crystals allocated for this + /// parameter. + /// \param[in] determined_force_quantities The list of quantities which we have + /// already determined. We are determining + /// the next one in this function. + /// \param[in] quantity_upperbound The upper bound for the current parameter. + /// \return A pair, containing the parameter as head, and tail as the number + /// of crystals left. The parameter is the precise maximum which cannot be + /// exceeded. + function determine_one_parameter(number_of_crystals, determined_force_quantities, quantity_upperbound) { + search_log("Determining bounds in [0, " + quantity_upperbound + "]"); + + /// Helper to call force_aura with the information we're provided. + /// \param[in] The parameter to attempt on the crystal. + function force_aura_helper(this_param) { + var attempt = append( + append(determined_force_quantities, list(this_param)), + build_list( + number_of_params - length(determined_force_quantities) - 1, + function(x) { + return 0; + } + ) + ); + + error_on(length(attempt) !== number_of_params, "FORCE_AURA_WRONG_PARAM"); + return force_aura(attempt); + } + + /// \param[in] min The inclusive minimum value of the range + /// \param[in] max The inclusive maximum value of the range + /// \remark This function must only break at most ONE crystal. + function linear_search(min, max) { + search_log("LSearch: " + min + ", " + max); + error_on(min > max, "Bounds inconsistent"); + if (min === max) { + //We got our answer + return min; + } else { + if (force_aura_helper(min + 1)) { + //Crystal doesn't break, try next + return linear_search(min + 1, max); + } else { + //Crystal broke. One less than min. + return min; + } + } + } + + /// \param[in] min The inclusive minimum value of the range + /// \param[in] max The inclusive maximum value of the range + function binary_split(number_of_crystals_left, min, max) { + search_log("BSearch: " + number_of_crystals_left + ", " + min + ", " + max); + error_on(number_of_crystals_left === 0, "Used all crystals allocated"); + if (min === max) { + //We got our answer! + return pair(max, number_of_crystals_left); + } else if (number_of_crystals_left === 1 || min + 1 === max) { + //If we only have one crystal left, we need to use linear search. + //This is also used to tie-break when we only have two solutions. + return pair(linear_search(min, max), number_of_crystals_left - 1); + } else { + //We still have spare crystals. Try to test the midpoint. + var midpoint = Math.floor((min + max) / 2); + + if (force_aura_helper(midpoint)) { + //The crystal didn't break. Test the upper half of the range. + return binary_split(number_of_crystals_left, midpoint, max); + } else { + //The crystal broke. The maximum param is one less than our midpoint. + return binary_split(number_of_crystals_left - 1, min, midpoint - 1); + } + } + } + + return binary_split(number_of_crystals, 0, quantity_upperbound); + } + + /// This allocates crystals for solving a parameter. + /// \param[in] number_of_crystals_left The number of crystals left + /// \param[in] determined_force_quantities The values we've already determined. + /// \param[in] force_quantity_upperbounds The upper bounds of the remaining parameters + /// to determine. + /// \return A list of parameters number_of_params long. + function determine_parameters(number_of_crystals_left, determined_force_quantities, force_quantity_upperbounds) { + //Bail out if we are done. + if (is_empty_list(force_quantity_upperbounds)) { + return determined_force_quantities; + } else {} + + //Calculate how many crystals we want to allocate to this element. + var remaining_search_bounds = accumulate( + function(x, y) { return x + y; }, + 0, + force_quantity_upperbounds + ); + var wanted_allocation = Math.floor(head(force_quantity_upperbounds) / + remaining_search_bounds * number_of_crystals_left) + 1; + var crystals_for_this_try = Math.min( + Math.max(wanted_allocation, 2), + number_of_crystals_left); + var parameter = determine_one_parameter(crystals_for_this_try, + determined_force_quantities, + head(force_quantity_upperbounds)); + console_log("Parameter: " + head(parameter) + ", " + tail(parameter) + "/" + crystals_for_this_try + " crystals left"); + + return determine_parameters( + number_of_crystals_left - (crystals_for_this_try - tail(parameter)), + append(determined_force_quantities, list(head(parameter))), + tail(force_quantity_upperbounds)); + } + + //list(1, 5, 3) for the 3 parameters. + var result = determine_parameters(number_of_crystals, [], force_quantity_upperbound); + console_log(result); + error_on(!force_aura_finalise(result), "Wrong answer"); +} + +//force_crystal(1, 1, list(10)); +start_test(10, 2, list(10, 10), list(3, 8)); +display("\r\n"); + +//Test binary search fallback with small sizes +start_test(6, 2, list(4, 4), list(1, 2)); +display("\r\n"); + +//Test binary search with odd number of hops. +start_test(10, 2, list(9, 9), list(3, 8)); +display("\r\n"); + +//Test cases. +//If the params are equal to upper bounds, we should not break ANY crystal. +start_test(10, 2, list(500000, 500000), list(500000, 500000)); +display("\r\n"); + +//Test transition to linear search +start_test(6, 2, list(25000, 100000), list(24995, 50000)); +display("\r\n"); + +//Larger number of parameters +start_test(21, 7, list(12500, 100000, 100000,100000,100000,100000,100000), list(11395, 50000, 21738, 31210, 87432, 69543, 54734)); +display("\r\n"); + +//Larger number of parameters +start_test(30, 7, list(12500, 135000, 100000,24000,100000,100000,40000), list(11395, 132504, 21738, 23950, 87432, 69543, 24103)); +display("\r\n"); + +//Larger number of parameters +start_test(21, 7, list(12500, 51000, 25000, 32000, 90000, 70000, 55000), list(11395, 50000, 21738, 31210, 87432, 69543, 54734)); +display("\r\n"); + +//Skewed data set +//Larger number of parameters +start_test(21, 7, list(12500, 10, 10, 10, 10, 10,500000), list(11395, 7, 3, 1, 2, 0, 253734)); +display("\r\n"); diff --git a/src/stdlib/metacircular-interpreter/tests/unit_tests.html b/src/stdlib/metacircular-interpreter/tests/unit_tests.html new file mode 100644 index 000000000..af1e48a0f --- /dev/null +++ b/src/stdlib/metacircular-interpreter/tests/unit_tests.html @@ -0,0 +1,788 @@ + + + + + JediScript Meta-circular evaluator + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ +
+ + + + + + +
+ +
+ +
+ +
+ + + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+
+ +
+ + + + + + + + + + + +
+ +
+ + + + + +
+ + diff --git a/src/stdlib/misc.ts b/src/stdlib/misc.ts index 32e5bc5c5..0b9a33942 100644 --- a/src/stdlib/misc.ts +++ b/src/stdlib/misc.ts @@ -38,6 +38,46 @@ export function is_number(v: Value) { } is_number.__SOURCE__ = 'is_number(v)' +export function is_undefined(xs: Value) { + return typeof xs === 'undefined' +} +is_undefined.__SOURCE__ = 'is_undefined(xs)' + +export function is_string(xs: Value) { + return typeof xs === 'string' +} +is_string.__SOURCE__ = 'is_string(xs)' + +export function is_boolean(xs: Value) { + return typeof xs === 'boolean' +} +is_boolean.__SOURCE__ = 'is_boolean(xs)' + +export function is_object(xs: Value) { + return typeof xs === 'object' || is_function(xs) +} +is_object.__SOURCE__ = 'is_object(xs)' + +export function is_function(xs: Value) { + return typeof xs === 'function' +} +is_function.__SOURCE__ = 'is_function(xs)' + +export function is_NaN(x: Value) { + return is_number(x) && isNaN(x) +} +is_NaN.__SOURCE__ = 'is_NaN(x)' + +export function has_own_property(obj: Value, p: Value) { + return obj.hasOwnProperty(p) +} +has_own_property.__SOURCE__ = 'has_own_property(obj, p)' + +export function is_array(a: Value) { + return a instanceof Array +} +is_array.__SOURCE__ = 'is_array(a)' + export function array_length(xs: Value[]) { return xs.length } diff --git a/src/stdlib/parser.js b/src/stdlib/parser.js new file mode 100644 index 000000000..979ece094 --- /dev/null +++ b/src/stdlib/parser.js @@ -0,0 +1,1101 @@ +/* tslint:disable */ +/** To generate this, see the /metacircular-interpreter folder. */ + +/* parser generated by jison 0.4.18 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +export default function createParser() { +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[2,2],$V1=[1,3],$V2=[1,5],$V3=[1,9],$V4=[1,25],$V5=[1,14],$V6=[1,15],$V7=[1,16],$V8=[1,21],$V9=[1,20],$Va=[1,17],$Vb=[1,18],$Vc=[1,19],$Vd=[1,23],$Ve=[1,22],$Vf=[1,24],$Vg=[1,28],$Vh=[1,30],$Vi=[1,31],$Vj=[1,32],$Vk=[1,33],$Vl=[1,34],$Vm=[1,35],$Vn=[1,37],$Vo=[1,38],$Vp=[1,39],$Vq=[1,40],$Vr=[1,29],$Vs=[5,9],$Vt=[5,6,8,9,13,15,22,23,24,25,27,28,30,31,34,35,39,49,57,58,59,60,61,62,64,65,66,67,73],$Vu=[1,51],$Vv=[1,52],$Vw=[1,53],$Vx=[1,54],$Vy=[1,55],$Vz=[1,56],$VA=[1,57],$VB=[1,58],$VC=[1,59],$VD=[1,60],$VE=[1,61],$VF=[1,62],$VG=[1,63],$VH=[1,64],$VI=[1,65],$VJ=[1,66],$VK=[1,67],$VL=[1,69],$VM=[2,78],$VN=[6,9,17,26,34,35,36,37,38,40,41,42,43,44,45,46,47,49,50,51,55,56,69],$VO=[2,49],$VP=[1,85],$VQ=[1,84],$VR=[2,69],$VS=[1,94],$VT=[6,9,17,26,34,35,36,37,38,40,41,42,43,44,45,46,47,50,55,56,69],$VU=[1,125],$VV=[17,50],$VW=[6,9,17,26,34,35,40,41,42,43,44,45,46,47,50,55,56,69],$VX=[6,9,17,26,40,41,42,43,50,55,56,69],$VY=[6,9,17,26,40,41,42,43,44,45,46,47,50,55,56,69],$VZ=[8,15,34,35,39,49,57,58,59,60,61,62,64,65,66,67,73],$V_=[6,9,17,26,50,56,69]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"program":3,"statements":4,"EOF":5,";":6,"statement":7,"{":8,"}":9,"ifstatement":10,"whilestatement":11,"forstatement":12,"function":13,"identifier":14,"(":15,"identifiers":16,")":17,"constdeclaration":18,"letdeclaration":19,"assignment":20,"expression":21,"return":22,"break":23,"continue":24,"let":25,"=":26,"const":27,"if":28,"else":29,"while":30,"for":31,"forinitialiser":32,"forfinaliser":33,"+":34,"-":35,"*":36,"/":37,"%":38,"!":39,"&&":40,"||":41,"===":42,"!==":43,">":44,"<":45,">=":46,"<=":47,"=>":48,"[":49,"]":50,".":51,"constants":52,"expressions":53,"pairs":54,"?":55,":":56,"FLOAT_NUMBER":57,"INT_NUMBER":58,"true":59,"false":60,"NaN":61,"Infinity":62,"quotedstring":63,"emptylist":64,"EmptyString":65,"QuotedString":66,"QuotedStringEscape":67,"nonemptyexpressions":68,",":69,"nonemptypairs":70,"pair":71,"nonemptyidentifiers":72,"Identifier":73,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",6:";",8:"{",9:"}",13:"function",15:"(",17:")",22:"return",23:"break",24:"continue",25:"let",26:"=",27:"const",28:"if",29:"else",30:"while",31:"for",34:"+",35:"-",36:"*",37:"/",38:"%",39:"!",40:"&&",41:"||",42:"===",43:"!==",44:">",45:"<",46:">=",47:"<=",48:"=>",49:"[",50:"]",51:".",55:"?",56:":",57:"FLOAT_NUMBER",58:"INT_NUMBER",59:"true",60:"false",61:"NaN",62:"Infinity",64:"emptylist",65:"EmptyString",66:"QuotedString",67:"QuotedStringEscape",69:",",73:"Identifier"}, +productions_: [0,[3,2],[4,0],[4,1],[4,2],[4,3],[7,1],[7,1],[7,1],[7,8],[7,1],[7,1],[7,2],[7,2],[7,3],[7,2],[7,2],[19,5],[18,5],[20,3],[10,11],[10,9],[11,7],[12,10],[32,1],[32,2],[33,1],[21,3],[21,3],[21,3],[21,3],[21,3],[21,2],[21,2],[21,2],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,5],[21,3],[21,4],[21,3],[21,3],[21,1],[21,1],[21,6],[21,3],[21,3],[21,4],[21,5],[52,1],[52,1],[52,1],[52,1],[52,1],[52,1],[52,1],[52,1],[63,1],[63,1],[63,1],[63,2],[63,2],[53,1],[53,0],[68,3],[68,1],[54,1],[54,0],[70,3],[70,1],[71,3],[16,1],[16,0],[72,3],[72,1],[14,1]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: + return $$[$0-1]; +break; +case 2: case 3: case 69: case 73: case 78: + this.$ = []; +break; +case 4: + this.$ = pair($$[$0-1], $$[$0]); +break; +case 5: + + this.$ = { + tag: 'block', + body: $$[$0-1] + }; + +break; +case 9: + + this.$ = { + tag: 'constant_declaration', + name: $$[$0-6], + value: { + tag: 'function_definition', + parameters: $$[$0-4], + body: $$[$0-1], + line: yylineno, + location: { + start_line: _$[$0-7].first_line, + start_col: _$[$0-7].first_column, + end_line: _$[$0].first_line, + end_col: _$[$0].first_column + } + }, + line: yylineno + }; + +break; +case 14: + + this.$ = { + tag: 'return_statement', + expression: $$[$0-1], + line: yylineno + }; + +break; +case 15: + + this.$ = { + tag: 'break_statement', + line: yylineno + }; + +break; +case 16: + + this.$ = { + tag: 'continue_statement', + line: yylineno + }; + +break; +case 17: + + this.$ = { + tag: 'variable_declaration', + name: $$[$0-3], + value: $$[$0-1], + line: yylineno + }; + +break; +case 18: + + this.$ = { + tag: 'constant_declaration', + name: $$[$0-3], + value: $$[$0-1], + line: yylineno + }; + +break; +case 19: + + if ($$[$0-2].tag === 'name') { + this.$ = { + tag: 'assignment', + name: $$[$0-2], + value: $$[$0], + line: yylineno + }; + + } else if ($$[$0-2].tag === 'property_access') { + this.$ = { + tag: 'property_assignment', + object: $$[$0-2].object, + property: $$[$0-2].property, + value: $$[$0], + line: yylineno + }; + + } else { + error('parse error in line ' + yylineno + ": " + yytext); + } + +break; +case 20: + + this.$ = { + tag: 'conditional_statement', + predicate: $$[$0-8], + consequent: { tag: 'block', body: $$[$0-5] }, + alternative: { tag: 'block', body: $$[$0-1] }, + line: yylineno + }; + +break; +case 21: + + this.$ = { + tag: 'conditional_statement', + predicate: $$[$0-6], + consequent: { tag: 'block', body: $$[$0-3] }, + alternative: pair($$[$0], []), + line: yylineno + }; + +break; +case 22: + + this.$ = { + tag: 'while_loop', + predicate: $$[$0-4], + statements: { tag: 'block', body: $$[$0-1] }, + line: yylineno + }; + +break; +case 23: + + this.$ = { + tag: 'for_loop', + initialiser: $$[$0-7], + predicate: $$[$0-6], + finaliser: $$[$0-4], + statements: { tag: 'block', body: $$[$0-1] }, + line: yylineno + }; + +break; +case 27: case 28: case 29: case 30: case 31: case 37: case 38: case 39: case 40: case 41: case 42: + + this.$ = { + tag: 'application', + operator: { + tag: 'name', + name: $$[$0-1], + line: yylineno + }, + operands: [$$[$0-2], [$$[$0], []]], + line: yylineno + }; + +break; +case 32: case 33: + + this.$ = { + tag: 'application', + operator: { + tag: 'name', + name: $$[$0-1], + line: yylineno + }, + operands: [0, [$$[$0], []]], + line: yylineno + }; + +break; +case 34: + + this.$ = { + tag: 'application', + operator: { + tag: 'name', + name: $$[$0-1], + line: yylineno + }, + operands: [$$[$0], []], + line: yylineno + }; + +break; +case 35: case 36: + + this.$ = { + tag: 'boolean_operation', + operator: $$[$0-1], + operands: [$$[$0-2], [$$[$0], []]], + line: yylineno + }; + +break; +case 43: + + this.$ = { + tag: 'function_definition', + parameters: $$[$0-3], + body: { tag: 'return_statement', expression: $$[$0], + line: yylineno }, + line: yylineno, + location: { + start_line: _$[$0-4].first_line, + start_col: _$[$0-4].first_column, + end_line: _$[$0].first_line, + end_col: _$[$0].first_column + } + }; + +break; +case 44: + + this.$ = { + tag: 'function_definition', + parameters: [$$[$0-2], [] ], + body: { tag: 'return_statement', expression: $$[$0], + line: yylineno }, + line: yylineno, + location: { + start_line: _$[$0-2].first_line, + start_col: _$[$0-2].first_column, + end_line: _$[$02].first_line, + end_col: _$[$02].first_column + } + }; + +break; +case 45: + + this.$ = { + tag: 'property_access', + object: $$[$0-3], + property: $$[$0-1], + line: yylineno + }; + +break; +case 46: + + this.$ = { + tag: 'property_access', + object: $$[$0-2], + property: $$[$0], + line: yylineno + }; + +break; +case 47: +this.$ = $$[$0-1]; +break; +case 49: + + this.$ = { + tag: 'name', + name: $$[$0], + line: yylineno + }; + +break; +case 50: + + this.$ = { + tag: 'application', + operator: $$[$0-4], + operands: $$[$0-1], + line: yylineno + }; + +break; +case 51: + + this.$ = { + tag: 'array_expression', + elements: $$[$0-1], + line: yylineno + }; + +break; +case 52: + + this.$ = { + tag: 'object_expression', + pairs: $$[$0-1], + line: yylineno + }; + +break; +case 53: + + this.$ = { + tag: 'application', + operator: { + tag: 'name', + name: $$[$0-3], + line: yylineno + }, + operands: $$[$0-1], + line: yylineno + }; + +break; +case 54: + + this.$ = { + tag: 'conditional_expression', + predicate: $$[$0-4], + consequent: $$[$0-2], + alternative: $$[$0], + line: yylineno + }; + +break; +case 55: + this.$ = parseFloat(yytext); +break; +case 56: + this.$ = parseInt(yytext, 10); +break; +case 57: + this.$ = true; +break; +case 58: + this.$ = false; +break; +case 59: + this.$ = NaN; +break; +case 60: + this.$ = Infinity; +break; +case 62: + this.$ = { tag: 'empty_list', line: yylineno }; +break; +case 63: + + this.$ = ''; + +break; +case 65: + + switch (yytext) + { + case 'b': this.$ = '\b'; break; + case 'n': this.$ = '\n'; break; + case 'r': this.$ = '\r'; break; + case 't': this.$ = '\t'; break; + case "'": this.$ = "'"; break; + case '"': this.$ = '"'; break; + case '\\': this.$ = '\\'; break; + case '\n': + case '\r\n': this.$ = ''; break; + default: this.$ = '\\' + $$[$0]; break; + } + +break; +case 66: + + switch ($$[$0-1]) + { + case 'b': this.$ = '\b'; break; + case 'n': this.$ = '\n'; break; + case 'r': this.$ = '\r'; break; + case 't': this.$ = '\t'; break; + case "'": this.$ = "'"; break; + case '"': this.$ = '"'; break; + case '\\': this.$ = '\\'; break; + case '\n': + case '\r\n': this.$ = ''; break; + default: this.$ = '\\' + $$[$0-1]; break; + } + this.$ += $$[$0]; + +break; +case 67: + + this.$ = $$[$0-1] + $$[$0]; + +break; +case 68: case 72: case 77: + this.$ = $$[$0]; +break; +case 70: case 74: case 76: case 79: + this.$ = [ $$[$0-2], $$[$0] ]; +break; +case 71: case 75: case 80: + this.$ = [ $$[$0], [] ]; +break; +case 81: + this.$ = yytext; +break; +} +}, +table: [{3:1,4:2,5:$V0,6:$V1,7:4,8:$V2,10:6,11:7,12:8,13:$V3,14:26,15:$V4,18:10,19:11,20:12,21:13,22:$V5,23:$V6,24:$V7,25:$V8,27:$V9,28:$Va,30:$Vb,31:$Vc,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{1:[3]},{5:[1,41]},o($Vs,[2,3]),o($Vs,$V0,{7:4,10:6,11:7,12:8,18:10,19:11,20:12,21:13,14:26,52:27,63:36,4:42,6:$V1,8:$V2,13:$V3,15:$V4,22:$V5,23:$V6,24:$V7,25:$V8,27:$V9,28:$Va,30:$Vb,31:$Vc,34:$Vd,35:$Ve,39:$Vf,49:$Vg,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr}),{4:43,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:47,15:$V4,18:10,19:11,20:12,21:13,22:$V5,23:$V6,24:$V7,25:$V8,27:$V9,28:$Va,30:$Vb,31:$Vc,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,54:44,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,70:45,71:46,73:$Vr},o($Vt,[2,6]),o($Vt,[2,7]),o($Vt,[2,8]),{14:48,73:$Vr},o($Vt,[2,10]),o($Vt,[2,11]),{6:[1,49]},{6:[1,50],26:$Vu,34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK},{8:$VL,14:26,15:$V4,21:68,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{6:[1,70]},{6:[1,71]},{15:[1,72]},{15:[1,73]},{15:[1,74]},{14:75,73:$Vr},{14:76,73:$Vr},{8:$VL,14:26,15:$V4,21:77,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:78,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:79,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:83,15:$V4,16:80,17:$VM,21:81,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,72:82,73:$Vr},o($VN,$VO,{15:$VP,48:$VQ}),o($VN,[2,48]),{8:$VL,14:26,15:$V4,21:88,34:$Vd,35:$Ve,39:$Vf,49:$Vg,50:$VR,52:27,53:86,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,68:87,73:$Vr},o([6,9,15,17,26,34,35,36,37,38,40,41,42,43,44,45,46,47,48,49,50,51,55,56,69],[2,81]),o($VN,[2,55]),o($VN,[2,56]),o($VN,[2,57]),o($VN,[2,58]),o($VN,[2,59]),o($VN,[2,60]),o($VN,[2,61]),o($VN,[2,62]),o($VN,[2,63]),o($VN,[2,64],{63:89,65:$Vo,66:$Vp,67:$Vq}),o($VN,[2,65],{63:90,65:$Vo,66:$Vp,67:$Vq}),{1:[2,1]},o($Vs,[2,4]),{9:[1,91]},{9:[1,92]},{9:[2,72]},{9:[2,75],69:[1,93]},o([6,26,34,35,36,37,38,40,41,42,43,44,45,46,47,49,51,55],$VO,{15:$VP,48:$VQ,56:$VS}),{15:[1,95]},o($Vt,[2,12]),o($Vt,[2,13]),{8:$VL,14:26,15:$V4,21:96,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:97,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:98,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:99,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:100,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:101,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:102,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:103,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:104,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:105,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:106,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:107,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:108,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:109,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:110,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{14:111,73:$Vr},{8:$VL,14:26,15:$V4,21:112,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{6:[1,113],34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK},{9:[2,73],14:114,54:44,70:45,71:46,73:$Vr},o($Vt,[2,15]),o($Vt,[2,16]),{8:$VL,14:26,15:$V4,21:115,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:116,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,19:118,20:119,21:120,25:$V8,32:117,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{26:[1,121]},{26:[1,122]},o($VT,[2,32],{49:$VI,51:$VJ}),o($VT,[2,33],{49:$VI,51:$VJ}),o($VT,[2,34],{49:$VI,51:$VJ}),{17:[1,123]},{17:[1,124],34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK},{17:[2,77]},o([17,34,35,36,37,38,40,41,42,43,44,45,46,47,49,51,55],$VO,{15:$VP,48:$VQ,69:$VU}),{8:$VL,14:26,15:$V4,21:126,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,17:$VR,21:88,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,53:127,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,68:87,73:$Vr},{50:[1,128]},o($VV,[2,68]),o($VV,[2,71],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK,69:[1,129]}),o($VN,[2,67]),o($VN,[2,66]),o($Vs,[2,5]),o($VN,[2,52]),{14:114,70:130,71:46,73:$Vr},{8:$VL,14:26,15:$V4,21:131,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{14:133,16:132,17:$VM,72:82,73:$Vr},o([6,17],[2,19],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK}),o($VW,[2,27],{36:$Vx,37:$Vy,38:$Vz,49:$VI,51:$VJ}),o($VW,[2,28],{36:$Vx,37:$Vy,38:$Vz,49:$VI,51:$VJ}),o($VT,[2,29],{49:$VI,51:$VJ}),o($VT,[2,30],{49:$VI,51:$VJ}),o($VT,[2,31],{49:$VI,51:$VJ}),o([6,9,17,26,40,41,50,55,56,69],[2,35],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ}),o([6,9,17,26,41,50,55,56,69],[2,36],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ}),o($VX,[2,37],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ}),o($VX,[2,38],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ}),o($VY,[2,39],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,49:$VI,51:$VJ}),o($VY,[2,40],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,49:$VI,51:$VJ}),o($VY,[2,41],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,49:$VI,51:$VJ}),o($VY,[2,42],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,49:$VI,51:$VJ}),{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,50:[1,134],51:$VJ,55:$VK},o($VN,[2,46]),{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK,56:[1,135]},o($Vt,[2,14]),{56:$VS},{17:[1,136],34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK},{17:[1,137],34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK},{8:$VL,14:26,15:$V4,21:138,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},o($VZ,[2,24]),{6:[1,139]},{26:$Vu,34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK},{8:$VL,14:26,15:$V4,21:140,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,21:141,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{48:[1,142]},o($VN,[2,47],{15:[1,143]}),{14:133,72:144,73:$Vr},o($V_,[2,44],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK}),{17:[1,145]},o($VN,[2,51]),{8:$VL,14:26,15:$V4,21:88,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,68:146,73:$Vr},{9:[2,74]},o([9,69],[2,76],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK}),{17:[1,147]},{17:[2,80],69:$VU},o($VN,[2,45]),{8:$VL,14:26,15:$V4,21:148,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:[1,149]},{8:[1,150]},{6:[1,151],34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK},o($VZ,[2,25]),{6:[1,152],34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK},{6:[1,153],34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK},{8:$VL,14:26,15:$V4,21:154,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,17:$VR,21:88,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,53:155,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,68:87,73:$Vr},{17:[2,79]},o($VN,[2,53]),o($VV,[2,70]),{8:[1,156]},o($V_,[2,54],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK}),{4:157,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:26,15:$V4,18:10,19:11,20:12,21:13,22:$V5,23:$V6,24:$V7,25:$V8,27:$V9,28:$Va,30:$Vb,31:$Vc,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{4:158,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:26,15:$V4,18:10,19:11,20:12,21:13,22:$V5,23:$V6,24:$V7,25:$V8,27:$V9,28:$Va,30:$Vb,31:$Vc,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{8:$VL,14:26,15:$V4,20:160,21:120,33:159,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},o($Vt,[2,18]),o($Vt,[2,17]),o($V_,[2,43],{34:$Vv,35:$Vw,36:$Vx,37:$Vy,38:$Vz,40:$VA,41:$VB,42:$VC,43:$VD,44:$VE,45:$VF,46:$VG,47:$VH,49:$VI,51:$VJ,55:$VK}),{17:[1,161]},{4:162,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:26,15:$V4,18:10,19:11,20:12,21:13,22:$V5,23:$V6,24:$V7,25:$V8,27:$V9,28:$Va,30:$Vb,31:$Vc,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{9:[1,163]},{9:[1,164]},{17:[1,165]},{17:[2,26]},o($VN,[2,50]),{9:[1,166]},{29:[1,167]},o($Vt,[2,22]),{8:[1,168]},o($Vt,[2,9]),{8:[1,169],10:170,28:$Va},{4:171,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:26,15:$V4,18:10,19:11,20:12,21:13,22:$V5,23:$V6,24:$V7,25:$V8,27:$V9,28:$Va,30:$Vb,31:$Vc,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},{4:172,6:$V1,7:4,8:$V2,9:$V0,10:6,11:7,12:8,13:$V3,14:26,15:$V4,18:10,19:11,20:12,21:13,22:$V5,23:$V6,24:$V7,25:$V8,27:$V9,28:$Va,30:$Vb,31:$Vc,34:$Vd,35:$Ve,39:$Vf,49:$Vg,52:27,57:$Vh,58:$Vi,59:$Vj,60:$Vk,61:$Vl,62:$Vm,63:36,64:$Vn,65:$Vo,66:$Vp,67:$Vq,73:$Vr},o($Vt,[2,21]),{9:[1,173]},{9:[1,174]},o($Vt,[2,23]),o($Vt,[2,20])], +defaultActions: {41:[2,1],45:[2,72],82:[2,77],130:[2,74],144:[2,79],160:[2,26]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else if (hash.loc && hash.line) { + throw new SyntaxError(str, hash.loc, hash.line); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + var lex = function () { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + }; + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:/* skip single-line comments */ +break; +case 1:/* skip multi-line comments */ +break; +case 2:/* skip whitespace */ +break; +case 3:return 13 +break; +case 4:return 22 +break; +case 5:return 28 +break; +case 6:return 29 +break; +case 7:return 30 +break; +case 8:return 31 +break; +case 9:return 23 +break; +case 10:return 24 +break; +case 11:return 25 +break; +case 12:return 27 +break; +case 13:return 42 +break; +case 14:return 48 +break; +case 15:return 26 +break; +case 16:return 8 +break; +case 17:return 9 +break; +case 18:return 6 +break; +case 19:return 69 +break; +case 20:return 59 +break; +case 21:return 60 +break; +case 22:return 61 +break; +case 23:return 62 +break; +case 24:return 64 +break; +case 25:return 49 +break; +case 26:return 50 +break; +case 27:return 51 +break; +case 28:return 65 +break; +case 29:return 65 +break; +case 30:this.begin('DoubleQuotedString'); +break; +case 31:this.begin('SingleQuotedString'); +break; +case 32:this.begin('QuotedStringEscape'); +break; +case 33:this.popState(); +break; +case 34:this.popState(); +break; +case 35: this.popState(); return 67; +break; +case 36:return 66; +break; +case 37:return 66; +break; +case 38:return 73 /* TODO: non-ASCII identifiers */ +break; +case 39:return 57 /* 3.1, 3.1e-7 */ +break; +case 40:return 58 +break; +case 41:return 34 +break; +case 42:return 35 +break; +case 43:return 36 +break; +case 44:return 37 +break; +case 45:return 38 +break; +case 46:return 43 +break; +case 47:return 47 +break; +case 48:return 46 +break; +case 49:return 45 +break; +case 50:return 44 +break; +case 51:return 39 +break; +case 52:return 40 +break; +case 53:return 41 +break; +case 54:return 15 +break; +case 55:return 17 +break; +case 56:return 55 +break; +case 57:return 56 +break; +case 58:return 5 +break; +case 59:return 'INVALID' +break; +} +}, +rules: [/^(?:\/\/([^\n\r]*))/,/^(?:\/\*([\u0000-\uffff]*?)\*\/)/,/^(?:\s+)/,/^(?:function\b)/,/^(?:return\b)/,/^(?:if\b)/,/^(?:else\b)/,/^(?:while\b)/,/^(?:for\b)/,/^(?:break\b)/,/^(?:continue\b)/,/^(?:let\b)/,/^(?:const\b)/,/^(?:===)/,/^(?:=>)/,/^(?:=)/,/^(?:\{)/,/^(?:\})/,/^(?:;)/,/^(?:,)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:NaN\b)/,/^(?:Infinity\b)/,/^(?:\[\])/,/^(?:\[)/,/^(?:\])/,/^(?:\.)/,/^(?:"")/,/^(?:'')/,/^(?:")/,/^(?:')/,/^(?:\\)/,/^(?:")/,/^(?:')/,/^(?:(.|\r\n|\n))/,/^(?:[^"\\]*)/,/^(?:[^'\\]*)/,/^(?:[A-Za-z_][A-Za-z0-9_]*)/,/^(?:[0-9]+(\.[0-9]+)?([eE][\-+]?[0-9]+)?\b)/,/^(?:[0-9]+\b)/,/^(?:\+)/,/^(?:-)/,/^(?:\*)/,/^(?:\/)/,/^(?:%)/,/^(?:!==)/,/^(?:<=)/,/^(?:>=)/,/^(?:<)/,/^(?:>)/,/^(?:!)/,/^(?:&&)/,/^(?:\|\|)/,/^(?:\()/,/^(?:\))/,/^(?:\?)/,/^(?::)/,/^(?:$)/,/^(?:.)/], +conditions: {"QuotedStringEscape":{"rules":[35],"inclusive":false},"SingleQuotedString":{"rules":[32,34,37],"inclusive":false},"DoubleQuotedString":{"rules":[32,33,36],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +} diff --git a/src/types.ts b/src/types.ts index ea499389c..6b4fd8fc5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -110,6 +110,9 @@ export interface Context { /** The external symbols that exist in the Context. */ externalSymbols: string[] + /** The Parser used for meta-circular evaluation */ + metaCircularParser: any + /** All the errors gathered */ errors: SourceError[] diff --git a/tsconfig.json b/tsconfig.json index 9b827b7c5..7fee346dc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,6 +25,8 @@ "noUnusedLocals": true }, "exclude": [ + "src/stdlib/metacircular-interpreter", + "src/stdlib/**/*.js", "node_modules", "dist" ], diff --git a/yarn.lock b/yarn.lock index ccbd1b978..851c38fbe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -285,6 +285,117 @@ babel-generator@^6.18.0, babel-generator@^6.26.0: source-map "^0.5.7" trim-right "^1.0.1" +babel-helper-bindify-decorators@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-bindify-decorators/-/babel-helper-bindify-decorators-6.24.1.tgz#14c19e5f142d7b47f19a52431e52b1ccbc40a330" + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" + dependencies: + babel-helper-explode-assignable-expression "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-call-delegate@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-define-map@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz#a5f56dab41a25f97ecb498c7ebaca9819f95be5f" + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-helper-explode-assignable-expression@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-explode-class@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-explode-class/-/babel-helper-explode-class-6.24.1.tgz#7dc2a3910dee007056e1e31d640ced3d54eaa9eb" + dependencies: + babel-helper-bindify-decorators "^6.24.1" + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-function-name@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" + dependencies: + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-get-function-arity@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-hoist-variables@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-optimise-call-expression@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-regex@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz#325c59f902f82f24b74faceed0363954f6495e72" + dependencies: + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-helper-remap-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-replace-supers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" + dependencies: + babel-helper-optimise-call-expression "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + babel-helpers@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" @@ -305,6 +416,12 @@ babel-messages@^6.23.0: dependencies: babel-runtime "^6.22.0" +babel-plugin-check-es2015-constants@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" + dependencies: + babel-runtime "^6.22.0" + babel-plugin-istanbul@^4.1.6: version "4.1.6" resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.6.tgz#36c59b2192efce81c5b378321b74175add1c9a45" @@ -318,10 +435,298 @@ babel-plugin-jest-hoist@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.2.0.tgz#e61fae05a1ca8801aadee57a6d66b8cefaf44167" -babel-plugin-syntax-object-rest-spread@^6.13.0: +babel-plugin-syntax-async-functions@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" + +babel-plugin-syntax-async-generators@^6.5.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-generators/-/babel-plugin-syntax-async-generators-6.13.0.tgz#6bc963ebb16eccbae6b92b596eb7f35c342a8b9a" + +babel-plugin-syntax-class-properties@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz#d7eb23b79a317f8543962c505b827c7d6cac27de" + +babel-plugin-syntax-decorators@^6.13.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz#312563b4dbde3cc806cee3e416cceeaddd11ac0b" + +babel-plugin-syntax-dynamic-import@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz#8d6a26229c83745a9982a441051572caa179b1da" + +babel-plugin-syntax-exponentiation-operator@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" + +babel-plugin-syntax-object-rest-spread@^6.13.0, babel-plugin-syntax-object-rest-spread@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5" +babel-plugin-syntax-trailing-function-commas@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" + +babel-plugin-transform-async-generator-functions@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-generator-functions/-/babel-plugin-transform-async-generator-functions-6.24.1.tgz#f058900145fd3e9907a6ddf28da59f215258a5db" + dependencies: + babel-helper-remap-async-to-generator "^6.24.1" + babel-plugin-syntax-async-generators "^6.5.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" + dependencies: + babel-helper-remap-async-to-generator "^6.24.1" + babel-plugin-syntax-async-functions "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-class-properties@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz#6a79763ea61d33d36f37b611aa9def81a81b46ac" + dependencies: + babel-helper-function-name "^6.24.1" + babel-plugin-syntax-class-properties "^6.8.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-decorators@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-decorators/-/babel-plugin-transform-decorators-6.24.1.tgz#788013d8f8c6b5222bdf7b344390dfd77569e24d" + dependencies: + babel-helper-explode-class "^6.24.1" + babel-plugin-syntax-decorators "^6.13.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-arrow-functions@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz#bbc51b49f964d70cb8d8e0b94e820246ce3a6141" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoping@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" + dependencies: + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-plugin-transform-es2015-classes@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" + dependencies: + babel-helper-define-map "^6.24.1" + babel-helper-function-name "^6.24.1" + babel-helper-optimise-call-expression "^6.24.1" + babel-helper-replace-supers "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-computed-properties@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-destructuring@^6.22.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-duplicate-keys@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-for-of@^6.22.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-function-name@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-literals@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz#4f54a02d6cd66cf915280019a31d31925377ca2e" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-modules-amd@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" + dependencies: + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-commonjs@^6.24.1: + version "6.26.2" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3" + dependencies: + babel-plugin-transform-strict-mode "^6.24.1" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-types "^6.26.0" + +babel-plugin-transform-es2015-modules-systemjs@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-umd@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" + dependencies: + babel-plugin-transform-es2015-modules-amd "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-object-super@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" + dependencies: + babel-helper-replace-supers "^6.24.1" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-parameters@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" + dependencies: + babel-helper-call-delegate "^6.24.1" + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-shorthand-properties@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-spread@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-sticky-regex@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-template-literals@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz#a84b3450f7e9f8f1f6839d6d687da84bb1236d8d" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-typeof-symbol@^6.22.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-unicode-regex@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + regexpu-core "^2.0.0" + +babel-plugin-transform-exponentiation-operator@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" + dependencies: + babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" + babel-plugin-syntax-exponentiation-operator "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-object-rest-spread@^6.22.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz#0f36692d50fef6b7e2d4b3ac1478137a963b7b06" + dependencies: + babel-plugin-syntax-object-rest-spread "^6.8.0" + babel-runtime "^6.26.0" + +babel-plugin-transform-regenerator@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" + dependencies: + regenerator-transform "^0.10.0" + +babel-plugin-transform-strict-mode@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-preset-es2015@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939" + dependencies: + babel-plugin-check-es2015-constants "^6.22.0" + babel-plugin-transform-es2015-arrow-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoping "^6.24.1" + babel-plugin-transform-es2015-classes "^6.24.1" + babel-plugin-transform-es2015-computed-properties "^6.24.1" + babel-plugin-transform-es2015-destructuring "^6.22.0" + babel-plugin-transform-es2015-duplicate-keys "^6.24.1" + babel-plugin-transform-es2015-for-of "^6.22.0" + babel-plugin-transform-es2015-function-name "^6.24.1" + babel-plugin-transform-es2015-literals "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.24.1" + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-plugin-transform-es2015-modules-systemjs "^6.24.1" + babel-plugin-transform-es2015-modules-umd "^6.24.1" + babel-plugin-transform-es2015-object-super "^6.24.1" + babel-plugin-transform-es2015-parameters "^6.24.1" + babel-plugin-transform-es2015-shorthand-properties "^6.24.1" + babel-plugin-transform-es2015-spread "^6.22.0" + babel-plugin-transform-es2015-sticky-regex "^6.24.1" + babel-plugin-transform-es2015-template-literals "^6.22.0" + babel-plugin-transform-es2015-typeof-symbol "^6.22.0" + babel-plugin-transform-es2015-unicode-regex "^6.24.1" + babel-plugin-transform-regenerator "^6.24.1" + babel-preset-jest@^23.0.0, babel-preset-jest@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-23.2.0.tgz#8ec7a03a138f001a1a8fb1e8113652bf1a55da46" @@ -329,6 +734,25 @@ babel-preset-jest@^23.0.0, babel-preset-jest@^23.2.0: babel-plugin-jest-hoist "^23.2.0" babel-plugin-syntax-object-rest-spread "^6.13.0" +babel-preset-stage-2@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-preset-stage-2/-/babel-preset-stage-2-6.24.1.tgz#d9e2960fb3d71187f0e64eec62bc07767219bdc1" + dependencies: + babel-plugin-syntax-dynamic-import "^6.18.0" + babel-plugin-transform-class-properties "^6.24.1" + babel-plugin-transform-decorators "^6.24.1" + babel-preset-stage-3 "^6.24.1" + +babel-preset-stage-3@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-preset-stage-3/-/babel-preset-stage-3-6.24.1.tgz#836ada0a9e7a7fa37cb138fb9326f87934a48395" + dependencies: + babel-plugin-syntax-trailing-function-commas "^6.22.0" + babel-plugin-transform-async-generator-functions "^6.24.1" + babel-plugin-transform-async-to-generator "^6.24.1" + babel-plugin-transform-exponentiation-operator "^6.24.1" + babel-plugin-transform-object-rest-spread "^6.22.0" + babel-register@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" @@ -341,7 +765,7 @@ babel-register@^6.26.0: mkdirp "^0.5.1" source-map-support "^0.4.15" -babel-runtime@^6.22.0, babel-runtime@^6.26.0, babel-runtime@^6.9.2: +babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0, babel-runtime@^6.9.2: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" dependencies: @@ -358,7 +782,7 @@ babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: babylon "^6.18.0" lodash "^4.17.4" -babel-traverse@^6.0.0, babel-traverse@^6.18.0, babel-traverse@^6.26.0: +babel-traverse@^6.0.0, babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" dependencies: @@ -372,7 +796,7 @@ babel-traverse@^6.0.0, babel-traverse@^6.18.0, babel-traverse@^6.26.0: invariant "^2.2.2" lodash "^4.17.4" -babel-types@^6.0.0, babel-types@^6.18.0, babel-types@^6.26.0: +babel-types@^6.0.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" dependencies: @@ -1934,6 +2358,10 @@ jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" +jsesc@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + json-schema-traverse@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" @@ -2556,7 +2984,7 @@ pretty-format@^23.2.0: ansi-regex "^3.0.0" ansi-styles "^3.2.0" -private@^0.1.8: +private@^0.1.6, private@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -2650,10 +3078,22 @@ realpath-native@^1.0.0: dependencies: util.promisify "^1.0.0" +regenerate@^1.2.1: + version "1.4.0" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11" + regenerator-runtime@^0.11.0: version "0.11.1" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" +regenerator-transform@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd" + dependencies: + babel-runtime "^6.18.0" + babel-types "^6.19.0" + private "^0.1.6" + regex-cache@^0.4.2: version "0.4.4" resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" @@ -2667,6 +3107,24 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" +regexpu-core@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" + dependencies: + regenerate "^1.2.1" + regjsgen "^0.2.0" + regjsparser "^0.1.4" + +regjsgen@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" + +regjsparser@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" + dependencies: + jsesc "~0.5.0" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"