-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathkwnodekuro.js
28 lines (22 loc) · 910 Bytes
/
kwnodekuro.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const constants = require("../../constants.js");
const BaseNode = require("../basenode.js");
const feedbackMessages = require("../../feedbackMessages.js");
class KwNodeKuro extends BaseNode {
getNode () {
if (KwNodeKuro.isExpectedKuroStatement(this)) {
return KwNodeKuro.getParsedKuroNode(this);
}
this.throwError(feedbackMessages.unexpectedDeclaration(constants.KW.KURO));
}
static isExpectedKuroStatement (context) {
return context.getBlockTypeStack().includes(constants.KW.FUN) ||
context.getBlockTypeStack().includes(constants.KW.NIGBATI);
}
static getParsedKuroNode (context) {
const node = {};
node.operation = context.lexer().next().value;
context.skipPunctuation(constants.SYM.STATEMENT_TERMINATOR);
return node;
}
}
module.exports = new KwNodeKuro();