Sprint 2 Step 3: all Statement, Expression, Type, and Parameter concepts
Ports all 33 SemAnno concepts from MPS into C++ headers grouped by category. Test builds the exact Calculator model from Phase1Test.mps as a 27-node C++ object graph and verifies every property, child link, and parent chain. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
107
editor/src/ast/Expression.h
Normal file
107
editor/src/ast/Expression.h
Normal file
@@ -0,0 +1,107 @@
|
||||
#pragma once
|
||||
#include "ASTNode.h"
|
||||
|
||||
class Expression : public ASTNode {
|
||||
public:
|
||||
Expression() { conceptType = "Expression"; }
|
||||
};
|
||||
|
||||
class BinaryOperation : public Expression {
|
||||
public:
|
||||
std::string op;
|
||||
BinaryOperation() { conceptType = "BinaryOperation"; }
|
||||
BinaryOperation(const std::string& id, const std::string& op) : op(op) {
|
||||
this->id = id;
|
||||
this->conceptType = "BinaryOperation";
|
||||
}
|
||||
// children: left (1), right (1) via setChild
|
||||
};
|
||||
|
||||
class UnaryOperation : public Expression {
|
||||
public:
|
||||
std::string op;
|
||||
UnaryOperation() { conceptType = "UnaryOperation"; }
|
||||
// children: operand (1) via setChild("operand", ...)
|
||||
};
|
||||
|
||||
class FunctionCall : public Expression {
|
||||
public:
|
||||
std::string functionName;
|
||||
FunctionCall() { conceptType = "FunctionCall"; }
|
||||
// children: arguments (0..n) via addChild("arguments", ...)
|
||||
};
|
||||
|
||||
class VariableReference : public Expression {
|
||||
public:
|
||||
std::string variableName;
|
||||
VariableReference() { conceptType = "VariableReference"; }
|
||||
VariableReference(const std::string& id, const std::string& varName)
|
||||
: variableName(varName) {
|
||||
this->id = id;
|
||||
this->conceptType = "VariableReference";
|
||||
}
|
||||
};
|
||||
|
||||
class IntegerLiteral : public Expression {
|
||||
public:
|
||||
int value = 0;
|
||||
IntegerLiteral() { conceptType = "IntegerLiteral"; }
|
||||
IntegerLiteral(const std::string& id, int val) : value(val) {
|
||||
this->id = id;
|
||||
this->conceptType = "IntegerLiteral";
|
||||
}
|
||||
};
|
||||
|
||||
class FloatLiteral : public Expression {
|
||||
public:
|
||||
std::string value;
|
||||
FloatLiteral() { conceptType = "FloatLiteral"; }
|
||||
FloatLiteral(const std::string& id, const std::string& val) : value(val) {
|
||||
this->id = id;
|
||||
this->conceptType = "FloatLiteral";
|
||||
}
|
||||
};
|
||||
|
||||
class StringLiteral : public Expression {
|
||||
public:
|
||||
std::string value;
|
||||
StringLiteral() { conceptType = "StringLiteral"; }
|
||||
StringLiteral(const std::string& id, const std::string& val) : value(val) {
|
||||
this->id = id;
|
||||
this->conceptType = "StringLiteral";
|
||||
}
|
||||
};
|
||||
|
||||
class BooleanLiteral : public Expression {
|
||||
public:
|
||||
bool value = false;
|
||||
BooleanLiteral() { conceptType = "BooleanLiteral"; }
|
||||
BooleanLiteral(const std::string& id, bool val) : value(val) {
|
||||
this->id = id;
|
||||
this->conceptType = "BooleanLiteral";
|
||||
}
|
||||
};
|
||||
|
||||
class NullLiteral : public Expression {
|
||||
public:
|
||||
NullLiteral() { conceptType = "NullLiteral"; }
|
||||
};
|
||||
|
||||
class ListLiteral : public Expression {
|
||||
public:
|
||||
ListLiteral() { conceptType = "ListLiteral"; }
|
||||
// children: elements (0..n) via addChild("elements", ...)
|
||||
};
|
||||
|
||||
class IndexAccess : public Expression {
|
||||
public:
|
||||
IndexAccess() { conceptType = "IndexAccess"; }
|
||||
// children: target (1), index (1) via setChild
|
||||
};
|
||||
|
||||
class MemberAccess : public Expression {
|
||||
public:
|
||||
std::string memberName;
|
||||
MemberAccess() { conceptType = "MemberAccess"; }
|
||||
// children: target (1) via setChild("target", ...)
|
||||
};
|
||||
14
editor/src/ast/Parameter.h
Normal file
14
editor/src/ast/Parameter.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "ASTNode.h"
|
||||
|
||||
class Parameter : public ASTNode {
|
||||
public:
|
||||
std::string name;
|
||||
Parameter() { conceptType = "Parameter"; }
|
||||
Parameter(const std::string& id, const std::string& name) : name(name) {
|
||||
this->id = id;
|
||||
this->conceptType = "Parameter";
|
||||
}
|
||||
// children: type (1) via setChild("type", ...)
|
||||
// children: defaultValue (0..1) via setChild("defaultValue", ...)
|
||||
};
|
||||
55
editor/src/ast/Statement.h
Normal file
55
editor/src/ast/Statement.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
#include "ASTNode.h"
|
||||
|
||||
class Statement : public ASTNode {
|
||||
public:
|
||||
Statement() { conceptType = "Statement"; }
|
||||
};
|
||||
|
||||
class Block : public Statement {
|
||||
public:
|
||||
Block() { conceptType = "Block"; }
|
||||
// children: statements (0..n) via addChild("statements", ...)
|
||||
};
|
||||
|
||||
class Assignment : public Statement {
|
||||
public:
|
||||
Assignment() { conceptType = "Assignment"; }
|
||||
// children: target (1) via setChild("target", ...)
|
||||
// children: value (1) via setChild("value", ...)
|
||||
};
|
||||
|
||||
class IfStatement : public Statement {
|
||||
public:
|
||||
IfStatement() { conceptType = "IfStatement"; }
|
||||
// children: condition (1) via setChild("condition", ...)
|
||||
// children: thenBranch (0..n) via addChild("thenBranch", ...)
|
||||
// children: elseBranch (0..n) via addChild("elseBranch", ...)
|
||||
};
|
||||
|
||||
class WhileLoop : public Statement {
|
||||
public:
|
||||
WhileLoop() { conceptType = "WhileLoop"; }
|
||||
// children: condition (1) via setChild("condition", ...)
|
||||
// children: body (0..n) via addChild("body", ...)
|
||||
};
|
||||
|
||||
class ForLoop : public Statement {
|
||||
public:
|
||||
std::string iteratorName;
|
||||
ForLoop() { conceptType = "ForLoop"; }
|
||||
// children: iterable (1) via setChild("iterable", ...)
|
||||
// children: body (0..n) via addChild("body", ...)
|
||||
};
|
||||
|
||||
class Return : public Statement {
|
||||
public:
|
||||
Return() { conceptType = "Return"; }
|
||||
// children: value (0..1) via setChild("value", ...)
|
||||
};
|
||||
|
||||
class ExpressionStatement : public Statement {
|
||||
public:
|
||||
ExpressionStatement() { conceptType = "ExpressionStatement"; }
|
||||
// children: expression (1) via setChild("expression", ...)
|
||||
};
|
||||
64
editor/src/ast/Type.h
Normal file
64
editor/src/ast/Type.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
#include "ASTNode.h"
|
||||
|
||||
class Type : public ASTNode {
|
||||
public:
|
||||
Type() { conceptType = "Type"; }
|
||||
};
|
||||
|
||||
class PrimitiveType : public Type {
|
||||
public:
|
||||
std::string kind;
|
||||
PrimitiveType() { conceptType = "PrimitiveType"; }
|
||||
PrimitiveType(const std::string& id, const std::string& kind) : kind(kind) {
|
||||
this->id = id;
|
||||
this->conceptType = "PrimitiveType";
|
||||
}
|
||||
};
|
||||
|
||||
class ListType : public Type {
|
||||
public:
|
||||
ListType() { conceptType = "ListType"; }
|
||||
// children: elementType (1) via setChild("elementType", ...)
|
||||
};
|
||||
|
||||
class SetType : public Type {
|
||||
public:
|
||||
SetType() { conceptType = "SetType"; }
|
||||
// children: elementType (1) via setChild("elementType", ...)
|
||||
};
|
||||
|
||||
class MapType : public Type {
|
||||
public:
|
||||
MapType() { conceptType = "MapType"; }
|
||||
// children: keyType (1), valueType (1) via setChild
|
||||
};
|
||||
|
||||
class TupleType : public Type {
|
||||
public:
|
||||
TupleType() { conceptType = "TupleType"; }
|
||||
// children: elementTypes (0..n) via addChild("elementTypes", ...)
|
||||
};
|
||||
|
||||
class ArrayType : public Type {
|
||||
public:
|
||||
ArrayType() { conceptType = "ArrayType"; }
|
||||
// children: elementType (1) via setChild("elementType", ...)
|
||||
// children: size (1) via setChild("size", ...) [Expression]
|
||||
};
|
||||
|
||||
class OptionalType : public Type {
|
||||
public:
|
||||
OptionalType() { conceptType = "OptionalType"; }
|
||||
// children: innerType (1) via setChild("innerType", ...)
|
||||
};
|
||||
|
||||
class CustomType : public Type {
|
||||
public:
|
||||
std::string typeName;
|
||||
CustomType() { conceptType = "CustomType"; }
|
||||
CustomType(const std::string& id, const std::string& name) : typeName(name) {
|
||||
this->id = id;
|
||||
this->conceptType = "CustomType";
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user