Lots of work on the parser including testing interface
This commit is contained in:
19
app/imports/parser/parseTree/ParenthesisNode.js
Normal file
19
app/imports/parser/parseTree/ParenthesisNode.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import ParseNode from '/imports/parser/parseTree/ParseNode.js';
|
||||
|
||||
export default class ParenthesisNode extends ParseNode {
|
||||
constructor({content}) {
|
||||
super();
|
||||
this.content = content;
|
||||
}
|
||||
compile(){
|
||||
let content = this.content.compile();
|
||||
if (content.constructor.name === 'ConstantNode'){
|
||||
return content;
|
||||
} else {
|
||||
return new ParenthesisNode({content});
|
||||
}
|
||||
}
|
||||
toString(){
|
||||
return `(${this.content.toString()})`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user