From a0d72b468e3949d294fdef1f51a2bb26d52ccb2a Mon Sep 17 00:00:00 2001 From: "karounwi.anuoluwapo" Date: Thu, 20 Dec 2018 15:25:50 +0100 Subject: [PATCH] Feature- translated all error messages to yoruba --- cli.js | 27 ++++++++++++++------- src/feedbackMessages.js | 29 ++++++++++++++++++++++- src/interpreters/inodearrayelem.js | 5 ++-- src/interpreters/inodecallise.js | 4 +++- src/interpreters/inodedivide.js | 3 ++- src/interpreters/inodegetjeki.js | 4 +++- src/interpreters/inodeise.js | 3 ++- src/interpreters/inodejeki.js | 7 +++--- src/interpreters/inodenegateexpression.js | 3 ++- src/interpreters/maininterpreter.js | 2 ++ src/parsers/keywordnodes/kwnodefun.js | 5 ++-- src/parsers/keywordnodes/kwnodegbewole.js | 5 ++-- src/parsers/keywordnodes/kwnodeise.js | 3 ++- src/parsers/keywordnodes/kwnodejeki.js | 3 ++- src/parsers/keywordnodes/kwnodekuro.js | 3 ++- src/parsers/keywordnodes/kwnodenigbati.js | 3 ++- src/parsers/keywordnodes/kwnodepada.js | 3 ++- src/parsers/keywordnodes/kwnodese.js | 4 +++- src/parsers/keywordnodes/kwnodewoke.js | 3 ++- src/parsers/keywordnodes/kwnodeyi.js | 3 ++- src/parsers/nodeLiterals/keywordnl.js | 9 +++---- src/parsers/nodeLiterals/variablenl.js | 3 ++- 22 files changed, 97 insertions(+), 37 deletions(-) diff --git a/cli.js b/cli.js index 56bcc95..3265487 100755 --- a/cli.js +++ b/cli.js @@ -2,11 +2,6 @@ const packageJson = require("./package.json"); const path = require("path"); -const InputStream = require("./src/inputstream.js"); -const Lexer = require("./src/lexer.js"); -const Parser = require("./src/parsers/parser.js"); -const Environment = require("./src/environment.js"); -const MainInterpreter = require("./src/interpreters/maininterpreter.js"); const constants = require("./src/constants.js"); const commander = require("commander"); @@ -25,13 +20,27 @@ commander.arguments("[file]") .option("-l, --lang [lang]", "Select language to use") .action((file, options) => { if (path.extname(file) === constants.YL_EXT) { - const lang = [ "english", "yoruba", ]; - global.defaultLang = lang.includes(options.lang) ? options.lang : "english"; - const parser = new Parser(new Lexer(new InputStream(file))); - new MainInterpreter(new Environment(), parser).interpreteProgram(); + setGlobalVars(options); + startYorlangProcess(file); } else { throw new Error("Invalid Yorlang file. Expected a .yl file"); } }); commander.parse(process.argv); + +function setGlobalVars (options) { + const lang = [ "english", "yoruba", ]; + global.defaultLang = lang.includes(options.lang) ? options.lang : "english"; +} + +function startYorlangProcess (file) { + const InputStream = require("./src/inputstream.js"); + const Lexer = require("./src/lexer.js"); + const Parser = require("./src/parsers/parser.js"); + const Environment = require("./src/environment.js"); + const MainInterpreter = require("./src/interpreters/maininterpreter.js"); + + const parser = new Parser(new Lexer(new InputStream(file))); + new MainInterpreter(new Environment(), parser).interpreteProgram(); +} diff --git a/src/feedbackMessages.js b/src/feedbackMessages.js index 73fe215..b870d94 100644 --- a/src/feedbackMessages.js +++ b/src/feedbackMessages.js @@ -2,11 +2,38 @@ const message = { english: { baseNodeType: (arg) => `${arg} must be of type BaseNode`, genericErrorMsg: (arg) => `Cannot process unexpected token : ${arg}`, + funIncrementAndDecrementMsg: () => "Invalid yorlang decrement or increment operation", + invalidFileMsg: () => "Invalid yorlang file. Expected file with .yl extension", + invalidAssignment: () => "Cannot assign value to yorlang ise call", + invalidArrayIndexTypeMsg: (arg) => `Typeof index given for array ${arg} must be a number`, + arrayIndexDoesNotExistMsg: (arg) => `Index given for array ${arg} does not exist`, + varDoesNotExist: (type, name) => `${type} ${name} is undefined`, + iseAlreadyExist: (name, scope) => `Ise with name ${name} already exists within the ${scope} scope`, + expectStringMsg: (arg) => `${arg} expects a string`, + expectBooleanMsg: () => "Expecting yorlang keyword value e.g boolean(iró|òótó)", + unexpectedDeclaration: (arg) => `Yorlang ${arg} keyword not expected`, + yorlangArithmeticException: () => "YorlangArithmeticException - cannot divide by zero", + undefinedValueMsg: (arg) => `Cannot set value undefined to variable ${arg}`, + cannotNegateMsg: (arg) => `Cannot apply negation operator to the given expression: ${arg}`, + }, yoruba: { baseNodeType: (arg) => `${arg} gbọdọ jẹ ti iru BaseNode`, - genericErrorMsg: (arg) => `kò lè ṣiṣẹ́ pẹlú ààmì ìfura tó yọjú láìròtẹ́lẹ : ${arg}`, + genericErrorMsg: (arg) => `Yorlang ò lè ṣiṣẹ́ pẹlú ààmì ìfura tó yọjú láìròtẹ́lẹ : ${arg}`, + funIncrementAndDecrementMsg: () => "Ilana ti ko dara ti yorlang nidi ise afikun tabi iyokuro ninu 'fun'", + invalidFileMsg: () => "Yorlang ko ri faili ti oruko re pari pelu .yl", + invalidAssignment: () => "Yorlang ko le fun ipe ise ni iye", + invalidArrayIndexTypeMsg: (arg) => `Atọka to je ti array ${arg} gbodo je nomba`, + arrayIndexDoesNotExistMsg: (arg) => `Atọka to je ti array ${arg} ko si ninu ibi itoju nkan pamo yorlang`, + varDoesNotExist: (type, name) => `${type} ${name} ko si ninu ibi itoju nkan pamo yorlang`, + iseAlreadyExist: (name, scope) => `Ise to ni oruko ${name} ti wa ninu odi ${scope} tẹ́lẹ`, + expectStringMsg: (arg) => `${arg} ti yorlang n reti string`, + expectBooleanMsg: (arg) => "Yorlang n reti ooto tabi iro", + unexpectedDeclaration: (arg) => `Yorlang ko reti '${arg}' ninu odi to ti yọjú`, + yorlangArithmeticException: () => "YorlangArithmeticException - yorlang ko le se isiro pipin nipase òdo", + undefinedValueMsg: (arg) => `Yorlang ko le fi ofifo sinu ${arg}`, + cannotNegateMsg: (arg) => `Yorlang ò le lo aami iyokuru pelu ${arg} `, }, }; diff --git a/src/interpreters/inodearrayelem.js b/src/interpreters/inodearrayelem.js index 8ec7f97..903e44b 100644 --- a/src/interpreters/inodearrayelem.js +++ b/src/interpreters/inodearrayelem.js @@ -1,5 +1,6 @@ const IBase = require("./ibase.js"); const contansts = require("../constants.js"); +const feedbackMessages = require("../feedbackMessages.js"); class INodeArrayElement extends IBase { interpreteNode (node) { @@ -19,11 +20,11 @@ class INodeArrayElement extends IBase { arrayElement = (isOnedimensionalArray) ? arrayLiteral[index] : arrayElement[index]; isOnedimensionalArray = false; } else { - context.throwError(`Typeof index given for array ${node.name} must be a number`); + context.throwError(feedbackMessages.invalidArrayIndexTypeMsg(node.name)); } }); - if (!arrayElement) context.throwError(`Index given for array ${node.name} does not exist`); + if (!arrayElement) context.throwError(feedbackMessages.arrayIndexDoesNotExistMsg(node.name)); return arrayElement; } diff --git a/src/interpreters/inodecallise.js b/src/interpreters/inodecallise.js index 85c36b2..585a92e 100644 --- a/src/interpreters/inodecallise.js +++ b/src/interpreters/inodecallise.js @@ -1,5 +1,7 @@ const IBase = require("./ibase.js"); const getFormattedReturnValue = require("./helpers/helper_ise_adapter"); +const feedbackMessages = require("../feedbackMessages.js"); +const constants = require("../constants.js"); class INodeCallIse extends IBase { interpreteNode (node) { @@ -10,7 +12,7 @@ class INodeCallIse extends IBase { return getFormattedReturnValue(this.environment().runHelperIse(node.name, INodeCallIse.getIseHelperParams(this, node.paramValues))); } - this.throwError(`Ise ${node.name} is undefined`); + this.throwError(feedbackMessages.varDoesNotExist(constants.KW.ISE, node.name)); } return INodeCallIse.startNewScope(this, iseNode, INodeCallIse.getResolvedParameterValues(this, node.paramValues)); diff --git a/src/interpreters/inodedivide.js b/src/interpreters/inodedivide.js index 843f59c..d6585f7 100644 --- a/src/interpreters/inodedivide.js +++ b/src/interpreters/inodedivide.js @@ -1,10 +1,11 @@ const IBase = require("./ibase.js"); +const feedbackMessages = require("../feedbackMessages.js"); class INodeDivide extends IBase { interpreteNode (node) { const leftNodeValue = this.evaluateNode(node.left); const rightNodeValue = this.evaluateNode(node.right); - if (rightNodeValue === 0) this.throwError("YorlangArithmeticException - cannot divide by zero"); + if (rightNodeValue === 0) this.throwError(feedbackMessages.yorlangArithmeticException()); return leftNodeValue / rightNodeValue; } diff --git a/src/interpreters/inodegetjeki.js b/src/interpreters/inodegetjeki.js index e556ad0..ba1ad0f 100644 --- a/src/interpreters/inodegetjeki.js +++ b/src/interpreters/inodegetjeki.js @@ -1,5 +1,7 @@ const IBase = require("./ibase.js"); const WokeHelper = require("./helpers/woke_helper.js"); +const feedbackMessages = require("../feedbackMessages.js"); +const constants = require("../constants.js"); class INodeGetJeki extends IBase { interpreteNode (node) { @@ -9,7 +11,7 @@ class INodeGetJeki extends IBase { } } - this.throwError(`Variable ${node.name} is undefined`); + this.throwError(feedbackMessages.varDoesNotExist(constants.VARIABLE, node.name)); } static getTopIndex (context, jekiName) { diff --git a/src/interpreters/inodeise.js b/src/interpreters/inodeise.js index 349634e..b5f2db7 100644 --- a/src/interpreters/inodeise.js +++ b/src/interpreters/inodeise.js @@ -1,8 +1,9 @@ const IBase = require("./ibase.js"); +const feedbackMessages = require("../feedbackMessages.js"); class INodeIse extends IBase { interpreteNode (node) { - if (this.environment().getIse(this.getCurrentScope(), node.name) !== undefined) { this.throwError(`Ise with name ${node.name} already exists within the ${this.getCurrentScope()} scope`); } + if (this.environment().getIse(this.getCurrentScope(), node.name) !== undefined) { this.throwError(feedbackMessages.iseAlreadyExist(node.name, this.getCurrentScope())); } this.environment().setIse(this.getCurrentScope(), node.name, node); } diff --git a/src/interpreters/inodejeki.js b/src/interpreters/inodejeki.js index 3c976a7..8899da9 100644 --- a/src/interpreters/inodejeki.js +++ b/src/interpreters/inodejeki.js @@ -1,6 +1,7 @@ const IBase = require("./ibase.js"); const constants = require("../constants.js"); const WokeHelper = require("./helpers/woke_helper.js"); +const feedbackMessages = require("../feedbackMessages.js"); class INodeJeki extends IBase { interpreteNode (node) { @@ -41,7 +42,7 @@ class INodeJeki extends IBase { if (typeof arrayIndex === "number") { if (!(Array.isArray(arrayLiteral[arrayIndex])) && (i < node.left.indexNodes.length - 1)) { - context.throwError(`Cannot set invalid array element for array : ${node.left.name}`); + context.throwError(feedbackMessages.arrayIndexDoesNotExistMsg(node.left.name)); } if ((Array.isArray(arrayLiteral[arrayIndex])) && (i < node.left.indexNodes.length - 1)) { @@ -52,7 +53,7 @@ class INodeJeki extends IBase { arrayLiteral[arrayIndex] = context.evaluateNode(node.right); } } else { - context.throwError(`Typeof index given for array ${node.name} must be a number`); + context.throwError(feedbackMessages.invalidArrayIndexTypeMsg(node.name)); } }; } @@ -64,7 +65,7 @@ class INodeJeki extends IBase { static getValue (context, node) { const value = context.evaluateNode(node); - if (value === undefined) context.throwError(`Cannot set value undefined to variable ${node.left}`); + if (value === undefined) context.throwError(feedbackMessages.undefinedValueMsg(node.left)); return value; } } diff --git a/src/interpreters/inodenegateexpression.js b/src/interpreters/inodenegateexpression.js index f8b1150..bc049d0 100644 --- a/src/interpreters/inodenegateexpression.js +++ b/src/interpreters/inodenegateexpression.js @@ -1,11 +1,12 @@ const IBase = require("./ibase.js"); +const feedbackMessages = require("../feedbackMessages.js"); class INodeNegateExpression extends IBase { interpreteNode (node) { const expressionValue = this.evaluateNode(node.body); if (typeof expressionValue === "number") return -parseFloat(expressionValue); - this.throwError("Cannot apply negation operator to the given expression"); + this.throwError(feedbackMessages.cannotNegateMsg(expressionValue)); } } diff --git a/src/interpreters/maininterpreter.js b/src/interpreters/maininterpreter.js index db823e7..75df81f 100644 --- a/src/interpreters/maininterpreter.js +++ b/src/interpreters/maininterpreter.js @@ -1,11 +1,13 @@ const registeredInterpreters = require("./interpreters.js"); const constants = require("../constants.js"); const IBase = require("./ibase.js"); +const feedbackMessages = require("../feedbackMessages.js"); class MainInterpreter { constructor (environment, parser) { this.environment = () => environment; this.parser = () => parser; + this.feedbackMessages = feedbackMessages; this.initScopeStack(); } diff --git a/src/parsers/keywordnodes/kwnodefun.js b/src/parsers/keywordnodes/kwnodefun.js index 3428124..80d4958 100644 --- a/src/parsers/keywordnodes/kwnodefun.js +++ b/src/parsers/keywordnodes/kwnodefun.js @@ -1,13 +1,14 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); const kwNodeJeki = require("./kwnodejeki.js"); +const feedbackMessages = require("../../feedbackMessages.js"); const bracketExpressionNl = require("../nodeLiterals/bracketexpressionnl.js"); class KwNodeFun extends BaseNode { constructor () { super(); if (this.isDependenciesInValid()) { - throw new Error("Dependencies must be of type BaseNode"); + throw new Error(feedbackMessages.baseNodeType("Dependencies")); } } @@ -28,7 +29,7 @@ class KwNodeFun extends BaseNode { node.increment = kwNodeJeki.getNode.call(this); if (KwNodeFun.isInValidFunIncrementStatement(node)) { - this.throwError("Invalid yorlang decrement or increment operation"); + this.throwError(feedbackMessages.funIncrementAndDecrementMsg()); } this.skipPunctuation(constants.SYM.R_BRACKET); diff --git a/src/parsers/keywordnodes/kwnodegbewole.js b/src/parsers/keywordnodes/kwnodegbewole.js index 52b93f2..70b25cb 100644 --- a/src/parsers/keywordnodes/kwnodegbewole.js +++ b/src/parsers/keywordnodes/kwnodegbewole.js @@ -2,6 +2,7 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); const leafnl = require("../nodeLiterals/leafnl.js"); const path = require("path"); +const feedbackMessages = require("../../feedbackMessages.js"); class KwNodeGbeWole extends BaseNode { getNode () { @@ -11,13 +12,13 @@ class KwNodeGbeWole extends BaseNode { if (this.lexer().peek().type === constants.STRING) { node.path = leafnl.getNode.call(this); - if (path.extname(node.path.value) !== constants.YL_EXT) { this.throwError("Invalid yorlang file. Expected file with .yl extension"); } + if (path.extname(node.path.value) !== constants.YL_EXT) { this.throwError(feedbackMessages.invalidFileMsg()); } this.skipPunctuation(constants.SYM.STATEMENT_TERMINATOR); return node; } - this.lexer().throwError(`${constants.KW.GBE_WOLE} expects a string.`); + this.lexer().throwError(feedbackMessages.expectStringMsg(constants.KW.GBE_WOLE)); } } diff --git a/src/parsers/keywordnodes/kwnodeise.js b/src/parsers/keywordnodes/kwnodeise.js index bb2e379..779a319 100644 --- a/src/parsers/keywordnodes/kwnodeise.js +++ b/src/parsers/keywordnodes/kwnodeise.js @@ -1,5 +1,6 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); +const feedbackMessages = require("../../feedbackMessages.js"); class KwNodeIse extends BaseNode { getNode () { @@ -7,7 +8,7 @@ class KwNodeIse extends BaseNode { return KwNodeIse.getParsedIseNode(this); } - this.throwError("Cannot create a yorlang function within a non function block"); + this.throwError(feedbackMessages.unexpectedDeclaration(constants.KW.ISE)); } static isExpectedIseDeclaration (context) { diff --git a/src/parsers/keywordnodes/kwnodejeki.js b/src/parsers/keywordnodes/kwnodejeki.js index f3bf51f..4ca044a 100644 --- a/src/parsers/keywordnodes/kwnodejeki.js +++ b/src/parsers/keywordnodes/kwnodejeki.js @@ -1,6 +1,7 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); const variableNl = require("../nodeLiterals/variablenl.js"); +const feedbackMessages = require("../../feedbackMessages.js"); class KwNodeJeki extends BaseNode { getNode () { @@ -9,7 +10,7 @@ class KwNodeJeki extends BaseNode { const node = {}; node.operation = constants.SYM.ASSIGN; const varNode = variableNl.getNode.call(this); - if (varNode.operation === constants.CALL_ISE) this.throwError("Cannot assign value to yorlang ise call"); + if (varNode.operation === constants.CALL_ISE) this.throwError(feedbackMessages.invalidAssignment()); node.left = (varNode.operation === constants.GET_JEKI) ? varNode.name : varNode; this.skipOperator(constants.SYM.ASSIGN); node.right = this.parseExpression(); diff --git a/src/parsers/keywordnodes/kwnodekuro.js b/src/parsers/keywordnodes/kwnodekuro.js index 022879f..fab2ceb 100644 --- a/src/parsers/keywordnodes/kwnodekuro.js +++ b/src/parsers/keywordnodes/kwnodekuro.js @@ -1,5 +1,6 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); +const feedbackMessages = require("../../feedbackMessages.js"); class KwNodeKuro extends BaseNode { getNode () { @@ -7,7 +8,7 @@ class KwNodeKuro extends BaseNode { return KwNodeKuro.getParsedKuroNode(this); } - this.throwError("Yorlang Kuro keyword not expected"); + this.throwError(feedbackMessages.unexpectedDeclaration(constants.KW.KURO)); } static isExpectedKuroStatement (context) { diff --git a/src/parsers/keywordnodes/kwnodenigbati.js b/src/parsers/keywordnodes/kwnodenigbati.js index b570703..ed5b464 100644 --- a/src/parsers/keywordnodes/kwnodenigbati.js +++ b/src/parsers/keywordnodes/kwnodenigbati.js @@ -1,12 +1,13 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); const bracketExpressionNl = require("../nodeLiterals/bracketexpressionnl.js"); +const feedbackMessages = require("../../feedbackMessages.js"); class KwNodeNigbati extends BaseNode { constructor () { super(); if (!(bracketExpressionNl instanceof BaseNode)) { - throw new Error("Dependency bracketExpressionNl must be of type BaseNode"); + throw new Error(feedbackMessages.baseNodeType("Dependencies bracketExpressionNl")); } } diff --git a/src/parsers/keywordnodes/kwnodepada.js b/src/parsers/keywordnodes/kwnodepada.js index 5a82a2c..96c95ea 100644 --- a/src/parsers/keywordnodes/kwnodepada.js +++ b/src/parsers/keywordnodes/kwnodepada.js @@ -1,5 +1,6 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); +const feedbackMessages = require("../../feedbackMessages.js"); class KwNodePada extends BaseNode { getNode () { @@ -7,7 +8,7 @@ class KwNodePada extends BaseNode { return KwNodePada.getParsedPadaNode(this); } - this.throwError("Yorlang pada keyword not expected in a non function(ise) block"); + this.throwError(feedbackMessages.unexpectedDeclaration(constants.KW.PADA)); } static isExpectedPadaStatement (context) { diff --git a/src/parsers/keywordnodes/kwnodese.js b/src/parsers/keywordnodes/kwnodese.js index 8aed3f0..2e4709e 100644 --- a/src/parsers/keywordnodes/kwnodese.js +++ b/src/parsers/keywordnodes/kwnodese.js @@ -1,11 +1,13 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); const bracketExpressionNl = require("../nodeLiterals/bracketexpressionnl.js"); +const feedbackMessages = require("../../feedbackMessages.js"); + class KwNodeSe extends BaseNode { constructor () { super(); if (!(bracketExpressionNl instanceof BaseNode)) { - throw new Error("Dependency brackExpressionNl must be of type BaseNode"); + throw new Error(feedbackMessages.baseNodeType("Dependency brackExpressionNl")); } } diff --git a/src/parsers/keywordnodes/kwnodewoke.js b/src/parsers/keywordnodes/kwnodewoke.js index d880e97..fef5166 100644 --- a/src/parsers/keywordnodes/kwnodewoke.js +++ b/src/parsers/keywordnodes/kwnodewoke.js @@ -1,5 +1,6 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); +const feedbackMessages = require("../../feedbackMessages.js"); class KwNodeWoke extends BaseNode { getNode () { @@ -7,7 +8,7 @@ class KwNodeWoke extends BaseNode { return KwNodeWoke.getParsedWokeNode(this); } - this.throwError("Yorlang woke keyword not expected in a non function(ise) block"); + this.throwError(feedbackMessages.unexpectedDeclaration(constants.KW.WOKE)); } static isExpectedWokeStatement (context) { diff --git a/src/parsers/keywordnodes/kwnodeyi.js b/src/parsers/keywordnodes/kwnodeyi.js index 47fdf6d..980a697 100644 --- a/src/parsers/keywordnodes/kwnodeyi.js +++ b/src/parsers/keywordnodes/kwnodeyi.js @@ -1,12 +1,13 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); const bracketExpressionNl = require("../nodeLiterals/bracketexpressionnl.js"); +const feedbackMessages = require("../../feedbackMessages.js"); class KwNodeYi extends BaseNode { constructor () { super(); if (!(bracketExpressionNl instanceof BaseNode)) { - throw new Error("Dependency brackExpressionNl must be of type BaseNode"); + throw new Error(feedbackMessages.baseNodeType("Dependency bracketExpressionNl")); } } diff --git a/src/parsers/nodeLiterals/keywordnl.js b/src/parsers/nodeLiterals/keywordnl.js index f36c118..fd905dd 100644 --- a/src/parsers/nodeLiterals/keywordnl.js +++ b/src/parsers/nodeLiterals/keywordnl.js @@ -1,24 +1,25 @@ const constants = require("../../constants.js"); const leafNl = require("./leafnl.js"); const BaseNode = require("../basenode.js"); +const feedbackMessages = require("../../feedbackMessages.js"); class KeywordNl extends BaseNode { constructor () { super(); if (!(leafNl instanceof BaseNode)) { - throw new Error("Dependency leafNl must be of type BaseNode"); + throw new Error(feedbackMessages.baseNodeType("Dependency leafnl")); } } getNode () { - if (KeywordNl.isKeywordNl(this)) { + if (KeywordNl.isBooleanKeywordNl(this)) { return leafNl.getNode.call(this); } - this.throwError("Expecting yorlang keyword value e.g boolean(iró|òótó)"); + this.throwError(feedbackMessages.expectBooleanMsg()); } - static isKeywordNl (context) { + static isBooleanKeywordNl (context) { return [ constants.KW.OOTO, constants.KW.IRO, ].includes(context.lexer().peek().value); } } diff --git a/src/parsers/nodeLiterals/variablenl.js b/src/parsers/nodeLiterals/variablenl.js index cfced64..bf3eb0a 100644 --- a/src/parsers/nodeLiterals/variablenl.js +++ b/src/parsers/nodeLiterals/variablenl.js @@ -1,6 +1,7 @@ const constants = require("../../constants.js"); const BaseNode = require("../basenode.js"); const variableNlTypes = require("./variablenltypes"); +const feedbackMessages = require("../../feedbackMessages.js"); class VariableNl extends BaseNode { getNode () { @@ -10,7 +11,7 @@ class VariableNl extends BaseNode { if (variableNlTypes[nextTokenValue]) { const variableNlType = variableNlTypes[nextTokenValue]; if (variableNlType instanceof BaseNode) return variableNlType.getNode.call(this, varNameToken); - else throw new Error(`Dependency ${variableNlType} must be of type BaseNode`); + else throw new Error(feedbackMessages.baseNodeType(variableNlType)); } return {