How to use ParserException method in Cucumber-gherkin

Best JavaScript code snippet using cucumber-gherkin

exceptions.js

Source:exceptions.js Github

copy

Full Screen

1/**2 * @file src/classes/exceptions.js3 * @description Тут я сгруппировал всевозможные исклюения4 * @author Astecom5 */6"use strict";7const { SERVICE } = require('./static')8 , { dirname } = require('path');9/**10 * Класс ошибки шаблонизатора11 *12 * @memberof Poonya.Exceptions13 * @name ParserException14 * @class15 * @protected16 */17class PoonyaException {18 constructor(header, message, throwed = false) {19 this.message = 'PoonyaException / ' + header + (message != null ? ': \n' + message : '');20 this.throwed = throwed;21 }22 toString(){23 return this.message;24 }25}26/**27 * Основное исключение парсера28 *29 * @memberof Poonya.Exceptions30 * @name ParserException31 * @class32 * @protected33 */34class ParserException extends PoonyaException {35 constructor(header, message) {36 super('Parser exception / ' + header, message);37 }38}39/**40 * Основное исключение лексера41 *42 * @memberof Poonya.Exceptions43 * @name LexerException44 * @class45 * @protected46 */47 class LexerException extends PoonyaException {48 constructor(header, message) {49 super('Lexer exception / ' + header, message);50 }51}52/**53 * Основное исключение линкера54 *55 * @memberof Poonya.Exceptions56 * @name LinkerException57 * @class58 * @protected59 */60class LinkerException extends PoonyaException {61 constructor(header, message) {62 super('Linker exception / ' + header, message);63 }64}65/**66 * Исключение последовательности, неожиданная последовательность67 *68 * @memberof Poonya.Exceptions69 * @name TheSequenceException70 * @class71 * @protected72 */73class TheSequenceException extends ParserException {74 constructor(entry, last) {75 super(`Wrong order: condition operator: '${entry.toString()}' after '${last.toString()}'`);76 }77}78/**79 * Исключение неизвестного токена80 *81 * @memberof Poonya.Exceptions82 * @name UnexpectedTokenException83 * @class84 * @protected85 */86class UnexpectedTokenException extends ParserException {87 constructor(token, expected) {88 super(`Unexpected token '${token.toString()}'` + (expected ? `when expected '${expected.toString()}'` : ''));89 }90}91/**92 * Исключение неизвестного токена93 *94 * @memberof Poonya.Exceptions95 * @name UnexpectedTokenStatement96 * @class97 * @protected98 */99class UnexpectedTokenStatement extends ParserException {100 constructor(statement, token, expected) {101 super(102 `Error parsing the '${statement.toString()}' statement. Expected '${expected.toString()}', when actually: '${token.toString()}'`103 );104 }105}106/**107 * Логическое исключение108 *109 * @memberof Poonya.Exceptions110 * @name ParserLogicException111 * @class112 * @protected113 */114class ParserLogicException extends ParserException {115 constructor() {116 super('The expression has incorrect logic');117 }118}119/**120 * Исключение пустого аргумента при вызове функции121 *122 * @memberof Poonya.Exceptions123 * @name ParserEmtyArgumentException124 * @class125 * @protected126 */127class ParserEmtyArgumentException extends ParserException {128 constructor() {129 super(130 'It is not possible to pass an empty argument to a function, use null to denote an empty value'131 );132 }133}134/**135 * Не передан путь родтельскому шаблону136 *137 * @memberof Poonya.Exceptions138 * @name LinkerPathNotGiveExceptrion139 * @class140 * @protected141 */142class LinkerPathNotGiveException extends LinkerException {143 constructor() {144 super('To use include, you must pass the path to the current execution file');145 }146}147/**148 * Ошибка открытия файла149 *150 * @memberof Poonya.Exceptions151 * @name LinkerIOError152 * @class153 * @protected154 */155class IOError extends LinkerException {156 constructor(path) {157 super("An error occured while opening file: '" + path + "'");158 }159}160/**161 * Ошибка использования стороннего шаблона162 *163 * @memberof Poonya.Exceptions164 * @name LinkerIOError165 * @class166 * @protected167 */168class LinkerIOError extends IOError {169 constructor(path) {170 super(path);171 }172}173/**174 * Ошибка выполнения нативной функции175 *176 * @memberof Poonya.Exceptions177 * @name NativeFunctionExecutionError178 * @class179 * @protected180 */181class NativeFunctionExecutionError extends PoonyaException {182 constructor(name, stack) {183 const exp = /^\s*at\s(?:new\s)?([aA-zZ.аА-яЯё]+)\s\((.*)\)$/;184 stack = stack.split('\n');185 for (let i = 0, leng = stack.length, cur; i < leng; i++) {186 if (exp.test(stack[i])) {187 cur = stack[i].match(exp);188 if (189 cur[1] === 'NativeFunction.result' &&190 SERVICE.ROOTPATH == dirname(cur[2]).substring(0, SERVICE.ROOTPATH.length)191 ) {192 stack = stack.slice(0, i);193 break;194 }195 }196 }197 super(198 "Critical error while executing a native function '" + name + "'",199 '* > \t' + stack.join('\n * > \t')200 );201 }202}203/**204 * Ошибка типа, возвращаемого нативной функцией205 *206 * @memberof Poonya.Exceptions207 * @name NativeFunctionReturnValueError208 * @class209 * @protected210 */211class NativeFunctionReturnValueError extends PoonyaException {212 constructor() {213 super('Function can only return simple types');214 }215}216/**217 * Невозможно получить n от null218 *219 * @memberof Poonya.Exceptions220 * @name GetFieldOfNullException221 * @class222 * @protected223 */224class GetFieldOfNullException extends PoonyaException {225 constructor(field) {226 super(`Cannot get property '${field}' of null`);227 }228}229/**230 * Поле не является функцией231 *232 * @memberof Poonya.Exceptions233 * @name FieldNotAFunctionException234 * @class235 * @protected236 */237class FieldNotAFunctionException extends PoonyaException {238 constructor(field) {239 super(`The field '${field}' is not a function`);240 }241}242/**243 * Поле уже объявлено244 *245 * @memberof Poonya.Exceptions246 * @name TheFieldAlreadyHasBeenDeclaredException247 * @class248 * @protected249 */250class TheFieldAlreadyHasBeenDeclaredException extends PoonyaException {251 constructor(field) {252 super(`The '${field}' field is already declared`);253 }254}255/**256 * Поле должно быть массивом257 *258 * @memberof Poonya.Exceptions259 * @name TheFieldMustBeAnArrayInstanceExceprion260 * @class261 * @protected262 */263class TheFieldMustBeAnArrayInstanceExceprion extends PoonyaException {264 constructor(field) {265 super(`Field '${field}' must be an Array instance`);266 }267}268/**269 * Поле не объявлено270 *271 * @memberof Poonya.Exceptions272 * @name TheFieldNotHasDeclaredExceprion273 * @class274 * @protected275 */276class TheFieldNotHasDeclaredExceprion extends PoonyaException {277 constructor(field) {278 super(`Field '${field}' is not declared`);279 }280}281/**282 * Поле должно иметь тип числа283 *284 * @memberof Poonya.Exceptions285 * @name TheFieldMustBeNumberException286 * @class287 * @protected288 */289class TheFieldMustBeNumberException extends PoonyaException {290 constructor(field) {291 super(`'${field}' must be a number, or a container containing a number`);292 }293}294/**295 * Невозможно распознать тип вхождения296 *297 * @memberof Poonya.Exceptions298 * @name UnableToRecognizeTypeException299 * @class300 * @protected301 */302class UnableToRecognizeTypeException extends ParserException {303 constructor(type) {304 super(`Unable to recognize type '${type}'`);305 }306}307/**308 * Ошибка сегментации сегментов вызова (...exp, ...exp, ) <-309 *310 * @memberof Poonya.Exceptions311 * @name SegmentationFaultEmptyArgumentException312 * @class313 * @protected314 */315class SegmentationFaultEmptyArgumentException extends ParserException {316 constructor(blockname) {317 super(`Segmentation fault: empty argument for ` + blockname);318 }319}320/**321 * Незавршенное объявление объекта322 *323 * @memberof Poonya.Exceptions324 * @name SegmentationFaultEmptyArgumentException325 * @class326 * @protected327 */328class ParserUnfinishedNotationException extends ParserException {329 constructor() {330 super(`Parser fault: unfinished notation`);331 }332}333/**334 * Ошибка сегментации сегментов вызова (...exp, ...exp, ) <-335 *336 * @memberof Poonya.Exceptions337 * @name SegmentationFaultMaximumSegmentsForBlockException338 * @class339 * @protected340 */341class SegmentationFaultMaximumSegmentsForBlockException extends ParserException {342 constructor(blockname) {343 super(`Segmentation fault exceeded the maximum number of segments for block ` + blockname);344 }345}346/**347 * somed.dss[ <...exp> ] <-348 *349 * @memberof Poonya.Exceptions350 * @name UnexpectedWordTypeAndGetException351 * @class352 * @protected353 */354class UnexpectedWordTypeAndGetException extends ParserException {355 constructor(value, type) {356 super(`Expected word type expression and get ${value}[${type}]`);357 }358}359/**360 * Невозможно получить доступ к полю, неправильно сотавлено выражение361 *362 * @memberof Poonya.Exceptions363 * @name InvalidSequenceForLetiableAccessException364 * @class365 * @protected366 */367class InvalidSequenceForLetiableAccessException extends ParserException {368 constructor() {369 super(`Invalid sequence for letiable access`);370 }371}372/**373 * Критическая ошибка парсера374 *375 * @memberof Poonya.Exceptions376 * @name CriticalParserErrorException377 * @class378 * @protected379 */380class CriticalParserErrorException extends ParserException {381 constructor() {382 super(`Critical parser error`);383 }384}385/**386 * Критическая ошибка парсера387 *388 * @memberof Poonya.Exceptions389 * @name CriticalParserErrorUnexpectedEndOfExpression390 * @class391 * @protected392 */393class CriticalParserErrorUnexpectedEndOfExpression extends ParserException {394 constructor() {395 super(`Critical parser error: unexprected end of expression`);396 }397}398/**399 * Критическая ошибка лексера, неожиданный конец ввода400 *401 * @memberof Poonya.Exceptions402 * @name CriticalLexerErrorUnexpectedEndOfInputException403 * @class404 * @protected405 */406 class CriticalLexerErrorUnexpectedEndOfInputException extends LexerException {407 constructor() {408 super(`Critical lexer error: unexpected end of input`);409 }410}411/**412 * Критическая ошибка парсера, неожиданный конец ввода413 *414 * @memberof Poonya.Exceptions415 * @name CriticalParserErrorUnexpectedEndOfInputException416 * @class417 * @protected418 */419class CriticalParserErrorUnexpectedEndOfInputException extends ParserException {420 constructor() {421 super(`Critical parser error: unexpected end of input`);422 }423}424/**425 * Критическая ошибка парсера, не переданны данные для парсинга426 *427 * @memberof Poonya.Exceptions428 * @name CriticalParserErrorNoRawDataTransmittedException429 * @class430 * @protected431 */432class CriticalParserErrorNoRawDataTransmittedException extends ParserException {433 constructor() {434 super(`Critical parser error: no raw data transmitted`);435 }436}437/**438 * Прыжок через два уровня439 *440 * @memberof Poonya.Exceptions441 * @name BadArrowNotationJTException442 * @class443 * @protected444 */445class BadArrowNotationJTException extends ParserException {446 constructor() {447 super(`Bad array notation: jumping two levels is not possible`);448 }449}450/**451 * Неожиданный переход на более высокий уровень452 *453 * @memberof Poonya.Exceptions454 * @name BadArrowNotationJTULException455 * @class456 * @protected457 */458class BadArrowNotationJTULException extends ParserException {459 constructor() {460 super(`Bad array notation: unexpected transition to a upper level`);461 }462}463/**464 * Невозможно создать пустой объект, ключи уже объявлены465 *466 * @memberof Poonya.Exceptions467 * @name BadEmptyObjectException468 * @class469 * @protected470 */471class BadEmptyObjectException extends ParserException {472 constructor() {473 super(`Cannot create an empty object after declaring its keys`);474 }475}476/**477 * Неправильный тип ключа478 *479 * @memberof Poonya.Exceptions480 * @name BadKeyInvalidTypeException481 * @class482 * @protected483 */484class BadKeyInvalidTypeException extends PoonyaException {485 constructor() {486 super(`Wrong key type: it can be set only by a numeric or string key`);487 }488}489/**490 * Невозможно создать пустой объект, ключи уже объявлены491 *492 * @memberof Poonya.Exceptions493 * @name BadKeyProtectedFieldException494 * @class495 * @protected496 */497class BadKeyProtectedFieldException extends PoonyaException {498 constructor() {499 super(`Cannot set this field, the field is protected from changes`);500 }501}502/**503 * Попытка создать объект вызывав его как функцию504 *505 * @memberof Poonya.Exceptions506 * @name UnableToCreateAnObjectException507 * @class508 * @protected509 */510class UnableToCreateAnObjectException extends PoonyaException {511 constructor() {512 super(513 `Unable to create an object by calling its constructor as a function, pick ConstructorName -> *;`514 );515 }516}517/**518 * Попытка вызывать несуществующий констурктор519 *520 * @memberof Poonya.Exceptions521 * @name IsNotAConstructorException522 * @class523 * @protected524 */525class IsNotAConstructorException extends PoonyaException {526 constructor(path) {527 super(528 `${path529 .map(e => (typeof e === 'number' ? '[' + e + ']' : e.toString()))530 .join(' -> ')} - not a constructor`531 );532 }533}534/**535 * Рекурсивное включение файла, когда файл пытается заинклудить сам себя.536 *537 * @memberof Poonya.Exceptions538 * @name IsRecursiveLink539 * @class540 * @protected541 */542 class IsRecursiveLink extends PoonyaException {543 constructor(path) {544 super('The "' + path + '" source file has a recursive inclusion of itself');545 }546}547/**548 * Невозможно импортировать статическую библиотеку, возможно неправильно указано имя.549 *550 * @memberof Poonya.Exceptions551 * @name CannotImportStaticLibrary552 * @class553 * @protected554 */555 class CannotImportStaticLibrary extends PoonyaException {556 constructor(...libs) {557 super(`library ${libs.map(e => `"${e}"`).join(', ')} cannot be imported, possibly the wrong library identifier for import was specified`);558 }559}560module.exports.IOError = IOError;561module.exports.LinkerIOError = LinkerIOError;562module.exports.LexerException = LexerException;563module.exports.IsRecursiveLink = IsRecursiveLink;564module.exports.LinkerException = LinkerException;565module.exports.PoonyaException = PoonyaException;566module.exports.ParserException = ParserException;567module.exports.TheSequenceException = TheSequenceException;568module.exports.ParserLogicException = ParserLogicException;569module.exports.GetFieldOfNullException = GetFieldOfNullException;570module.exports.BadEmptyObjectException = BadEmptyObjectException;571module.exports.UnexpectedTokenException = UnexpectedTokenException;572module.exports.UnexpectedTokenStatement = UnexpectedTokenStatement;573module.exports.CannotImportStaticLibrary = CannotImportStaticLibrary;574module.exports.FieldNotAFunctionException = FieldNotAFunctionException;575module.exports.BadKeyInvalidTypeException = BadKeyInvalidTypeException;576module.exports.IsNotAConstructorException = IsNotAConstructorException;577module.exports.LinkerPathNotGiveException = LinkerPathNotGiveException;578module.exports.ParserEmtyArgumentException = ParserEmtyArgumentException;579module.exports.CriticalParserErrorException = CriticalParserErrorException;580module.exports.NativeFunctionExecutionError = NativeFunctionExecutionError;581module.exports.BadKeyProtectedFieldException = BadKeyProtectedFieldException;582module.exports.TheFieldMustBeNumberException = TheFieldMustBeNumberException;583module.exports.BadArrowNotationJumpingTwoLevels = BadArrowNotationJTException;584module.exports.NativeFunctionReturnValueError = NativeFunctionReturnValueError;585module.exports.UnableToRecognizeTypeException = UnableToRecognizeTypeException;586module.exports.TheFieldNotHasDeclaredExceprion = TheFieldNotHasDeclaredExceprion;587module.exports.UnableToCreateAnObjectException = UnableToCreateAnObjectException;588module.exports.BadArrowNotationJumpingToUpperLevel = BadArrowNotationJTULException;589module.exports.UnexpectedWordTypeAndGetException = UnexpectedWordTypeAndGetException;590module.exports.ParserUnfinishedNotationException = ParserUnfinishedNotationException;591module.exports.TheFieldMustBeAnArrayInstanceExceprion = TheFieldMustBeAnArrayInstanceExceprion;592module.exports.TheFieldAlreadyHasBeenDeclaredException = TheFieldAlreadyHasBeenDeclaredException;593module.exports.SegmentationFaultEmptyArgumentException = SegmentationFaultEmptyArgumentException;594module.exports.InvalidSequenceForLetiableAccessException = InvalidSequenceForLetiableAccessException;595module.exports.CriticalParserErrorUnexpectedEndOfExpression = CriticalParserErrorUnexpectedEndOfExpression;596module.exports.CriticalLexerErrorUnexpectedEndOfInputException = CriticalLexerErrorUnexpectedEndOfInputException;597module.exports.CriticalParserErrorUnexpectedEndOfInputException = CriticalParserErrorUnexpectedEndOfInputException;598module.exports.CriticalParserErrorNoRawDataTransmittedException = CriticalParserErrorNoRawDataTransmittedException;...

Full Screen

Full Screen

parser.js

Source:parser.js Github

copy

Full Screen

1Tokenizer = require('./tokenizer.js')2function ParserException(name, pos)3{4 this.name = name;5 this.position = pos;6 this.toString = function() {7 return this.name + " exception at character " + this.position + " (0-indexed)";8 }9}10function Parser(str) {11 this.str = str; // the string to be parsed12 this.variables = {true: true, false: false, null: null};13 14 this.functions = {print : function(input) {console.log (input);},15 string : function(input) {return JSON.stringify(input);}}16 this.tokenizer = new Tokenizer();17 this.tokenizer18 .add(/\+/)19 .add(/-/)20 .add(/\*/)21 .add(/\//)22 .add(/%/)23 .add(/\(/)24 .add(/\)/)25 .add(/\[/)26 .add(/\]/)27 .add(/\./)28 .add(/=/)29 .add(/;/)30 .add(/{/)31 .add(/}/)32 .add(/:/)33 .add(/,/)34 // Matches all double-quoted strings with appropriate escaping35 .add(/\"(\\.|[^\"])*\"/)36 // Matches all single-quoted strings with appropriate escaping37 .add(/'(\\.|[^'])*'/)38 // Matches all identifiers starting with letter or underscore39 .add(/[a-zA-Z_][a-zA-Z0-9_]*/)40 // Second half matches numbers starting with .; first half matches all other floats41 .add(/[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?|\.?[0-9]+([eE][-+]?[0-9]+)?/);42 this.tokenizer.tokenize(this.str);43}44Parser.prototype.number = function() {45 var num;46 if (this.tokenizer.is_num()) {47 num = this.tokenizer.float_val();48 this.tokenizer.eat();49 } else {50 throw new ParserException("Unexpected token", this.tokenizer.pos());51 }52 return num;53}54 55Parser.prototype.array = function() {56 var arr = [];57 var i = 0;58 if (!this.tokenizer.matches("["))59 {60 throw new ParserException("Array requires starting square bracket", this.tokenizer.pos());61 }62 this.tokenizer.eat();63 while (!this.tokenizer.matches("]"))64 {65 if (!this.tokenizer.matches(","))66 {67 arr[i] = this.expression();68 if (this.tokenizer.matches("]"))69 {70 break;71 }72 if (!this.tokenizer.matches(","))73 {74 throw new ParserException("Comma expected after array element", this.tokenizer.pos());75 }76 }77 i++;78 this.tokenizer.eat();79 }80 this.tokenizer.eat();81 return arr;82}83 84Parser.prototype.hash = function() {85 var hash = {};86 if (!this.tokenizer.matches("{"))87 {88 throw new ParserException("Hash requires starting curly bracket", this.tokenizer.pos());89 }90 this.tokenizer.eat();91 while (!this.tokenizer.matches("}"))92 {93 var key = this.identifier();94 if (!this.tokenizer.matches(":"))95 {96 throw new ParserException("Colon expected after hash key", this.tokenizer.pos());97 }98 this.tokenizer.eat();99 hash[key] = this.expression();100 101 if (this.tokenizer.matches("}"))102 {103 break;104 }105 if (!this.tokenizer.matches(","))106 {107 throw new ParserException("Comma expected after hash pair", this.tokenizer.pos());108 }109 this.tokenizer.eat();110 }111 this.tokenizer.eat();112 return hash;113}114Parser.prototype.string = function() {115 var tmpstr;116 var str = "";117 if (this.tokenizer.is_str()) {118 tmpstr = this.tokenizer.current();119 this.tokenizer.eat();120 } else {121 throw new ParserException("Unexpected token", this.tokenizer.pos());122 }123 124 for (var i = 1; i < tmpstr.length - 1; i++)125 {126 if (tmpstr[i] == "\\" && tmpstr[i + 1] == "\"")127 {128 str += "\"";129 i++;130 }131 else if (tmpstr[i] == "\\" && tmpstr[i + 1] == "'")132 {133 str += "'";134 i++;135 }136 else if (tmpstr[i] == "\\" && tmpstr[i + 1] == "\\")137 {138 str += "\\";139 i++;140 }141 else142 {143 str += tmpstr[i];144 }145 }146 return str;147}148Parser.prototype.variable = function() {149 var variable = this.getVariable();150 var val;151 if (this.tokenizer.matches("("))152 {153 val = this.func(variable);154 }155 else156 {157 val = this.evalVariable(variable);158 }159 return val;160}161Parser.prototype.func = function(variable) {162 if (variable === undefined)163 {164 variable = this.getVariable();165 }166 var result;167 if (!this.tokenizer.matches("("))168 {169 throw new ParserException("Function requires starting parenthesis", this.tokenizer.pos());170 }171 this.tokenizer.eat();172 if (this.tokenizer.matches(")"))173 {174 this.tokenizer.eat();175 this.callFunction(variable);176 }177 else178 {179 var value = this.expression();180 if (!this.tokenizer.matches(")"))181 {182 throw new ParserException("Expected closing parenthesis after function call", this.tokenizer.pos());183 }184 this.tokenizer.eat();185 result = this.callFunction(variable, value);186 }187 return result;188}189Parser.prototype.factor = function() {190 var val;191 if(this.tokenizer.matches("("))192 {193 this.tokenizer.eat();194 val = this.statement();195 if ( this.tokenizer.matches(")") )196 {197 this.tokenizer.eat();198 } else {199 console.log(this.tokenizer.current());200 throw new ParserException("Expected closing parenthesis", this.tokenizer.pos());201 }202 } else if (this.tokenizer.matches("+") || this.tokenizer.matches("-")) {203 var negative = false;204 if (this.tokenizer.matches("-"))205 {206 negative = true;207 }208 this.tokenizer.eat();209 val = this.factor();210 if (typeof val != "number" && typeof val != "boolean")211 {212 throw new ParserException("Cannot apply sign to non-number.", this.tokenizer.pos());213 }214 215 if (negative)216 {217 val = -val;218 }219 } else if (this.tokenizer.is_num()) {220 val = this.number();221 } else if (this.tokenizer.is_str()) {222 val = this.string();223 } else if (this.tokenizer.is_ident()) {224 val = this.variable();225 } else if (this.tokenizer.matches("[")) {226 val = this.array();227 } else if (this.tokenizer.matches("{")) {228 val = this.hash();229 } else {230 throw new ParserException("Unexpected token", this.tokenizer.pos());231 }232 return val;233}234Parser.prototype.term = function(first) {235 var val;236 if (first !== undefined) {237 val = first;238 } else {239 val = this.factor();240 }241 if (typeof val == "number" || typeof val == "boolean")242 {243 while (this.tokenizer.matches("*") || this.tokenizer.matches("/") || this.tokenizer.matches("%"))244 {245 var op = this.tokenizer.current();246 var pos = this.tokenizer.pos();247 this.tokenizer.eat();248 var num = this.factor();249 if (op == "*")250 {251 val *= num;252 } else if (op == "/" && num == 0) {253 throw new ParserException("Division by zero", pos);254 } else if (op == "/") {255 val /= num;256 } else if (op == "%" && num == 0) {257 throw new ParserException("Modulo by zero", pos);258 } else {259 val %= num;260 }261 }262 }263 return val;264}265Parser.prototype.expression = function(first) {266 var val = this.term(first);267 while (this.tokenizer.matches("+") || this.tokenizer.matches("-"))268 {269 var negative = false;270 if (this.tokenizer.matches("-"))271 {272 this.tokenizer.eat();273 if (typeof val != "number" && typeof val != "boolean")274 {275 throw new ParserException("Subtraction cannot be applied to non-number", this.tokenizer.pos());276 }277 var sub = this.term()278 if (typeof sub != "number" && typeof sub != "boolean")279 {280 throw new ParserException("Non-number cannot be subtracted", this.tokenizer.pos());281 }282 val -= sub;283 } else {284 this.tokenizer.eat();285 if (typeof val != "number" && typeof val != "string" && typeof val != "boolean")286 {287 throw new ParserException("Addition cannot be applied to non-number/string", this.tokenizer.pos());288 }289 var sub = this.term()290 if (typeof sub != "number" && typeof sub != "string" && typeof sub != "boolean")291 {292 throw new ParserException("Non-number/string cannot be added", this.tokenizer.pos());293 }294 val += sub;295 }296 }297 return val;298}299Parser.prototype.identifier = function() {300 var ident;301 if (this.tokenizer.is_ident()) {302 ident = this.tokenizer.current();303 this.tokenizer.eat();304 } else {305 throw new ParserException("Unexpected token", this.tokenizer.pos());306 }307 return ident;308}309Parser.prototype.getVariable = function() {310 var ident = this.identifier();311 var key = undefined;312 if (this.tokenizer.matches("["))313 {314 this.tokenizer.eat();315 key = this.expression();316 if (!this.tokenizer.matches("]"))317 {318 throw new ParserException("Expected closing square bracket", this.tokenizer.pos());319 }320 this.tokenizer.eat();321 } else if (this.tokenizer.matches("."))322 {323 this.tokenizer.eat();324 key = this.identifier();325 }326 return {identifier: ident, key: key};327}328Parser.prototype.evalVariable = function(variable) {329 if (!(variable.identifier in this.variables))330 {331 throw new ParserException("Undefined variable " + variable.identifier, this.tokenizer.pos());332 }333 334 if (variable.key === undefined)335 {336 return this.variables[variable.identifier];337 }338 if (typeof this.variables[variable.identifier] != "object")339 {340 throw new ParserException(variable.identifier + " is not a valid object", this.tokenizer.pos());341 }342 if (this.variables[variable.identifier][variable.key] === undefined)343 {344 if (Array.isArray(this.variables[variable.identifier]))345 {346 throw new ParserException("Undefined index " + variable.key + " in " + variable.identifier, this.tokenizer.pos());347 }348 throw new ParserException("Undefined key " + variable.key + " in " + variable.identifier, this.tokenizer.pos());349 }350 351 return this.variables[variable.identifier][variable.key];352 353}354Parser.prototype.setVariable = function(variable, value) {355 if (variable.key === undefined)356 {357 this.variables[variable.identifier] = value;358 } else {359 if (typeof variable.key == "number")360 {361 if (this.variables[variable.identifier] === undefined)362 {363 this.variables[variable.identifier] = new Array();364 }365 if (typeof this.variables[variable.identifier] != "object")366 {367 throw new ParserException("Array subscript applied to non-array", this.tokenizer.pos());368 }369 this.variables[variable.identifier][variable.key] = value;370 }371 else if (typeof variable.key == "string")372 {373 if (this.variables[variable.identifier] === undefined)374 {375 this.variables[variable.identifier] = new Object();376 }377 if (typeof this.variables[variable.identifier] != "object")378 {379 throw new ParserException("Object key applied to non-object", this.tokenizer.pos());380 }381 this.variables[variable.identifier][variable.key] = value;382 }383 }384}385Parser.prototype.callFunction = function(func, arg) {386 if (this.functions[func.identifier] === undefined)387 {388 throw new ParserException("Undefined function " + func, this.tokenizer.pos());389 }390 if (func.key !== undefined)391 {392 throw new ParserException("Unsupported syntax", this.tokenizer.pos());393 }394 return this.functions[func.identifier](arg);395}396Parser.prototype.statement = function() {397 var result;398 if (this.tokenizer.matches(";"))399 {400 result = null;401 }402 else if (this.tokenizer.is_ident())403 {404 var variable = this.getVariable();405 if (this.tokenizer.matches("="))406 {407 this.tokenizer.eat();408 result = this.expression();409 this.setVariable(variable, result);410 }411 else if (this.tokenizer.matches("("))412 {413 result = this.func(variable);414 } else {415 var value = this.evalVariable(variable);416 result = this.expression(value);417 }418 }419 else420 {421 result = this.expression(value);422 }423 //console.log(result);424 return result;425}426Parser.prototype.parse = function() {427 var result;428 while (!this.tokenizer.eof())429 {430 if (!this.tokenizer.matches(";"))431 {432 this.statement();433 }434 if (!this.tokenizer.matches(";"))435 {436 throw new ParserException("Expected semicolon to end statement", this.tokenizer.pos());437 }438 this.tokenizer.eat();439 }440 //console.log(this.variables);441 return result;442}...

Full Screen

Full Screen

objectExpression.js

Source:objectExpression.js Github

copy

Full Screen

...114 'sin' : [Sin, 1],115 'cos' : [Cos, 1]116};117/***** Exception part *****/118function ParserException(message, expr, ind) {119 if (expr === null) {120 this.message = message;121 } else {122 this.message = message + " in index '" + ind + "'\n'" + expr + "'\n";123 for (var i = 0; i < ind + 1; i++)124 this.message += " ";125 this.message += "^\n";126 }127}128ParserException.prototype = Object.create(Error.prototype);129ParserException.prototype.name = "ParserException";130ParserException.prototype.constructor = ParserException;131/**** Helpful function ****/132function isDigit(c) {133 return c >= '0' && c <= '9';134}135function isLetter(c) {136 return c >= 'a' && c <= 'z';137}138function isNumber(expr, ind) {139 return !!((isDigit(expr[ind])) || (expr[ind] === '-' && ind + 1 < expr.length && isDigit(expr[ind + 1])));140}141function startsWith(str, begin, shift) {142 if (str.length - shift < begin.length)143 return false;144 for (var i = 0; i < begin.length; i++)145 if (str[shift + i] !== begin[i])146 return false;147 return true;148}149/**** Tokenizer function ****/150function getToken(expr, ind) {151 var beginInd = ind;152 /* If it's number */153 if (isNumber(expr, ind)) {154 ind++;155 while (ind < expr.length && isDigit(expr[ind])) {156 ind++;157 }158 return [expr.substring(beginInd, ind), ind];159 } else if (expr[ind] === '(' || expr[ind] === ')')160 return [expr[ind], ind + 1];161 /* If it's operation */162 for (var item in OPERATIONS)163 if (startsWith(expr, item, ind)) {164 ind += item.length;165 return [item, ind];166 }167 /* Get unknown token */168 while (isLetter(expr[ind]) || expr[ind] === '_') {169 ind++;170 }171 var name = expr.substring(beginInd, ind);172 if (vars.indexOf(name) !== -1)173 return [name, ind];174 while (ind < expr.length && expr[ind] !== ' ')175 ind++;176 throw new ParserException("Unexpected token '" + expr.substring(beginInd, ind) + "'", expr, beginInd);177}178function missingSpaces(expr, ind) {179 while (ind !== expr.length && expr[ind] === ' ') {180 ind++;181 }182 return ind;183}184/****** Parse function ******/185function parse(expr, parseFunc) {186 var ind = 0;187 expr = expr.trim();188 if (expr === "")189 throw new ParserException("Empty input", null, 0);190 var stack = [];191 var brBalance = 0;192 while (ind !== expr.length) {193 ind = missingSpaces(expr, ind);194 var oldInd = ind;195 var tokenInform = getToken(expr, ind);196 var token = tokenInform[0];197 ind = tokenInform[1];198 if (token === ')') {199 if (--brBalance < 0)200 throw new ParserException("Waiting opening bracket for closing bracket", expr, ind);201 if (stack[stack.length - 1][0] === '(')202 throw new ParserException("Empty brackets", expr, stack[stack.length - 1][1]);203 var res = parseFunc(stack, oldInd);204 token = res[0];205 var args = res[1];206 /* Read operation and check for bad situations */207 if (args.length > OPERATIONS[token][1]) {208 throw new ParserException("Too many arguments for operation '" + token + "'", expr, res[2]);209 } else if (args.length < OPERATIONS[token][1])210 throw new ParserException("Too less arguments for operation '" + token + "'", expr, res[2]);211 stack.push([applyToConstructor(OPERATIONS[token][0], args), oldInd]);212 } else if (token === '(') {213 brBalance++;214 stack.push([token[0], oldInd]);215 }else if (token in OPERATIONS) {216 stack.push([token, oldInd]);217 } else if (vars.indexOf(token) !== -1) {218 stack.push([new Variable(token), oldInd]);219 } else if (isNumber(token, 0)) {220 stack.push([new Const(parseInt(token)), oldInd]);221 }222 }223 if (brBalance !== 0)224 throw new ParserException("Missed closing bracket", expr, ind);225 if (stack.length !== 1)226 throw new ParserException("Extra argument out of brackets", null, 0);227 return stack[0][0];228}229/**** Parser examples ****/230var parsePostfix = function(expr) {231 return parse(expr,232 function (stack, ind) {233 var op = stack.pop();234 if (!(op[0] in OPERATIONS)) {235 throw new ParserException("Waiting for operation before ')'", expr, ind);236 }237 var args = [];238 for (var i = 0; i < OPERATIONS[op[0]][1] && stack[stack.length - 1][0] !== '('; i++) {239 var elem = stack.pop();240 if (!(elem[0] in OPERATIONS))241 args.push(elem[0]);242 else243 throw new ParserException("Two operations in one brackets", expr, elem[1]);244 }245 args.reverse();246 var br = stack.pop();247 if (br[0] !== "(")248 throw new ParserException("Waiting for opening bracket after '" + br[0].toString() + "' operand", expr, br[1]);249 return [op[0], args, op[1]];250 });251};252var parsePrefix = function(expr) {253 return parse(expr,254 function (stack) {255 var args = [];256 while (!(stack[stack.length - 1][0] in OPERATIONS || stack[stack.length - 1][0] === '('))257 args.push(stack.pop()[0]);258 var op = stack.pop();259 args.reverse();260 if (!(op[0] in OPERATIONS)) {261 throw new ParserException("Waiting for operation after '('", expr, (stack.length !== 0 ? stack.pop()[1] : 0));262 }263 var br = stack.pop();264 if (br[0] !== "(")265 throw new ParserException("Waiting for opening bracket before '" + op[0] + "' operation", null, 0);266 return [op[0], args, op[1]];267 });...

Full Screen

Full Screen

parse.js

Source:parse.js Github

copy

Full Screen

...107 //case "?":108 default:109 // This is an unknown operator.110 var c = stream.next();111 throw new parse.ParserException("Undefined special operator #" + c + " at " +112 "position " + stream.position + " (expression: #" + c +113 toLisp(parse.any(stream)) + ")");114 }115 case ",":116 stream.next();117 return [_S("resolve"), parse.any(stream)];118 case "@":119 stream.next();120 return [_S("explode"), parse.any(stream)];121 case '"':122 return parse.string(stream);123 case ':':124 return parse.keyword(stream);125 case ';':126 return parse.comment(stream);127 // case '{': // An object literal128 // return parse.object(stream);129 default:130 var rest = stream.rest();131 for (var i = 0; i < lisp.parse.NUMBER_FORMATS.length; i++) {132 var format = lisp.parse.NUMBER_FORMATS[i];133 var match = rest.match(format);134 if (match) {135 return parse.number(stream, match[1]);136 }137 }138 return parse.symbol(stream);139 }140};141/**142 * @returns The parsed sexp.143 */144parse.sexp = function (stream) {145 stream = validateInput(stream);146 stream.swallowWhitespace();147 if (stream.peek() != '(') {148 throw new parse.ParserException("Invalid sexp at line " + stream.line() +149 " (starting with: '" + stream.peek() + "')");150 }151 stream.next();152 stream.swallowWhitespace();153 var parts = [];154 while (stream.peek() != ')' && !stream.eof()) {155 var exp = parse.any(stream);156 if (exp !== undefined)157 parts.push(exp);158 stream.swallowWhitespace();159 }160 stream.next();161 return parts;162};163// Do we want object literals?164// object: function (stream) {165// throw new Error("Not impelemented");166// stream = validateInput(stream);167// stream.swallowWhitespace();168// if (stream.peek() != '{') {169// throw new parse.ParserException("Invalid object at position " +170// stream.position + " (starting with: '" + stream.peek() + "')");171// }172// stream.next()173// stream.swallowWhitespace();174// while (stream.peek() != '}') {175// stream.swallowWhitespace();176// var key /* grab the key */;177// }178// },179/**180 * @returns The parsed symbol.181 */182parse.symbol = function (stream) {183 stream = validateInput(stream);184 stream.swallowWhitespace();185 var badChars = WHITESPACE + '()';186 if (badChars.indexOf(stream.peek()) != -1) {187 throw new parse.ParserException("Invalid symbol at line " + stream.line() +188 " (starting with: '" + stream.peek() + "')");189 }190 var symbol = "";191 while (badChars.indexOf(stream.peek()) == -1 && !stream.eof()) {192 symbol += stream.next();193 }194 return _S(symbol);195};196/**197 * @returns The parsed keyword.198 */199parse.keyword = function (stream) {200 stream = validateInput(stream);201 stream.swallowWhitespace();202 if (stream.peek() != ':') {203 throw new parse.ParserException("Invalid keyword at line " + stream.line() +204 ", position " + stream.position + " (starting with: '" +205 stream.peek() + "')");206 }207 stream.next();208 return new Keyword(parse.symbol(stream).value);209};210/**211 * @returns The parsed string.212 */213parse.string = function (stream) {214 stream = validateInput(stream);215 stream.swallowWhitespace();216 if (stream.peek() != '"') {217 throw new parse.ParserException("Invalid string at line " + stream.line() +218 " (starting with: '" + stream.peek() + "')");219 }220 var string = "";221 stream.next();222 while (stream.peek() != '"' && !stream.eof()) {223 var c = stream.next();224 switch (c)225 {226 case "\\":227 string += parse.stringEscape(stream);228 break;229 default:230 string += c;231 break;232 }233 }234 stream.next();235 return string;236};237/**238 * @returns The parsed escaped character.239 */240parse.stringEscape = function (stream) {241 stream = validateInput(stream);242 var c = stream.next();243 switch (c)244 {245 case "x":246 var hex = stream.next(2);247 return eval('"' + '\\' + c + hex + '"');248 default:249 return eval('"' + '\\' + c + '"');250 }251};252/**253 * @returns The parsed number.254 */255parse.number = function (stream, match) {256 if (!match) {257 stream = validateInput(stream);258 stream.swallowWhitespace();259 var rest = stream.rest();260 for (var i = 0; i < lisp.parse.NUMBER_FORMATS.length; i++) {261 var format = lisp.parse.NUMBER_FORMATS[i];262 match = rest.match(format);263 if (match) {264 match = match[1];265 break;266 }267 }268 }269 270 if (!match) {271 throw new parse.ParserException("Invalid number at line " + stream.line() +272 " (starting with: '" + stream.peek() + "')");273 }274 275 stream.position += match.length;276 return eval(match);277};278/**279 * @returns Nothing280 */281parse.comment = function (stream) {282 stream = validateInput(stream);283 stream.swallowWhitespace();284 if (stream.peek() != ';') {285 throw new parse.ParserException("Invalid comment at line " + stream.line() +286 " (starting with: '" + stream.peek() + "')");287 }288 var c = '';289 while ('\n\r'.indexOf(stream.peek()) == -1 &&290 !stream.eof() &&291 stream.slice(stream.position, stream.position+2) != '\n\r') {292 c += stream.next();293 }294 if (!stream.eof()) {295 stream.next();296 }...

Full Screen

Full Screen

home.js

Source:home.js Github

copy

Full Screen

1require.config({ paths: { vs: 'lib/monaco-editor/min/vs' } });2require(['vs/editor/editor.main', 'js/proto3lang'], function (_, proto3lang)3{4 monaco.languages.register({ id: 'proto3lang' });5 monaco.languages.setMonarchTokensProvider('proto3lang', proto3lang);6 var editor = monaco.editor.create(document.getElementById('protocontainer'), {7 language: 'proto3lang'8 });9 var codeViewer = null;10 var codeResultSection = document.getElementById("coderesult");11 var oldDecorations = [];12 $(document).ready(function () {13 var hash = window.location.hash;14 if (hash.indexOf('#g') === 0 && hash.length > 2) {15 16 $.ajax({17 url: 'https://api.github.com/gists/' + hash.substr(2),18 type: 'GET',19 dataType: 'jsonp'20 }).success(function (gistdata) {21 // This can be less complicated if you know the gist file name22 var objects = [];23 for (file in gistdata.data.files) {24 if (gistdata.data.files.hasOwnProperty(file)) {25 editor.setValue(gistdata.data.files[file].content);26 break;27 }28 }29 }).error(function (e) { });30 }31 });32 document.getElementById("generatecsharp").addEventListener("click", function ()33 {34 jQuery.post("/generate", {35 schema: editor.getValue({ preserveBOM: false, lineEnding: "\n" }),36 tooling: $('#tooling').find(":selected").val()37 }, function(data, textStatus, jqXHR)38 {39 if (data === null || data === undefined)40 {41 return;42 }43 var decorations = [];44 if (data.files && data.files.length)45 {46 var code = data.files[0].text;47 codeResultSection.style.display = "";48 if (codeViewer === null)49 {50 codeViewer = monaco.editor.create(document.getElementById('csharpcontainer'), {51 value: code,52 language: 'csharp',53 readOnly: true54 });55 }56 else57 {58 codeViewer.setValue(code);59 }60 }61 if (data.parserExceptions)62 {63 var length = data.parserExceptions.length;64 var haveErrors = false;65 for (var i = 0; i < length; i++)66 {67 var parserException = data.parserExceptions[i];68 if (parserException.isError) { haveErrors = true; }69 decorations.push({70 range: new monaco.Range(parserException.lineNumber, parserException.columnNumber, parserException.lineNumber, parserException.columnNumber + parserException.text.length),71 options: {72 inlineClassName: parserException.isError ? "redsquiggly" : "greensquiggly",73 hoverMessage: parserException.message,74 overviewRuler: {75 color: parserException.isError ? "#E47777" : "#71B771",76 position: parserException.isError ? monaco.editor.OverviewRulerLane.Right : monaco.editor.OverviewRulerLane.Center77 }78 }79 });80 }81 if (haveErrors) { codeResultSection.style.display = "none"; }82 }83 if (data.exception)84 {85 codeResultSection.style.display = "none";86 decorations.push({87 range: new monaco.Range(1, 1, editor.getModel().getLineCount(), 1),88 options: {89 isWholeLine: true,90 inlineClassName: "redsquiggly",91 hoverMessage: data.exception.message92 }93 });94 }95 oldDecorations = editor.deltaDecorations(oldDecorations, decorations);96 }, "json");97 });...

Full Screen

Full Screen

all_d.js

Source:all_d.js Github

copy

Full Screen

2[3 ['parser_0',['Parser',['../classnts_1_1_parser.html',1,'nts::Parser'],['../classnts_1_1_parser.html#ad2a63c97e4af2728f2f1c52ee4984d82',1,'nts::Parser::Parser()']]],4 ['parser_2ecpp_1',['Parser.cpp',['../_parser_8cpp.html',1,'']]],5 ['parser_2ehpp_2',['Parser.hpp',['../_parser_8hpp.html',1,'']]],6 ['parserexception_3',['ParserException',['../classnts_1_1_exception_1_1_parser_exception.html',1,'nts::Exception::ParserException'],['../classnts_1_1_exception_1_1_parser_exception.html#a7932d49204550231d35015e0acf0a769',1,'nts::Exception::ParserException::ParserException()']]],7 ['pin_5fother_4',['pin_other',['../structnts_1_1_link_pair.html#ad6f2c0118e2b14c591c8820cfce6d055',1,'nts::LinkPair']]],8 ['pin_5fself_5',['pin_self',['../structnts_1_1_link_pair.html#ae472f460b51970be660fd519846fa681',1,'nts::LinkPair']]],9 ['pollstate_6',['pollState',['../classnts_1_1_a_component.html#a9a944052cf133bc1cecdd11a6d844748',1,'nts::AComponent::pollState()'],['../classnts_1_1_i_component.html#a7d711756b99b1760e05628c746c513f2',1,'nts::IComponent::pollState()']]]...

Full Screen

Full Screen

all_8.js

Source:all_8.js Github

copy

Full Screen

1var searchData=2[3 ['parametersneededexception',['ParametersNeededException',['../class_r_c_f_1_1_common_1_1_parameters_needed_exception.html',1,'RCF::Common']]],4 ['parametersneededexception',['ParametersNeededException',['../class_r_c_f_1_1_common_1_1_parameters_needed_exception.html#a6d5eb91489f48b7b7749799a2fbb5eb6',1,'RCF::Common::ParametersNeededException']]],5 ['parserexception',['ParserException',['../class_r_c_f_1_1_common_1_1_parser_exception.html#a5bd15dbf761e09667d86cdd95f980c1b',1,'RCF::Common::ParserException']]],6 ['parserexception',['ParserException',['../class_r_c_f_1_1_common_1_1_parser_exception.html',1,'RCF::Common']]],7 ['protocolexception',['ProtocolException',['../class_r_c_f_1_1_common_1_1_protocol_exception.html',1,'RCF::Common']]],8 ['protocolexception',['ProtocolException',['../class_r_c_f_1_1_common_1_1_protocol_exception.html#aa32f723d59444c644cb5ed4fe8ceaefc',1,'RCF::Common::ProtocolException']]]...

Full Screen

Full Screen

classCSF_1_1Zpt_1_1Tal_1_1ParserException.js

Source:classCSF_1_1Zpt_1_1Tal_1_1ParserException.js Github

copy

Full Screen

1var classCSF_1_1Zpt_1_1Tal_1_1ParserException =2[3 [ "ParserException", "classCSF_1_1Zpt_1_1Tal_1_1ParserException.html#a9a135052b726b8b203ff0e83128deb69", null ],4 [ "ParserException", "classCSF_1_1Zpt_1_1Tal_1_1ParserException.html#aba2366a00d1e4710b568a6f39706ae7f", null ],5 [ "ParserException", "classCSF_1_1Zpt_1_1Tal_1_1ParserException.html#ad6f26be33bb1bd804489a37e3e84a569", null ],6 [ "ParserException", "classCSF_1_1Zpt_1_1Tal_1_1ParserException.html#a4ac525955320fb97b3e8b95fba6ff1f2", null ],7 [ "SourceAttributeName", "classCSF_1_1Zpt_1_1Tal_1_1ParserException.html#a8886d0570bbe52914c3afe763297c2c7", null ],8 [ "SourceAttributeValue", "classCSF_1_1Zpt_1_1Tal_1_1ParserException.html#a594d84b419892323b933f0ddd66daf6c", null ],9 [ "SourceElementName", "classCSF_1_1Zpt_1_1Tal_1_1ParserException.html#a30efb8741853e12018187f89dc162cd3", null ]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var Parser = require('gherkin').Parser;2var ParserException = require('gherkin').ParserException;3var fs = require('fs');4var parser = new Parser();5var gherkinSource = fs.readFileSync('test.feature', 'utf8');6try {7 parser.parse(gherkinSource);8} catch (e) {9 if (e instanceof ParserException) {10 console.log(e.message);11 }12}

Full Screen

Using AI Code Generation

copy

Full Screen

1var ParserException = require('cucumber-gherkin').ParserException;2var parser = new ParserException();3var ParserException = require('gherkin').ParserException;4var parser = new ParserException();5var ParserException = require('gherkin-gherkin').ParserException;6var parser = new ParserException();7var ParserException = require('gherkin-javascript').ParserException;8var parser = new ParserException();9var ParserException = require('gherkin-javascript-gherkin').ParserException;10var parser = new ParserException();11var ParserException = require('gherkin-javascript-javascript').ParserException;12var parser = new ParserException();13var ParserException = require('gherkin-javascript-javascript-gherkin').ParserException;14var parser = new ParserException();15var ParserException = require('gherkin-javascript-javascript-javascript').ParserException;16var parser = new ParserException();17var ParserException = require('gherkin-javascript-javascript-javascript-gherkin').ParserException;18var parser = new ParserException();19var ParserException = require('gherkin-javascript-javascript-javascript-javascript').ParserException;20var parser = new ParserException();21var ParserException = require('gherkin-javascript-javascript-javascript-javascript-gherkin').ParserException;22var parser = new ParserException();23var ParserException = require('gherkin-javascript-javascript

Full Screen

Using AI Code Generation

copy

Full Screen

1var ParserException = require('cucumber-gherkin').ParserException;2console.log("ParserException: " + ParserException);3console.log("ParserException: " + ParserException.name);4console.log("ParserException: " + ParserException.message);5var ParserException = require('cucumber-gherkin/lib/parser_exception');6console.log("ParserException: " + ParserException);7console.log("ParserException: " + ParserException.name);8console.log("ParserException: " + ParserException.message);9var ParserException = require('cucumber/lib/cucumber/parser/parser_exception');10console.log("ParserException: " + ParserException);11console.log("ParserException: " + ParserException.name);12console.log("ParserException: " + ParserException.message);13var ParserException = require('cucumber/lib/parser/parser_exception');14console.log("ParserException: " + ParserException);15console.log("ParserException: " + ParserException.name);16console.log("ParserException: " + ParserException.message);17var ParserException = require('cucumber/lib/parser_exception');18console.log("ParserException: " + ParserException);19console.log("ParserException: " + ParserException.name);20console.log("ParserException: " + ParserException.message);21var ParserException = require('cucumber/lib/parser_exception');22console.log("ParserException: " + ParserException);23console.log("ParserException: " + ParserException.name);24console.log("ParserException: " + ParserException.message);25var ParserException = require('cucumber/lib/parser_exception');26console.log("ParserException: " + ParserException);27console.log("ParserException: " + ParserException.name);28console.log("ParserException: " + ParserException.message);29var ParserException = require('cucumber/lib/parser_exception');30console.log("ParserException: " + ParserException);31console.log("ParserException: " + ParserException.name);32console.log("ParserException: " + ParserException.message);33var ParserException = require('cucumber/lib/parser_exception');34console.log("ParserException: " + ParserException);

Full Screen

Using AI Code Generation

copy

Full Screen

1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var lexer = new gherkin.Lexer();4var fs = require('fs');5fs.readFile("features/feature1.feature", "utf8", function(err, data) {6 if (err) throw err;7 var token = lexer.lex(data);8 try {9 parser.parse(token);10 } catch (e) {11 console.log(e.toString());12 }13});

Full Screen

Using AI Code Generation

copy

Full Screen

1var ParserException = require('cucumber-gherkin').ParserException;2var parser = new ParserException();3console.log(parser.getMessage());4{5 "dependencies": {6 }7}

Full Screen

Using AI Code Generation

copy

Full Screen

1var ParserException = require('cucumber-gherkin').ParserException;2var fs = require('fs');3var file = fs.readFileSync('test.feature');4var parser = new ParserException();5var result = parser.parse(file.toString());6console.log(result);

Full Screen

Cucumber Tutorial:

LambdaTest offers a detailed Cucumber testing tutorial, explaining its features, importance, best practices, and more to help you get started with running your automation testing scripts.

Cucumber Tutorial Chapters:

Here are the detailed Cucumber testing chapters to help you get started:

  • Importance of Cucumber - Learn why Cucumber is important in Selenium automation testing during the development phase to identify bugs and errors.
  • Setting Up Cucumber in Eclipse and IntelliJ - Learn how to set up Cucumber in Eclipse and IntelliJ.
  • Running First Cucumber.js Test Script - After successfully setting up your Cucumber in Eclipse or IntelliJ, this chapter will help you get started with Selenium Cucumber testing in no time.
  • Annotations in Cucumber - To handle multiple feature files and the multiple scenarios in each file, you need to use functionality to execute these scenarios. This chapter will help you learn about a handful of Cucumber annotations ranging from tags, Cucumber hooks, and more to ease the maintenance of the framework.
  • Automation Testing With Cucumber And Nightwatch JS - Learn how to build a robust BDD framework setup for performing Selenium automation testing by integrating Cucumber into the Nightwatch.js framework.
  • Automation Testing With Selenium, Cucumber & TestNG - Learn how to perform Selenium automation testing by integrating Cucumber with the TestNG framework.
  • Integrate Cucumber With Jenkins - By using Cucumber with Jenkins integration, you can schedule test case executions remotely and take advantage of the benefits of Jenkins. Learn how to integrate Cucumber with Jenkins with this detailed chapter.
  • Cucumber Best Practices For Selenium Automation - Take a deep dive into the advanced use cases, such as creating a feature file, separating feature files, and more for Cucumber testing.

Run Cucumber-gherkin automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful