mirror of
https://github.com/Gers2017/cpp.js.git
synced 2025-02-16 13:58:20 -06:00
- Move generate_rust_code to interpreter - Clean stuff.js - Parse command line arguments
55 lines
931 B
JavaScript
55 lines
931 B
JavaScript
export class Stmt {}
|
|
|
|
export class PrintStmt extends Stmt {
|
|
/**
|
|
*
|
|
* @param {string} string
|
|
* @param {string[] | undefined} args
|
|
*/
|
|
constructor(string, args) {
|
|
super();
|
|
this.string = string;
|
|
this.args = args ?? [];
|
|
}
|
|
}
|
|
|
|
export class ReturnStmt extends Stmt {
|
|
/**
|
|
*
|
|
* @param {NumberExpr} value
|
|
*/
|
|
constructor(value) {
|
|
super();
|
|
this.value = value;
|
|
}
|
|
}
|
|
|
|
// TODO
|
|
export class IfStmt extends Stmt {}
|
|
|
|
export class ElseStmt extends Stmt {}
|
|
|
|
export class AST {}
|
|
|
|
export class Block extends AST {
|
|
constructor(stmts) {
|
|
super();
|
|
this.stmts = stmts;
|
|
}
|
|
}
|
|
|
|
export class NumberNode extends AST {
|
|
constructor(value) {
|
|
super();
|
|
this.value = value;
|
|
}
|
|
}
|
|
|
|
export class BinaryExpr extends AST {
|
|
constructor(left, right) {
|
|
super();
|
|
this.left = left;
|
|
this.right = right;
|
|
}
|
|
}
|