modl-parser
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -24,6 +24,14 @@ "use strict"; | ||
var tokens = MODLTokeniser_1.tokeniser(s); | ||
var root = parse(new TokenStream_1.TokenStream(tokens)); | ||
return new Model_1.Modl(root); | ||
var rootItems = parse(new TokenStream_1.TokenStream(tokens)); | ||
return new Model_1.Modl(rootItems); | ||
}; | ||
exports.parseModl = parseModl; | ||
var ParserException = (function (_super) { | ||
__extends(ParserException, _super); | ||
function ParserException() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return ParserException; | ||
}(Error)); | ||
exports.ParserException = ParserException; | ||
var parse = function (s) { | ||
@@ -45,3 +53,3 @@ var rootPrimitive = parsePrimitive(s); | ||
case MODLTokeniser_1.TokenType.EQUALS: { | ||
if (s.length() === 0) { | ||
if (s.empty()) { | ||
throw new ParserException("Unexpected token: " + tok.toS()); | ||
@@ -99,3 +107,3 @@ } | ||
var result = []; | ||
while (s.length() > 0) { | ||
while (!s.empty()) { | ||
result.push(parseModlValue(s)); | ||
@@ -117,3 +125,3 @@ var maybeStructSep = s.next(); | ||
var arrayEntries = []; | ||
while (s.length() > 0) { | ||
while (!s.empty()) { | ||
var peek = s.peek(); | ||
@@ -148,3 +156,3 @@ if (peek && peek.type === MODLTokeniser_1.TokenType.RBRACKET) { | ||
var mapEntries = []; | ||
while (s.length() > 0) { | ||
while (!s.empty()) { | ||
var peek = s.peek(); | ||
@@ -223,10 +231,2 @@ if (peek && peek.type === MODLTokeniser_1.TokenType.RPAREN) { | ||
}; | ||
var ParserException = (function (_super) { | ||
__extends(ParserException, _super); | ||
function ParserException() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return ParserException; | ||
}(Error)); | ||
exports.ParserException = ParserException; | ||
//# sourceMappingURL=MODLParser.js.map |
@@ -10,2 +10,4 @@ export declare class Token { | ||
export declare const tokeniser: (s: string) => Token[]; | ||
export declare class TokeniserException extends Error { | ||
} | ||
export declare enum TokenType { | ||
@@ -26,3 +28,1 @@ LPAREN = "LPAREN", | ||
} | ||
export declare class TokeniserException extends Error { | ||
} |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TokeniserException = exports.TokenType = exports.tokeniser = exports.Token = void 0; | ||
exports.TokenType = exports.TokeniserException = exports.tokeniser = exports.Token = void 0; | ||
var Token = (function () { | ||
@@ -37,2 +37,10 @@ function Token(type, value, from, to) { | ||
exports.tokeniser = tokeniser; | ||
var TokeniserException = (function (_super) { | ||
__extends(TokeniserException, _super); | ||
function TokeniserException() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return TokeniserException; | ||
}(Error)); | ||
exports.TokeniserException = TokeniserException; | ||
var WS = ' \t\r\n'; | ||
@@ -172,10 +180,2 @@ var nonStringTokens = '[]();"='; | ||
}()); | ||
var TokeniserException = (function (_super) { | ||
__extends(TokeniserException, _super); | ||
function TokeniserException() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return TokeniserException; | ||
}(Error)); | ||
exports.TokeniserException = TokeniserException; | ||
//# sourceMappingURL=MODLTokeniser.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var MODLParser_1 = require("./MODLParser"); | ||
var tests = ['()']; | ||
var modl = tests.map(function (t) { return MODLParser_1.parseModl(t); }); | ||
console.log(JSON.stringify(modl)); | ||
var result = MODLParser_1.parseModl('x=y'); | ||
console.log(JSON.stringify(result)); | ||
//# sourceMappingURL=Scratch.js.map |
@@ -8,3 +8,3 @@ import { Token } from './MODLTokeniser'; | ||
pushBack(t: Token): void; | ||
length(): number; | ||
empty(): boolean; | ||
} |
@@ -25,4 +25,4 @@ "use strict"; | ||
}; | ||
TokenStream.prototype.length = function () { | ||
return this.tokens.length; | ||
TokenStream.prototype.empty = function () { | ||
return this.tokens.length === 0; | ||
}; | ||
@@ -29,0 +29,0 @@ return TokenStream; |
{ | ||
"name": "modl-parser", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "A MODL parser in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
39024
21
1
13
610