This commit is contained in:
Vyacheslav Matyukhin 2022-09-10 21:01:04 +04:00
parent ecc82ba8f7
commit fe56e81710
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
15 changed files with 345 additions and 452 deletions

View File

@ -0,0 +1,30 @@
#!/usr/bin/env node
const s = require("./dist/src/js");
const fs = require("fs");
const measure = (cb, times = 1) => {
const t1 = new Date();
for (let i = 1; i <= times; i++) {
cb();
}
const t2 = new Date();
return (t2 - t1) / 1000;
};
const maxP = 0;
const bioSrc = fs.readFileSync(
"/Users/berekuk/Downloads/Bio.squiggle",
"utf-8"
);
for (let p = 0; p <= maxP; p++) {
const size = Math.pow(10, p);
const prj = s.SqProject.create();
prj.setSource("main", bioSrc);
const t = measure(() => {
prj.run("main");
});
console.log(`1e${p}`, "\t", t);
}

27
packages/squiggle-lang/bench.js Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env node
const s = require("./dist/src/js");
const measure = (cb, times = 1) => {
const t1 = new Date();
for (let i = 1; i <= times; i++) {
cb();
}
const t2 = new Date();
return (t2 - t1) / 1000;
};
const maxP = 7;
for (let p = 0; p <= maxP; p++) {
const size = Math.pow(10, p);
const prj = s.SqProject.create();
prj.setSource("list", `l = List.upTo(1,${size})`);
prj.run("list");
prj.setSource("map", "l |> map({|x| x})");
prj.setContinues("map", ["list"]);
const t = measure(() => {
prj.run("map");
});
console.log(`1e${p}`, "\t", t);
}

View File

@ -13,4 +13,4 @@ let toString = (v: squiggleValue_Module): string =>
let toSquiggleValue = (v: squiggleValue_Module): squiggleValue => IEvBindings(v)
@genType
let get = ReducerInterface_InternalExpressionValue.nameSpaceGet
let get = Reducer_Bindings.get

View File

@ -13,23 +13,23 @@ type t = ReducerInterface_InternalExpressionValue.nameSpace
let typeAliasesKey = "_typeAliases_"
let typeReferencesKey = "_typeReferences_"
let getType = (NameSpace(container): t, id: string) => {
Belt.Map.String.get(container, typeAliasesKey)->Belt.Option.flatMap(aliases =>
switch aliases {
| IEvRecord(r) => Belt.Map.String.get(r, id)
| _ => None
}
)
}
// let getType = (NameSpace(container): t, id: string) => {
// Belt.Map.String.get(container, typeAliasesKey)->Belt.Option.flatMap(aliases =>
// switch aliases {
// | IEvRecord(r) => Belt.Map.String.get(r, id)
// | _ => None
// }
// )
// }
let getTypeOf = (NameSpace(container): t, id: string) => {
Belt.Map.String.get(container, typeReferencesKey)->Belt.Option.flatMap(defs =>
switch defs {
| IEvRecord(r) => Belt.Map.String.get(r, id)
| _ => None
}
)
}
// let getTypeOf = (NameSpace(container): t, id: string) => {
// Belt.Map.String.get(container, typeReferencesKey)->Belt.Option.flatMap(defs =>
// switch defs {
// | IEvRecord(r) => Belt.Map.String.get(r, id)
// | _ => None
// }
// )
// }
let getWithDefault = (NameSpace(container): t, id: string, default) =>
switch Belt.Map.String.get(container, id) {
@ -37,29 +37,40 @@ let getWithDefault = (NameSpace(container): t, id: string, default) =>
| None => default
}
let get = (NameSpace(container): t, id: string) => Belt.Map.String.get(container, id)
let get = (nameSpace: t, id: string) => {
let NameSpace(container, parent) = nameSpace
switch container->Belt.MutableMap.String.get(key) {
| Some(v) => Some(v)
| None => switch parent {
| Some(p) => nameSpaceGet(p, key)
| None => None
}
}
}
let emptyMap: map = Belt.Map.String.empty
let setTypeAlias = (NameSpace(container): t, id: string, value): t => {
let rValue = Belt.Map.String.getWithDefault(container, typeAliasesKey, IEvRecord(emptyMap))
let r = switch rValue {
| IEvRecord(r) => r
| _ => emptyMap
}
let r2 = Belt.Map.String.set(r, id, value)->IEvRecord
NameSpace(Belt.Map.String.set(container, typeAliasesKey, r2))
}
// let setTypeAlias = (NameSpace(container): t, id: string, value): t => {
// let rValue = Belt.Map.String.getWithDefault(container, typeAliasesKey, IEvRecord(emptyMap))
// let r = switch rValue {
// | IEvRecord(r) => r
// | _ => emptyMap
// }
// let r2 = Belt.Map.String.set(r, id, value)->IEvRecord
// NameSpace(Belt.Map.String.set(container, typeAliasesKey, r2))
// }
let setTypeOf = (NameSpace(container): t, id: string, value): t => {
let rValue = Belt.Map.String.getWithDefault(container, typeReferencesKey, IEvRecord(emptyMap))
let r = switch rValue {
| IEvRecord(r) => r
| _ => emptyMap
}
let r2 = Belt.Map.String.set(r, id, value)->IEvRecord
NameSpace(Belt.Map.String.set(container, typeReferencesKey, r2))
}
// let setTypeOf = (NameSpace(container): t, id: string, value): t => {
// let rValue = Belt.Map.String.getWithDefault(container, typeReferencesKey, IEvRecord(emptyMap))
// let r = switch rValue {
// | IEvRecord(r) => r
// | _ => emptyMap
// }
// let r2 = Belt.Map.String.set(r, id, value)->IEvRecord
// NameSpace(Belt.Map.String.set(container, typeReferencesKey, r2))
// }
let set = (NameSpace(container): t, id: string, value): t => NameSpace(
Belt.Map.String.set(container, id, value),
@ -69,9 +80,6 @@ let emptyModule: t = NameSpace(emptyMap)
let emptyBindings = emptyModule
let emptyNameSpace = emptyModule
// let fromTypeScriptBindings = ReducerInterface_InternalExpressionValue.nameSpaceFromTypeScriptBindings
// let toTypeScriptBindings = ReducerInterface_InternalExpressionValue.nameSpaceToTypeScriptBindings
let toExpressionValue = (nameSpace: t): internalExpressionValue => IEvBindings(nameSpace)
let fromExpressionValue = (aValue: internalExpressionValue): t =>
switch aValue {

View File

@ -89,14 +89,14 @@ let callInternal = (
Bindings.set(bindings, symbol, value)->IEvBindings->Ok
}
let doSetTypeAliasBindings = (
bindings: nameSpace,
symbol: string,
value: internalExpressionValue,
) => Bindings.setTypeAlias(bindings, symbol, value)->IEvBindings->Ok
// let doSetTypeAliasBindings = (
// bindings: nameSpace,
// symbol: string,
// value: internalExpressionValue,
// ) => Bindings.setTypeAlias(bindings, symbol, value)->IEvBindings->Ok
let doSetTypeOfBindings = (bindings: nameSpace, symbol: string, value: internalExpressionValue) =>
Bindings.setTypeOf(bindings, symbol, value)->IEvBindings->Ok
// let doSetTypeOfBindings = (bindings: nameSpace, symbol: string, value: internalExpressionValue) =>
// Bindings.setTypeOf(bindings, symbol, value)->IEvBindings->Ok
let doExportBindings = (bindings: nameSpace) => bindings->Bindings.toExpressionValue->Ok
@ -153,30 +153,30 @@ let callInternal = (
| ("$_exportBindings_$", [evValue]) => doIdentity(evValue)
| ("$_setBindings_$", [IEvBindings(nameSpace), IEvSymbol(symbol), value]) =>
doSetBindings(nameSpace, symbol, value)
| ("$_setTypeAliasBindings_$", [IEvBindings(nameSpace), IEvTypeIdentifier(symbol), value]) =>
doSetTypeAliasBindings(nameSpace, symbol, value)
| ("$_setTypeOfBindings_$", [IEvBindings(nameSpace), IEvSymbol(symbol), value]) =>
doSetTypeOfBindings(nameSpace, symbol, value)
// | ("$_setTypeAliasBindings_$", [IEvBindings(nameSpace), IEvTypeIdentifier(symbol), value]) =>
// doSetTypeAliasBindings(nameSpace, symbol, value)
// | ("$_setTypeOfBindings_$", [IEvBindings(nameSpace), IEvSymbol(symbol), value]) =>
// doSetTypeOfBindings(nameSpace, symbol, value)
| ("$_dumpBindings_$", [IEvBindings(nameSpace), _, evValue]) => doDumpBindings(nameSpace, evValue)
| ("$_typeModifier_memberOf_$", [IEvTypeIdentifier(typeIdentifier), IEvArray(arr)]) =>
TypeBuilder.typeModifier_memberOf(IEvTypeIdentifier(typeIdentifier), IEvArray(arr))
| ("$_typeModifier_memberOf_$", [IEvType(typeRecord), IEvArray(arr)]) =>
TypeBuilder.typeModifier_memberOf_update(typeRecord, IEvArray(arr))
| ("$_typeModifier_min_$", [IEvTypeIdentifier(typeIdentifier), value]) =>
TypeBuilder.typeModifier_min(IEvTypeIdentifier(typeIdentifier), value)
| ("$_typeModifier_min_$", [IEvType(typeRecord), value]) =>
TypeBuilder.typeModifier_min_update(typeRecord, value)
| ("$_typeModifier_max_$", [IEvTypeIdentifier(typeIdentifier), value]) =>
TypeBuilder.typeModifier_max(IEvTypeIdentifier(typeIdentifier), value)
| ("$_typeModifier_max_$", [IEvType(typeRecord), value]) =>
TypeBuilder.typeModifier_max_update(typeRecord, value)
| ("$_typeModifier_opaque_$", [IEvType(typeRecord)]) =>
TypeBuilder.typeModifier_opaque_update(typeRecord)
| ("$_typeOr_$", [IEvArray(arr)]) => TypeBuilder.typeOr(IEvArray(arr))
| ("$_typeFunction_$", [IEvArray(arr)]) => TypeBuilder.typeFunction(arr)
| ("$_typeTuple_$", [IEvArray(elems)]) => TypeBuilder.typeTuple(elems)
| ("$_typeArray_$", [elem]) => TypeBuilder.typeArray(elem)
| ("$_typeRecord_$", [IEvRecord(propertyMap)]) => TypeBuilder.typeRecord(propertyMap)
// | ("$_typeModifier_memberOf_$", [IEvTypeIdentifier(typeIdentifier), IEvArray(arr)]) =>
// TypeBuilder.typeModifier_memberOf(IEvTypeIdentifier(typeIdentifier), IEvArray(arr))
// | ("$_typeModifier_memberOf_$", [IEvType(typeRecord), IEvArray(arr)]) =>
// TypeBuilder.typeModifier_memberOf_update(typeRecord, IEvArray(arr))
// | ("$_typeModifier_min_$", [IEvTypeIdentifier(typeIdentifier), value]) =>
// TypeBuilder.typeModifier_min(IEvTypeIdentifier(typeIdentifier), value)
// | ("$_typeModifier_min_$", [IEvType(typeRecord), value]) =>
// TypeBuilder.typeModifier_min_update(typeRecord, value)
// | ("$_typeModifier_max_$", [IEvTypeIdentifier(typeIdentifier), value]) =>
// TypeBuilder.typeModifier_max(IEvTypeIdentifier(typeIdentifier), value)
// | ("$_typeModifier_max_$", [IEvType(typeRecord), value]) =>
// TypeBuilder.typeModifier_max_update(typeRecord, value)
// | ("$_typeModifier_opaque_$", [IEvType(typeRecord)]) =>
// TypeBuilder.typeModifier_opaque_update(typeRecord)
// | ("$_typeOr_$", [IEvArray(arr)]) => TypeBuilder.typeOr(IEvArray(arr))
// | ("$_typeFunction_$", [IEvArray(arr)]) => TypeBuilder.typeFunction(arr)
// | ("$_typeTuple_$", [IEvArray(elems)]) => TypeBuilder.typeTuple(elems)
// | ("$_typeArray_$", [elem]) => TypeBuilder.typeArray(elem)
// | ("$_typeRecord_$", [IEvRecord(propertyMap)]) => TypeBuilder.typeRecord(propertyMap)
| ("concat", [IEvArray(aValueArray), IEvArray(bValueArray)]) =>
doAddArray(aValueArray, bValueArray)
| ("concat", [IEvString(aValueString), IEvString(bValueString)]) =>
@ -204,12 +204,19 @@ let dispatch = (
): internalExpressionValue =>
try {
let (fn, args) = call
// There is a bug that prevents string match in patterns
// So we have to recreate a copy of the string
if fn->Js.String2.startsWith("$") {
switch callInternal((fn, args), accessors, reducer) {
| Ok(v) => v
| Error(e) => raise(ErrorException(e))
}
} else {
// There is a bug that prevents string match in patterns
// So we have to recreate a copy of the string
switch ExternalLibrary.dispatch((Js.String.make(fn), args), accessors, reducer, callInternal) {
| Ok(v) => v
| Error(e) => raise(ErrorException(e))
}
}
} catch {
| ErrorException(e) => raise(ErrorException(e))
| Js.Exn.Error(obj) =>

View File

@ -47,13 +47,13 @@ let dispatchMacroCall = (
let doBindStatement = (bindingExpr: expression, statement: expression, accessors) => {
let defaultStatement = ErrorValue.REAssignmentExpected->ErrorException
switch statement {
| ExpressionT.EList(list{ExpressionT.EValue(IEvCall(callName)), symbolExpr, statement}) => {
| ExpressionT.EList(list{ExpressionT.EValue(IEvCall(callName)), ExpressionT.EValue(IEvSymbol(symbolExpr)), statement}) => {
let setBindingsFn = correspondingSetBindingsFn(callName)
if setBindingsFn !== "" {
useExpressionToSetBindings(bindingExpr, accessors, statement, (
newBindingsExpr,
boundStatement,
) => eFunction(setBindingsFn, list{newBindingsExpr, symbolExpr, boundStatement}))
) => eFunction(setBindingsFn, list{newBindingsExpr, symbolExpr->IEvSymbol->ExpressionT.EValue, boundStatement}))
} else {
raise(defaultStatement)
}

View File

@ -19,37 +19,43 @@ exception ErrorException = Reducer_ErrorValue.ErrorException
/*
Recursively evaluate/reduce the expression (Lisp AST/Lambda calculus)
*/
let rec reduceExpressionInProject = (
let rec evaluate = (
expression: t,
continuation: T.bindings,
bindings: T.bindings,
accessors: ProjectAccessorsT.t,
): InternalExpressionValue.t => {
// Js.log(`reduce: ${T.toString(expression)} bindings: ${bindings->Bindings.toString}`)
// Js.log(`reduce: ${T.toString(expression)}`)
switch expression {
| T.EValue(value) => value
| T.EList(list) =>
switch list {
| list{EValue(IEvCall(fName)), ..._args} =>
switch Macro.isMacroName(fName) {
// A macro expands then reduces itself
| true => Macro.doMacroCall(expression, continuation, accessors, reduceExpressionInProject)
| false => reduceExpressionList(list, continuation, accessors)
| T.Eblock(statements) => {
statements->Js.Array2.reduce(statement => evaluate(statement, bindings, accessors))
}
| T.ESymbol(name) => bindings->nameSpaceGet(name)
| T.EValue(value) => value
| T.ETernary(predicate, trueCase, falseCase) => {
let predicateResult = evaluate(predicate, bindings, accessors)
switch predicateResult {
| InternalExpressionValue.IEvBool(false) =>
evaluate(false, bindings, accessors)
| InternalExpressionValue.IEvBool(true) =>
evaluate(trueCase, bindings, accessors)
| _ => REExpectedType("Boolean", "")->ErrorException->raise
}
| _ => reduceExpressionList(list, continuation, accessors)
}
| T.ELambda(parameteres, expr) => {
BInternalExpressionValue.IEvLambda({
parameters: parameters,
context: context,
body: NotFFI(expr)->BBindings.castExpressionToInternalCode,
})->T.EValue
}
| T.ECall(fn, args) => {
let func = evaluate(fn, bindings, accessors)
"TODO"
// Lambda.doLambdaCall(), etc.
}
}
}
and reduceExpressionList = (
expressions: list<t>,
continuation: T.bindings,
accessors: ProjectAccessorsT.t,
): InternalExpressionValue.t => {
let acc: list<InternalExpressionValue.t> =
expressions->Belt.List.reduceReverse(list{}, (acc, each: t) =>
acc->Belt.List.add(each->reduceExpressionInProject(continuation, accessors))
)
acc->reduceValueList(accessors)
}
/*
After reducing each level of expression(Lisp AST), we have a value list to evaluate
@ -80,6 +86,8 @@ and reduceValueList = (
| _ => valueList->Lambda.checkIfReduced->Belt.List.toArray->InternalExpressionValue.IEvArray
}
let reduceExpressionInProject = evaluate
let reduceReturningBindings = (
expression: t,
continuation: T.bindings,

View File

@ -1,86 +1,63 @@
module BBindingsReplacer = Reducer_Expression_BindingsReplacer
module BErrorValue = Reducer_ErrorValue
module BExpressionT = Reducer_Expression_T
module T = Reducer_Expression_T
module BInternalExpressionValue = ReducerInterface_InternalExpressionValue
module BBindings = Reducer_Bindings
type errorValue = BErrorValue.errorValue
type expression = BExpressionT.expression
type expressionOrFFI = BExpressionT.expressionOrFFI
type ffiFn = BExpressionT.ffiFn
type expression = T.expression
type expressionOrFFI = T.expressionOrFFI
type ffiFn = T.ffiFn
type internalCode = ReducerInterface_InternalExpressionValue.internalCode
let eArray = anArray => anArray->BInternalExpressionValue.IEvArray->BExpressionT.EValue
let eArray = anArray => anArray->BInternalExpressionValue.IEvArray->T.EValue
let eArrayString = anArray => anArray->BInternalExpressionValue.IEvArrayString->BExpressionT.EValue
let eArrayString = anArray => anArray->BInternalExpressionValue.IEvArrayString->T.EValue
let eBindings = (anArray: array<(string, BInternalExpressionValue.t)>) =>
anArray->BBindings.fromArray->BBindings.toExpressionValue->BExpressionT.EValue
anArray->BBindings.fromArray->BBindings.toExpressionValue->T.EValue
let eBool = aBool => aBool->BInternalExpressionValue.IEvBool->BExpressionT.EValue
let eBool = aBool => aBool->BInternalExpressionValue.IEvBool->T.EValue
let eCall = (name: string): expression =>
name->BInternalExpressionValue.IEvCall->BExpressionT.EValue
name->BInternalExpressionValue.IEvCall->T.EValue
let eFunction = (fName: string, lispArgs: list<expression>): expression => {
let fn = fName->eCall
list{fn, ...lispArgs}->BExpressionT.EList
list{fn, ...lispArgs}->T.EList
}
let eLambda = (
parameters: array<string>,
context: BInternalExpressionValue.nameSpace,
expr: expression,
) => {
BInternalExpressionValue.IEvLambda({
parameters: parameters,
context: context,
body: NotFFI(expr)->BBindings.castExpressionToInternalCode,
})->BExpressionT.EValue
}
T.ELambda(parameters, expr)
let eLambdaFFI = (ffiFn: ffiFn) => {
ffiFn->BBindings.eLambdaFFIValue->BExpressionT.EValue
}
let eNumber = aNumber => aNumber->BInternalExpressionValue.IEvNumber->T.EValue
let eNumber = aNumber => aNumber->BInternalExpressionValue.IEvNumber->BExpressionT.EValue
let eRecord = aMap => aMap->BInternalExpressionValue.IEvRecord->T.EValue
let eRecord = aMap => aMap->BInternalExpressionValue.IEvRecord->BExpressionT.EValue
let eString = aString => aString->BInternalExpressionValue.IEvString->BExpressionT.EValue
let eString = aString => aString->BInternalExpressionValue.IEvString->T.EValue
let eSymbol = (name: string): expression =>
name->BInternalExpressionValue.IEvSymbol->BExpressionT.EValue
T.ESymbol(name)
let eList = (list: list<expression>): expression => list->BExpressionT.EList
let eBlock = (exprs: list<expression>): expression => eFunction("$$_block_$$", exprs)
let eBlock = (exprs: array<expression>): expression =>
T.EBlock(exprs)
let eModule = (nameSpace: BInternalExpressionValue.nameSpace): expression =>
nameSpace->BInternalExpressionValue.IEvBindings->BExpressionT.EValue
nameSpace->BInternalExpressionValue.IEvBindings->T.EValue
let eLetStatement = (symbol: string, valueExpression: expression): expression =>
eFunction("$_let_$", list{eSymbol(symbol), valueExpression})
T.EAssign(symbol, valueExpression)
let eBindStatement = (bindingExpr: expression, letStatement: expression): expression =>
eFunction("$$_bindStatement_$$", list{bindingExpr, letStatement})
let eBindStatementDefault = (letStatement: expression): expression =>
eFunction("$$_bindStatement_$$", list{letStatement})
let eBindExpression = (bindingExpr: expression, expression: expression): expression =>
eFunction("$$_bindExpression_$$", list{bindingExpr, expression})
let eBindExpressionDefault = (expression: expression): expression =>
eFunction("$$_bindExpression_$$", list{expression})
let eTernary = (truth: expression, trueCase: expression, falseCase: expression): expression =>
eFunction("$$_ternary_$$", list{truth, trueCase, falseCase})
let eTernary = (predicate: expression, trueCase: expression, falseCase: expression): expression =>
T.ETernary(predicate, trueCase, falseCase)
let eIdentifier = (name: string): expression =>
name->BInternalExpressionValue.IEvSymbol->BExpressionT.EValue
name->BInternalExpressionValue.IEvSymbol->T.EValue
let eTypeIdentifier = (name: string): expression =>
name->BInternalExpressionValue.IEvTypeIdentifier->BExpressionT.EValue
name->BInternalExpressionValue.IEvTypeIdentifier->T.EValue
let eVoid: expression = BInternalExpressionValue.IEvVoid->BExpressionT.EValue
let eVoid: expression = BInternalExpressionValue.IEvVoid->T.EValue

View File

@ -13,8 +13,13 @@ type internalExpressionValue = InternalExpressionValue.t
type environment = ReducerInterface_InternalExpressionValue.environment
type rec expression =
| EList(list<expression>) // A list to map-reduce
| EValue(internalExpressionValue) // Irreducible built-in value. Reducer should not know the internals. External libraries are responsible
| EBlock(array<expression>)
| ESymbol(string)
| ETernary(expression, expression, expression)
| EAssign(string, expression)
| ECall(expression, array<expression>)
| ELambda(array<string>, expression)
| EValue(internalExpressionValue)
and bindings = InternalExpressionValue.nameSpace
type t = expression
@ -28,20 +33,20 @@ type reducerFn = (
/*
Converts the expression to String
*/
let rec toString = expression =>
switch expression {
| EList(list{EValue(IEvCall("$$_block_$$")), ...statements}) =>
`{${Belt.List.map(statements, aValue => toString(aValue))
->Extra.List.intersperse("; ")
->Belt.List.toArray
->Js.String.concatMany("")}}`
| EList(aList) =>
`(${Belt.List.map(aList, aValue => toString(aValue))
->Extra.List.intersperse(" ")
->Belt.List.toArray
->Js.String.concatMany("")})`
| EValue(aValue) => InternalExpressionValue.toString(aValue)
}
let rec toString = expression => "TODO"
// switch expression {
// | EList(list{EValue(IEvCall("$$_block_$$")), ...statements}) =>
// `{${Belt.List.map(statements, aValue => toString(aValue))
// ->Extra.List.intersperse("; ")
// ->Belt.List.toArray
// ->Js.String.concatMany("")}}`
// | EList(aList) =>
// `(${Belt.List.map(aList, aValue => toString(aValue))
// ->Extra.List.intersperse(" ")
// ->Belt.List.toArray
// ->Js.String.concatMany("")})`
// | EValue(aValue) => InternalExpressionValue.toString(aValue)
// }
let toStringResult = codeResult =>
switch codeResult {

View File

@ -168,7 +168,7 @@ chainFunctionCall
unary
= unaryOperator:unaryOperator _nl right:(unary/postOperator)
{ return h.apply(h.unaryToFunction[unaryOperator], right)}
{ return h.makeFunctionCall(h.unaryToFunction[unaryOperator], [right])}
/ postOperator
unaryOperator "unary operator"
@ -247,7 +247,7 @@ number = number:(float / integer) unit:unitIdentifier?
if (unit === null)
{ return number }
else
{ return h.apply('fromUnit_'+unit.value, number)
{ return h.makeFunctionCall('fromUnit_'+unit.value, [number])
}
}
@ -357,10 +357,10 @@ typePostModifierExpression = head:typeOr tail:(_ '$' _nl @typeModifier)*
}
typeOr = head:typeFunction tail:(_ '|' _nl @typeFunction)*
{ return tail.length === 0 ? head : h.apply('$_typeOr_$', h.constructArray([head, ...tail])); }
{ return tail.length === 0 ? head : h.makeFunctionCall('$_typeOr_$', [h.constructArray([head, ...tail])]); }
typeFunction = head:typeModifierExpression tail:(_ '=>' _nl @typeModifierExpression)*
{ return tail.length === 0 ? head : h.apply( '$_typeFunction_$', h.constructArray([head, ...tail])); }
{ return tail.length === 0 ? head : h.makeFunctionCall( '$_typeFunction_$', [h.constructArray([head, ...tail])]); }
typeModifierExpression = head:basicType tail:(_ '<-' _nl @typeModifier)*
{
@ -378,17 +378,17 @@ typeModifierExpression = head:basicType tail:(_ '<-' _nl @typeModifier)*
basicType = typeConstructor / typeArray / typeTuple / typeRecord / typeInParanthesis / typeIdentifier
typeArray = '[' _nl elem:typeExpression _nl ']'
{return h.apply('$_typeArray_$', elem)}
{return h.makeFunctionCall('$_typeArray_$', [elem])}
typeTuple = '[' _nl elems:array_typeTupleArguments _nl ']'
{ return h.apply('$_typeTuple_$', h.constructArray(elems))}
{ return h.makeFunctionCall('$_typeTuple_$', [h.constructArray(elems)])}
array_typeTupleArguments
= head:typeExpression tail:(_ ',' _nl @typeExpression)*
{ return [head, ...tail]; }
typeRecord = '{' _nl elems:array_typeRecordArguments _nl '}'
{ return h.apply('$_typeRecord_$', h.constructRecord(elems)); }
{ return h.makeFunctionCall('$_typeRecord_$', [h.constructRecord(elems)]); }
array_typeRecordArguments
= head:typeKeyValuePair tail:(_ ',' _nl @typeKeyValuePair)*

View File

@ -21,8 +21,7 @@ let parse = (expr: string): result<node, errorValue> =>
type nodeBlock = {...node, "statements": array<node>}
type nodeBoolean = {...node, "value": bool}
type nodeCallIdentifier = {...node, "value": string}
type nodeExpression = {...node, "nodes": array<node>}
type nodeCall = {...node, "fn": node, "args": array<node>}
type nodeFloat = {...node, "value": float}
type nodeIdentifier = {...node, "value": string}
type nodeInteger = {...node, "value": int}
@ -38,9 +37,8 @@ type nodeVoid = node
type peggyNode =
| PgNodeBlock(nodeBlock)
| PgNodeBoolean(nodeBoolean)
| PgNodeCallIdentifier(nodeCallIdentifier)
| PgNodeExpression(nodeExpression)
| PgNodeFloat(nodeFloat)
| PgNodeCall(nodeCall)
| PgNodeIdentifier(nodeIdentifier)
| PgNodeInteger(nodeInteger)
| PgNodeKeyValue(nodeKeyValue)
@ -54,8 +52,7 @@ type peggyNode =
external castNodeBlock: node => nodeBlock = "%identity"
external castNodeBoolean: node => nodeBoolean = "%identity"
external castNodeCallIdentifier: node => nodeCallIdentifier = "%identity"
external castNodeExpression: node => nodeExpression = "%identity"
external castNodeCall: node => nodeCall = "%identity"
external castNodeFloat: node => nodeFloat = "%identity"
external castNodeIdentifier: node => nodeIdentifier = "%identity"
external castNodeInteger: node => nodeInteger = "%identity"
@ -73,8 +70,7 @@ let castNodeType = (node: node) =>
switch node["type"] {
| "Block" => node->castNodeBlock->PgNodeBlock
| "Boolean" => node->castNodeBoolean->PgNodeBoolean
| "CallIdentifier" => node->castNodeCallIdentifier->PgNodeCallIdentifier
| "Expression" => node->castNodeExpression->PgNodeExpression
| "Call" => node->castNodeCall->PgNodeCall
| "Float" => node->castNodeFloat->PgNodeFloat
| "Identifier" => node->castNodeIdentifier->PgNodeIdentifier
| "Integer" => node->castNodeInteger->PgNodeInteger
@ -99,8 +95,7 @@ let rec pgToString = (peggyNode: peggyNode): string => {
switch peggyNode {
| PgNodeBlock(node) => "{" ++ node["statements"]->nodesToStringUsingSeparator("; ") ++ "}"
| PgNodeBoolean(node) => node["value"]->Js.String.make
| PgNodeCallIdentifier(node) => `::${Js.String.make(node["value"])}` // This is an identifier also but for function names
| PgNodeExpression(node) => "(" ++ node["nodes"]->nodesToStringUsingSeparator(" ") ++ ")"
| PgNodeCall(node) => "(" ++ node["fn"]->toString ++ " " ++ node["args"]->nodesToStringUsingSeparator(" ") ++ ")"
| PgNodeFloat(node) => node["value"]->Js.String.make
| PgNodeIdentifier(node) => `:${node["value"]}`
| PgNodeInteger(node) => node["value"]->Js.String.make

View File

@ -6,23 +6,22 @@ type expression = ExpressionT.expression
let rec fromNode = (node: Parse.node): expression => {
let caseBlock = nodeBlock =>
ExpressionBuilder.eBlock(nodeBlock["statements"]->Js.Array2.map(fromNode)->Belt.List.fromArray)
ExpressionBuilder.eBlock(nodeBlock["statements"]->Js.Array2.map(fromNode))
let caseLambda = (nodeLambda: Parse.nodeLambda): expression => {
let args =
nodeLambda["args"]
->Js.Array2.map((argNode: Parse.nodeIdentifier) => argNode["value"])
->ExpressionBuilder.eArrayString
let body = nodeLambda["body"]->caseBlock
ExpressionBuilder.eFunction("$$_lambda_$$", list{args, body})
ExpressionBuilder.eLambda(args, body)
}
switch Parse.castNodeType(node) {
| PgNodeBlock(nodeBlock) => caseBlock(nodeBlock)
| PgNodeBoolean(nodeBoolean) => ExpressionBuilder.eBool(nodeBoolean["value"])
| PgNodeCallIdentifier(nodeCallIdentifier) => ExpressionBuilder.eCall(nodeCallIdentifier["value"])
| PgNodeExpression(nodeExpression) =>
ExpressionT.EList(nodeExpression["nodes"]->Js.Array2.map(fromNode)->Belt.List.fromArray)
ExpressionT.EList(nodeExpression["nodes"]->Js.Array2.map(fromNode))
| PgNodeFloat(nodeFloat) => ExpressionBuilder.eNumber(nodeFloat["value"])
| PgNodeIdentifier(nodeIdentifier) => ExpressionBuilder.eSymbol(nodeIdentifier["value"])
| PgNodeInteger(nodeInteger) => ExpressionBuilder.eNumber(Belt.Int.toFloat(nodeInteger["value"]))
@ -38,13 +37,10 @@ let rec fromNode = (node: Parse.node): expression => {
ExpressionBuilder.eIdentifier(nodeModuleIdentifier["value"])
| PgNodeString(nodeString) => ExpressionBuilder.eString(nodeString["value"])
| PgNodeTernary(nodeTernary) =>
ExpressionBuilder.eFunction(
"$$_ternary_$$",
list{
fromNode(nodeTernary["condition"]),
fromNode(nodeTernary["trueExpression"]),
fromNode(nodeTernary["falseExpression"]),
},
ExpressionBuilder.eTernary(
fromNode(nodeTernary["condition"]),
fromNode(nodeTernary["trueExpression"]),
fromNode(nodeTernary["falseExpression"])
)
| PgNodeTypeIdentifier(nodeTypeIdentifier) =>
ExpressionBuilder.eTypeIdentifier(nodeTypeIdentifier["value"])

View File

@ -40,9 +40,10 @@ type NodeBlock = {
statements: AnyPeggyNode[];
};
type NodeExpression = {
type: "Expression";
nodes: AnyPeggyNode[];
type NodeCall = {
type: "Call";
fn: AnyPeggyNode;
args: AnyPeggyNode[];
};
type NodeFloat = {
@ -58,12 +59,6 @@ type NodeInteger = {
type NodeIdentifier = {
type: "Identifier";
value: string;
location: LocationRange;
};
type NodeCallIdentifier = {
type: "CallIdentifier";
value: string;
};
type NodeLetStatement = {
@ -104,11 +99,10 @@ type NodeBoolean = {
export type AnyPeggyNode =
| NodeBlock
| NodeExpression
| NodeCall
| NodeFloat
| NodeInteger
| NodeIdentifier
| NodeCallIdentifier
| NodeLetStatement
| NodeLambda
| NodeTernary
@ -117,30 +111,14 @@ export type AnyPeggyNode =
| NodeBoolean;
export function makeFunctionCall(fn: string, args: AnyPeggyNode[]) {
if (fn === "$$_applyAll_$$") {
// Any list of values is applied from left to right anyway.
// Like in Haskell and Lisp.
// So we remove the redundant $$_applyAll_$$.
if (args[0].type === "Identifier") {
args[0] = {
...args[0],
type: "CallIdentifier",
};
}
return nodeExpression(args);
} else {
return nodeExpression([nodeCallIndentifier(fn), ...args]);
}
return nodeCall(nodeIdentifier(fn), args);
}
export function apply(fn: string, arg: AnyPeggyNode) {
return makeFunctionCall(fn, [arg]);
}
export function constructArray(elems: AnyPeggyNode[]) {
return makeFunctionCall("$_constructArray_$", elems);
}
export function constructRecord(elems: AnyPeggyNode[]) {
return apply("$_constructRecord_$", nodeExpression(elems));
return makeFunctionCall("$_constructRecord_$", elems);
}
export function nodeBlock(statements: AnyPeggyNode[]): NodeBlock {
@ -149,20 +127,14 @@ export function nodeBlock(statements: AnyPeggyNode[]): NodeBlock {
export function nodeBoolean(value: boolean): NodeBoolean {
return { type: "Boolean", value };
}
export function nodeCallIndentifier(value: string): NodeCallIdentifier {
return { type: "CallIdentifier", value };
}
export function nodeExpression(args: AnyPeggyNode[]): NodeExpression {
return { type: "Expression", nodes: args };
export function nodeCall(fn: AnyPeggyNode, args: AnyPeggyNode[]): NodeCall {
return { type: "Call", fn, args };
}
export function nodeFloat(value: number): NodeFloat {
return { type: "Float", value };
}
export function nodeIdentifier(
value: string,
location: LocationRange
): NodeIdentifier {
return { type: "Identifier", value, location };
export function nodeIdentifier(value: string): NodeIdentifier {
return { type: "Identifier", value };
}
export function nodeInteger(value: number): NodeInteger {
return { type: "Integer", value };

View File

@ -26,7 +26,7 @@ type rec t =
| IEvVoid
@genType.opaque and squiggleArray = array<t>
@genType.opaque and map = Belt.Map.String.t<t>
@genType.opaque and nameSpace = NameSpace(Belt.Map.String.t<t>)
@genType.opaque and nameSpace = NameSpace(Belt.MutableMap.String.t<t>, option<nameSpace>)
@genType.opaque
and lambdaValue = {
parameters: array<string>,
@ -94,7 +94,8 @@ and toStringMap = aMap => {
`{${pairs}}`
}
and toStringNameSpace = nameSpace => {
let NameSpace(container) = nameSpace
let NameSpace(container, parent) = nameSpace
FIXME_CALL_PARENTS
container->toStringMap
}
@ -228,19 +229,8 @@ let arrayToValueArray = (arr: array<t>): array<t> => arr
let recordToKeyValuePairs = (record: map): array<(string, t)> => record->Belt.Map.String.toArray
// let nameSpaceToTypeScriptBindings = (
// nameSpace: nameSpace,
// ) => {
// let NameSpace(container) = nameSpace
// Belt.Map.String.map(container, e => e->Belt.Map.String.toArray->Js.Dict.fromArray)
// }
let nameSpaceToKeyValuePairs = (nameSpace: nameSpace): array<(string, t)> => {
let NameSpace(container) = nameSpace
container->Belt.Map.String.toArray
}
let nameSpaceGet = (nameSpace: nameSpace, key: string): option<t> => {
let NameSpace(container) = nameSpace
container->Belt.Map.String.get(key)
let NameSpace(container, parent) = nameSpace
FIXME_CALL_PARENTS
container->Belt.MutableMap.String.toArray
}

View File

@ -5,9 +5,7 @@
"use strict";
function peg$subclass(child, parent) {
function C() {
this.constructor = child;
}
function C() { this.constructor = child; }
C.prototype = parent.prototype;
child.prototype = new C();
}
@ -29,15 +27,13 @@ peg$subclass(peg$SyntaxError, Error);
function peg$padEnd(str, targetLength, padString) {
padString = padString || " ";
if (str.length > targetLength) {
return str;
}
if (str.length > targetLength) { return str; }
targetLength -= str.length;
padString += padString.repeat(targetLength);
return str + padString.slice(0, targetLength);
}
peg$SyntaxError.prototype.format = function (sources) {
peg$SyntaxError.prototype.format = function(sources) {
var str = "Error: " + this.message;
if (this.location) {
var src = null;
@ -52,24 +48,15 @@ peg$SyntaxError.prototype.format = function (sources) {
var loc = this.location.source + ":" + s.line + ":" + s.column;
if (src) {
var e = this.location.end;
var filler = peg$padEnd("", s.line.toString().length, " ");
var filler = peg$padEnd("", s.line.toString().length, ' ');
var line = src[s.line - 1];
var last = s.line === e.line ? e.column : line.length + 1;
var hatLen = last - s.column || 1;
str +=
"\n --> " +
loc +
"\n" +
filler +
" |\n" +
s.line +
" | " +
line +
"\n" +
filler +
" | " +
peg$padEnd("", s.column - 1, " ") +
peg$padEnd("", hatLen, "^");
var hatLen = (last - s.column) || 1;
str += "\n --> " + loc + "\n"
+ filler + " |\n"
+ s.line + " | " + line + "\n"
+ filler + " | " + peg$padEnd("", s.column - 1, ' ')
+ peg$padEnd("", hatLen, "^");
} else {
str += "\n at " + loc;
}
@ -77,35 +64,33 @@ peg$SyntaxError.prototype.format = function (sources) {
return str;
};
peg$SyntaxError.buildMessage = function (expected, found) {
peg$SyntaxError.buildMessage = function(expected, found) {
var DESCRIBE_EXPECTATION_FNS = {
literal: function (expectation) {
return '"' + literalEscape(expectation.text) + '"';
literal: function(expectation) {
return "\"" + literalEscape(expectation.text) + "\"";
},
class: function (expectation) {
var escapedParts = expectation.parts.map(function (part) {
class: function(expectation) {
var escapedParts = expectation.parts.map(function(part) {
return Array.isArray(part)
? classEscape(part[0]) + "-" + classEscape(part[1])
: classEscape(part);
});
return (
"[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"
);
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
},
any: function () {
any: function() {
return "any character";
},
end: function () {
end: function() {
return "end of input";
},
other: function (expectation) {
other: function(expectation) {
return expectation.description;
},
}
};
function hex(ch) {
@ -115,17 +100,13 @@ peg$SyntaxError.buildMessage = function (expected, found) {
function literalEscape(s) {
return s
.replace(/\\/g, "\\\\")
.replace(/"/g, '\\"')
.replace(/"/g, "\\\"")
.replace(/\0/g, "\\0")
.replace(/\t/g, "\\t")
.replace(/\n/g, "\\n")
.replace(/\r/g, "\\r")
.replace(/[\x00-\x0F]/g, function (ch) {
return "\\x0" + hex(ch);
})
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return "\\x" + hex(ch);
});
.replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
}
function classEscape(s) {
@ -133,17 +114,13 @@ peg$SyntaxError.buildMessage = function (expected, found) {
.replace(/\\/g, "\\\\")
.replace(/\]/g, "\\]")
.replace(/\^/g, "\\^")
.replace(/-/g, "\\-")
.replace(/-/g, "\\-")
.replace(/\0/g, "\\0")
.replace(/\t/g, "\\t")
.replace(/\n/g, "\\n")
.replace(/\r/g, "\\r")
.replace(/[\x00-\x0F]/g, function (ch) {
return "\\x0" + hex(ch);
})
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return "\\x" + hex(ch);
});
.replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
}
function describeExpectation(expectation) {
@ -174,25 +151,17 @@ peg$SyntaxError.buildMessage = function (expected, found) {
return descriptions[0] + " or " + descriptions[1];
default:
return (
descriptions.slice(0, -1).join(", ") +
", or " +
descriptions[descriptions.length - 1]
);
return descriptions.slice(0, -1).join(", ")
+ ", or "
+ descriptions[descriptions.length - 1];
}
}
function describeFound(found) {
return found ? '"' + literalEscape(found) + '"' : "end of input";
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
}
return (
"Expected " +
describeExpected(expected) +
" but " +
describeFound(found) +
" found."
);
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
};
function peg$parse(input, options) {
@ -208,7 +177,7 @@ function peg$parse(input, options) {
var peg$c1 = "#include";
var peg$c2 = "as";
var peg$c3 = "'";
var peg$c4 = '"';
var peg$c4 = "\"";
var peg$c5 = "//";
var peg$c6 = "/*";
var peg$c7 = "*/";
@ -228,8 +197,8 @@ function peg$parse(input, options) {
var peg$e3 = peg$otherExpectation("string");
var peg$e4 = peg$literalExpectation("'", false);
var peg$e5 = peg$classExpectation(["'"], true, false);
var peg$e6 = peg$literalExpectation('"', false);
var peg$e7 = peg$classExpectation(['"'], true, false);
var peg$e6 = peg$literalExpectation("\"", false);
var peg$e7 = peg$classExpectation(["\""], true, false);
var peg$e8 = peg$otherExpectation("comment");
var peg$e9 = peg$literalExpectation("//", false);
var peg$e10 = peg$literalExpectation("/*", false);
@ -243,36 +212,16 @@ function peg$parse(input, options) {
var peg$e18 = peg$classExpectation(["\r", "\n"], true, false);
var peg$e19 = peg$otherExpectation("identifier");
var peg$e20 = peg$classExpectation(["_", ["a", "z"]], false, false);
var peg$e21 = peg$classExpectation(
["_", ["a", "z"], ["0", "9"]],
false,
true
);
var peg$e21 = peg$classExpectation(["_", ["a", "z"], ["0", "9"]], false, true);
var peg$f0 = function (head, tail) {
return [head, ...tail].filter((e) => e != "");
};
var peg$f1 = function () {
return [];
};
var peg$f2 = function (file, variable) {
return [!variable ? "" : variable, file];
};
var peg$f3 = function (characters) {
return characters.join("");
};
var peg$f4 = function (characters) {
return characters.join("");
};
var peg$f5 = function () {
return "";
};
var peg$f6 = function () {
return "";
};
var peg$f7 = function () {
return text();
};
var peg$f0 = function(head, tail) {return [head, ...tail].filter( e => e != '');};
var peg$f1 = function() {return [];};
var peg$f2 = function(file, variable) {return [!variable ? '' : variable, file]};
var peg$f3 = function(characters) {return characters.join('');};
var peg$f4 = function(characters) {return characters.join('');};
var peg$f5 = function() { return '';};
var peg$f6 = function() { return '';};
var peg$f7 = function() {return text();};
var peg$currPos = 0;
var peg$savedPos = 0;
var peg$posDetailsCache = [{ line: 1, column: 1 }];
@ -286,9 +235,7 @@ function peg$parse(input, options) {
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error(
"Can't start parsing from rule \"" + options.startRule + '".'
);
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
@ -306,7 +253,7 @@ function peg$parse(input, options) {
return {
source: peg$source,
start: peg$savedPos,
end: peg$currPos,
end: peg$currPos
};
}
@ -315,10 +262,9 @@ function peg$parse(input, options) {
}
function expected(description, location) {
location =
location !== undefined
? location
: peg$computeLocation(peg$savedPos, peg$currPos);
location = location !== undefined
? location
: peg$computeLocation(peg$savedPos, peg$currPos);
throw peg$buildStructuredError(
[peg$otherExpectation(description)],
@ -328,10 +274,9 @@ function peg$parse(input, options) {
}
function error(message, location) {
location =
location !== undefined
? location
: peg$computeLocation(peg$savedPos, peg$currPos);
location = location !== undefined
? location
: peg$computeLocation(peg$savedPos, peg$currPos);
throw peg$buildSimpleError(message, location);
}
@ -341,12 +286,7 @@ function peg$parse(input, options) {
}
function peg$classExpectation(parts, inverted, ignoreCase) {
return {
type: "class",
parts: parts,
inverted: inverted,
ignoreCase: ignoreCase,
};
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
}
function peg$anyExpectation() {
@ -376,7 +316,7 @@ function peg$parse(input, options) {
details = peg$posDetailsCache[p];
details = {
line: details.line,
column: details.column,
column: details.column
};
while (p < pos) {
@ -405,20 +345,18 @@ function peg$parse(input, options) {
start: {
offset: startPos,
line: startPosDetails.line,
column: startPosDetails.column,
column: startPosDetails.column
},
end: {
offset: endPos,
line: endPosDetails.line,
column: endPosDetails.column,
},
column: endPosDetails.column
}
};
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) {
return;
}
if (peg$currPos < peg$maxFailPos) { return; }
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
@ -578,9 +516,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e0);
}
if (peg$silentFails === 0) { peg$fail(peg$e0); }
}
peg$silentFails--;
if (s2 === peg$FAILED) {
@ -650,9 +586,7 @@ function peg$parse(input, options) {
peg$currPos += 8;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e1);
}
if (peg$silentFails === 0) { peg$fail(peg$e1); }
}
if (s2 !== peg$FAILED) {
s3 = [];
@ -685,9 +619,7 @@ function peg$parse(input, options) {
peg$currPos += 2;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e2);
}
if (peg$silentFails === 0) { peg$fail(peg$e2); }
}
if (s7 !== peg$FAILED) {
s8 = [];
@ -784,9 +716,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e4);
}
if (peg$silentFails === 0) { peg$fail(peg$e4); }
}
if (s2 !== peg$FAILED) {
s3 = [];
@ -795,9 +725,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e5);
}
if (peg$silentFails === 0) { peg$fail(peg$e5); }
}
while (s4 !== peg$FAILED) {
s3.push(s4);
@ -806,9 +734,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e5);
}
if (peg$silentFails === 0) { peg$fail(peg$e5); }
}
}
if (input.charCodeAt(peg$currPos) === 39) {
@ -816,9 +742,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e4);
}
if (peg$silentFails === 0) { peg$fail(peg$e4); }
}
if (s4 !== peg$FAILED) {
s1 = s3;
@ -843,9 +767,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e6);
}
if (peg$silentFails === 0) { peg$fail(peg$e6); }
}
if (s2 !== peg$FAILED) {
s3 = [];
@ -854,9 +776,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e7);
}
if (peg$silentFails === 0) { peg$fail(peg$e7); }
}
while (s4 !== peg$FAILED) {
s3.push(s4);
@ -865,9 +785,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e7);
}
if (peg$silentFails === 0) { peg$fail(peg$e7); }
}
}
if (input.charCodeAt(peg$currPos) === 34) {
@ -875,9 +793,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e6);
}
if (peg$silentFails === 0) { peg$fail(peg$e6); }
}
if (s4 !== peg$FAILED) {
s1 = s3;
@ -898,9 +814,7 @@ function peg$parse(input, options) {
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e3);
}
if (peg$silentFails === 0) { peg$fail(peg$e3); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -963,9 +877,7 @@ function peg$parse(input, options) {
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e9);
}
if (peg$silentFails === 0) { peg$fail(peg$e9); }
}
if (s1 !== peg$FAILED) {
s2 = [];
@ -998,9 +910,7 @@ function peg$parse(input, options) {
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e8);
}
if (peg$silentFails === 0) { peg$fail(peg$e8); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -1027,9 +937,7 @@ function peg$parse(input, options) {
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e10);
}
if (peg$silentFails === 0) { peg$fail(peg$e10); }
}
if (s1 !== peg$FAILED) {
s2 = [];
@ -1038,9 +946,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e11);
}
if (peg$silentFails === 0) { peg$fail(peg$e11); }
}
while (s3 !== peg$FAILED) {
s2.push(s3);
@ -1049,9 +955,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e11);
}
if (peg$silentFails === 0) { peg$fail(peg$e11); }
}
}
if (input.substr(peg$currPos, 2) === peg$c7) {
@ -1059,9 +963,7 @@ function peg$parse(input, options) {
peg$currPos += 2;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e12);
}
if (peg$silentFails === 0) { peg$fail(peg$e12); }
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
@ -1077,9 +979,7 @@ function peg$parse(input, options) {
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e8);
}
if (peg$silentFails === 0) { peg$fail(peg$e8); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -1105,16 +1005,12 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e14);
}
if (peg$silentFails === 0) { peg$fail(peg$e14); }
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e13);
}
if (peg$silentFails === 0) { peg$fail(peg$e13); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -1140,16 +1036,12 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e16);
}
if (peg$silentFails === 0) { peg$fail(peg$e16); }
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e15);
}
if (peg$silentFails === 0) { peg$fail(peg$e15); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -1175,16 +1067,12 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e18);
}
if (peg$silentFails === 0) { peg$fail(peg$e18); }
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e17);
}
if (peg$silentFails === 0) { peg$fail(peg$e17); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -1213,9 +1101,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e20);
}
if (peg$silentFails === 0) { peg$fail(peg$e20); }
}
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
@ -1225,9 +1111,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e20);
}
if (peg$silentFails === 0) { peg$fail(peg$e20); }
}
}
} else {
@ -1240,9 +1124,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e21);
}
if (peg$silentFails === 0) { peg$fail(peg$e21); }
}
while (s4 !== peg$FAILED) {
s3.push(s4);
@ -1251,9 +1133,7 @@ function peg$parse(input, options) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e21);
}
if (peg$silentFails === 0) { peg$fail(peg$e21); }
}
}
s2 = [s2, s3];
@ -1270,9 +1150,7 @@ function peg$parse(input, options) {
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$e19);
}
if (peg$silentFails === 0) { peg$fail(peg$e19); }
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -1301,5 +1179,5 @@ function peg$parse(input, options) {
module.exports = {
SyntaxError: peg$SyntaxError,
parse: peg$parse,
parse: peg$parse
};