public CallExpression(Cursor cursor, Expression callee, Expression[] arguments) : base(NodeKind.CallExpression, cursor) { _callee = callee; _callee.Above = this; _arguments = arguments; foreach (Expression argument in _arguments) argument.Above = this; }
public CallStatement(Cursor cursor, Expression expression) : base(NodeKind.CallStatement, cursor) { _expression = expression; _expression.Above = this; }
public PrefixReference(Cursor cursor, Expression prefix, string symbol) : base(NodeKind.PrefixReference, cursor, symbol) { _prefix = prefix; _prefix.Above = this; }
public ReturnExpressionStatement(Cursor cursor, Expression expression) : base(NodeKind.ReturnExpressionStatement, cursor) { _expression = expression; _expression.Above = this; }
public override Node Clone() { Expression[] arguments = new Expression[_arguments.Length]; for (int i = 0; i < arguments.Length; i++) arguments[i] = (Expression) _arguments[i].Clone(); return new CallExpression(this.Cursor, (Expression) _callee.Clone(), arguments); }
/** Parses a \c class definition, which may include nested classes, methods, and so on. */ private ClassStatement ParseClassOrRecordStatement(SymbolKind kind) { Token start = _matcher.Match((kind == SymbolKind.Class) ? TokenKind.Keyword_Class : TokenKind.Keyword_Record); _matcher.Match(TokenKind.Space); SymbolDefinition name = ParseSymbolDefinition(kind); _stack.Push(name.Symbol); // Parse: SPACE "is" SPACE base { "," SPACE interface }. Expression[] bases; if (kind == SymbolKind.Record) { // Records currently don't have a base class. bases = new Expression[0]; } else if (_matcher.This.Kind != TokenKind.Colon) { // Parse list of base class (first) and/or interfaces. _matcher.Match(TokenKind.Space); _matcher.Match(TokenKind.Keyword_Is); _matcher.Match(TokenKind.Space); // Parse list of base classes and/or interfaces. var parents = new List<Expression>(); for (;;) { Expression expression = ParseExpression(); parents.Add(expression); if (_matcher.This.Kind == TokenKind.Colon) break; _matcher.Match(TokenKind.Comma); _matcher.Match(TokenKind.Space); } bases = parents.ToArray(); } else { // If no base class and no interfaces, inherit the !Braceless.Object class (accesible as "Object"). bases = new Reference[1] { new GlobalReference(_matcher.This.Cursor, "Object") }; } _matcher.Match(TokenKind.Colon); _matcher.Match(TokenKind.EndOfLine); // parse: INDENT +Definition DEDENT _matcher.Match(TokenKind.Indent); Statement[] statements = ParseClassOrRecordInnerStatements(); _matcher.Match(TokenKind.Dedent); _stack.Pop(); return new ClassStatement(start.Cursor, name, bases, statements); }
private NewExpression ParseNewExpression() { Token start = _matcher.Match(TokenKind.Keyword_New); _matcher.Match(TokenKind.Space); Type type = ParseType(); Expression[] arguments; if (_matcher.This.Kind == TokenKind.ParenthesisBegin) arguments = ParseArguments(); else arguments = new Expression[0]; return new NewExpression(start.Cursor, type, arguments); }