public void Visit(ArrayLiteralNode arrayLiteral) { foreach (var element in arrayLiteral.Elements) { element.Parent = arrayLiteral; element.Accept(this); } }
public override object VisitArrayLiteral(ArrayLiteralNode node) { object[] result = new object[node.Elements.Count]; for (int i = 0; i < result.Length; i++) { result[i] = node.Elements[i].Accept(this); } return(result); }
/// <summary> /// Visits the Array Literal node. /// </summary> /// <param name="node">The node to visit.</param> public virtual TResult VisitArrayLiteral(ArrayLiteralNode node) { foreach (LiteralNode item in node.Elements) { item.Accept(this); } return(default(TResult)); // The default naive implementation }
private object EvaluateNode(ArrayLiteralNode expression, Context context) { var result = new List <object>(); foreach (var exp in expression.values) { result.Add(EvaluateNode(exp, context)); } return(result); }
/// <summary> /// Visits the Array Literal node. /// </summary> /// <param name="node">The node to visit.</param> public override bool VisitArrayLiteral(ArrayLiteralNode node) { if (node.Parent == null) { return(false); } if ((node.ArrayToken == null) || (node.LeftParenthesis == null) || (node.RightParenthesis == null)) { return(false); } foreach (LiteralNode item in node.Elements) { if (!item.Accept(this)) { return(false); } } return(true); }
/// <summary> /// Visits the Array Literal node. /// </summary> /// <param name="node">The node to visit.</param> public virtual TResult VisitArrayLiteral(ArrayLiteralNode node) { throw new NotImplementedException(); }
public override Expression VisitArrayLiteral(ArrayLiteralNode node) { return(this.Context.Compiler.LiteralEncodingStrategy.Array(this, node.Elements)); }
protected virtual ArrayLiteralNode ParseArrayLiteral(ILiteralNodeParent parent, SpecialCharacterToken arrayToken) { // PARSE: <array literal> ::= '#(' <array element>* ')' // <array element> ::= <literal> | identifier Token token = this.GetNextTokenxx(Preference.Default); if (!Parser.IsOpeningParenthesis(token)) { this.ReportParserError(parent, SemanticErrors.MissingLiteralArrayOpeningParenthesis, token); // The hash token is thrown away and lost :-/ ... only the current token is passed on. this.ResidueToken = token; return(null); } List <LiteralNode> elements = new List <LiteralNode>(); ArrayLiteralNode result = new ArrayLiteralNode(parent, arrayToken, (SpecialCharacterToken)token); // Process tokens inside the array ... while (true) { // ... get next token in the array ... token = this.GetNextTokenxx(Preference.NegativeSign | Preference.UnquotedSelector); // Is this closing parenthesis? if (Parser.IsClosingParenthesis(token)) { // Closing parenthesis ... done with the array, return litral array node. result.SetContents(elements, (SpecialCharacterToken)token); this.ResidueToken = null; return(result); } if (token is EofToken) { // Unfinished source code ... return result.SetContents(elements, null); this.ReportParserError(parent, SemanticErrors.MissingLiteralArrayClosingParenthesis, token); this.ResidueToken = token; return(result); } // PARSE: <array element> ::= <literal> | identifier if (token is ILiteralArrayIdentifierToken) { // identifier ... special case only inside arrays. elements.Add(new IdentifierLiteralNode(result, (ILiteralArrayIdentifierToken)token)); } else { // ... it's not identifier, so it must be an literal LiteralNode element = this.ParseLiteral(result, token); if (element == null) { // Report error in source code ... here, it must be a literal this.ReportParserError(result, SemanticErrors.UnrecognizedLiteral, token); result.SetContents(elements, null); return(result); } else { // ... add the child element to the array elements. elements.Add(element); } } } }
internal override void Visit(ArrayLiteralNode node) { }