public override void LeaveArrayLiteralExpression(ArrayLiteralExpression node) { if (LookingFor(node)) { Found(node.Type); } }
public object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) { if (!arrayCreateExpression.ArrayInitializer.IsNull) { B.ArrayLiteralExpression ale = ConvertArrayLiteralExpression(arrayCreateExpression.ArrayInitializer); if (!arrayCreateExpression.IsImplicitlyTyped) { ale.Type = (B.ArrayTypeReference)ConvertTypeReference(arrayCreateExpression.CreateType); } return(ale); } string builtInName = (arrayCreateExpression.Arguments.Count > 1) ? "matrix" : "array"; B.MethodInvocationExpression mie = new B.MethodInvocationExpression(GetLexicalInfo(arrayCreateExpression), MakeReferenceExpression(builtInName)); TypeReference elementType = arrayCreateExpression.CreateType.Clone(); int[] newRank = new int[elementType.RankSpecifier.Length - 1]; for (int i = 0; i < newRank.Length; i++) { newRank[i] = elementType.RankSpecifier[i + 1]; } elementType.RankSpecifier = newRank; mie.Arguments.Add(MakeReferenceExpression(elementType)); ConvertExpressions(arrayCreateExpression.Arguments, mie.Arguments); return(mie); }
public static Expression typesOf(params Expression[] args) { var result = new ArrayLiteralExpression(); foreach (var arg in args) result.Items.Add(CodeBuilder.CreateTypeofExpression(arg.ExpressionType)); return result; }
protected virtual void AddDependency(ArrayLiteralExpression dependencies, BinaryExpression binaryExpression) { StringLiteralExpression dependency; //HACK: replace with proper AST method invocation if (binaryExpression.Left is StringLiteralExpression) { dependency = new StringLiteralExpression(string.Format("{0}|{1}", binaryExpression.Left.ToString().Trim('\''), binaryExpression.Right.ToString().Trim('\''))); } else if(binaryExpression.Left is BinaryExpression) { var left = (BinaryExpression) binaryExpression.Left; var package = left.Left.ToString().Trim('\''); var version = left.Right.ToString().Trim('\''); var dll = binaryExpression.Right.ToString().Trim('\''); dependency = new StringLiteralExpression(string.Format("{0}|{1}|{2}", package, dll, version)); } else throw new ArgumentOutOfRangeException(string.Format("Unknown Expression type {0} passed to RightShiftToMethodCompilerStep.AddDependency", binaryExpression.Left.GetType().Name)); dependencies.Items.Add(dependency); }
protected virtual void OnMethodInvocationExpression(ArrayLiteralExpression dependencies, MethodInvocationExpression expression) { foreach (var arg in expression.Arguments) { var binaryExpression = arg as BinaryExpression; if (binaryExpression == null || binaryExpression.Operator != BinaryOperatorType.ShiftRight) continue; AddDependency(dependencies, binaryExpression); } }
public override void LeaveArrayLiteralExpression(ArrayLiteralExpression node) { IType elementType = GetExpressionType(node).ElementType; for (int i = 0; i < node.Items.Count; ++i) { Expression converted = Convert(elementType, node.Items[i]); if (null != converted) { node.Items.ReplaceAt(i, converted); } } }
public static Expression data(params StringLiteralExpression[] expressions) { var arrayExpression = new ArrayLiteralExpression(); for (var i = 0; i < expressions.Length; i++) arrayExpression.Items.Add(expressions[i]); return new MethodInvocationExpression( new ReferenceExpression("SetData"), arrayExpression ); }
void ExpandComplexArraySlicing(SlicingExpression node) { if (node.Indices.Count > 1) { MethodInvocationExpression mie = null; var computeEnd = new ArrayLiteralExpression(); var collapse = new ArrayLiteralExpression(); var ranges = new ArrayLiteralExpression(); for (int i = 0; i < node.Indices.Count; i++) { ranges.Items.Add(node.Indices[i].Begin); if (node.Indices[i].End == null ) { var end = new BinaryExpression(BinaryOperatorType.Addition, node.Indices[i].Begin, new IntegerLiteralExpression(1)); ranges.Items.Add(end); BindExpressionType(end, GetExpressionType(node.Indices[i].Begin)); computeEnd.Items.Add(new BoolLiteralExpression(false)); collapse.Items.Add(new BoolLiteralExpression(true)); } else if (node.Indices[i].End == OmittedExpression.Default) { var end = new IntegerLiteralExpression(0); ranges.Items.Add(end); BindExpressionType(end, GetExpressionType(node.Indices[i].Begin)); computeEnd.Items.Add(new BoolLiteralExpression(true)); collapse.Items.Add(new BoolLiteralExpression(false)); } else { ranges.Items.Add(node.Indices[i].End); computeEnd.Items.Add(new BoolLiteralExpression(false)); collapse.Items.Add(new BoolLiteralExpression(false)); } } mie = CodeBuilder.CreateMethodInvocation(MethodCache.RuntimeServices_GetMultiDimensionalRange1, node.Target, ranges); mie.Arguments.Add(computeEnd); mie.Arguments.Add(collapse); BindExpressionType(ranges, TypeSystemServices.Map(typeof(int[]))); BindExpressionType(computeEnd, TypeSystemServices.Map(typeof(bool[]))); BindExpressionType(collapse, TypeSystemServices.Map(typeof(bool[]))); node.ParentNode.Replace(node, mie); } else { var slice = node.Indices[0]; var mie = IsNullOrOmitted(slice.End) ? CodeBuilder.CreateMethodInvocation(MethodCache.RuntimeServices_GetRange1, node.Target, slice.Begin) : CodeBuilder.CreateMethodInvocation(MethodCache.RuntimeServices_GetRange2, node.Target, slice.Begin, slice.End); node.ParentNode.Replace(node, mie); } }
public static bool IsCompoundAssignment(Expression expression, out ArrayLiteralExpression assignments) { assignments = expression as ArrayLiteralExpression; if (assignments != null) { BinaryExpression assignment; return (assignments.Items.Count > 1 && IsAssignment(assignments.Items[1], out assignment)); } return false; }
/// <summary> /// Perform the actual expansion of the macro /// </summary> /// <param name="macro">The macro.</param> /// <returns></returns> protected override Statement DoExpand(MacroStatement macro) { Block body = (Block)macro.GetAncestor(NodeType.Block); MacroStatement macroParent = (MacroStatement)macro.GetAncestor(NodeType.MacroStatement); if (macro.Body.Statements.Count < 1 && parent.Name=="join") { Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "Join " + name + " section must contain at least a single expression statement")); return null; } if (macro.Arguments.Count == 0 && parent.Name!="join") { Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "Join " + name + " section must contain at least one key column")); return null; } if (macro.Arguments.Count > 0) { ArrayLiteralExpression ale = new ArrayLiteralExpression(macro.LexicalInfo); ale.Type = new ArrayTypeReference(CodeBuilder.CreateTypeReference(typeof(string))); foreach (Expression argument in macro.Arguments) { ReferenceExpression expr = argument as ReferenceExpression; if (expr == null) { Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo,"Join " + name +" section arguments must be reference expressions. Example: " + name + " name, surname")); return null; } ale.Items.Add(new StringLiteralExpression(expr.Name)); } var keyExpr = new BinaryExpression(BinaryOperatorType.Assign, new ReferenceExpression(name+"KeyColumns"), ale); macroParent.Arguments.Add(keyExpr); } foreach (Statement statement in macro.Body.Statements) { ExpressionStatement exprStmt = statement as ExpressionStatement; if(exprStmt==null) { Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "Join " + name + " section can only contain expressions")); return null; } Expression expr = exprStmt.Expression; parent.Arguments.Add(new MethodInvocationExpression(new ReferenceExpression(name), expr)); } return null; }
private Method CreateGetColumnsToGroupByMethod(MacroStatement macro, IEnumerable<string> columns) { Method method = new Method("GetColumnsToGroupBy"); method.Modifiers = TypeMemberModifiers.Override; ArrayLiteralExpression ale = new ArrayLiteralExpression(macro.LexicalInfo); ale.Type = new ArrayTypeReference(CodeBuilder.CreateTypeReference(typeof(string))); foreach (string column in columns) { ale.Items.Add(new StringLiteralExpression(column)); } method.Body.Statements.Add(new ReturnStatement(ale)); return method; }
public override void OnArrayLiteralExpression(ArrayLiteralExpression node) { var need_expansion = false; if(node.Items.Count==2 && node.Items[0].ToCodeString().StartsWith("@_")){ need_expansion = true; } base.OnArrayLiteralExpression(node); if(need_expansion){ if(node.Items[0] is NullLiteralExpression){ node.ParentNode.Replace(node, node.Items[1].CloneNode()); } else{ node.ParentNode.Replace(node, node.Items[0].CloneNode()); } } }
public static Expression exclude(BlockExpression action) { var arrayExpression = new ArrayLiteralExpression(); foreach (Statement statement in action.Body.Statements) { var stringLiteral = new StringLiteralExpression( ((MethodInvocationExpression) (((ExpressionStatement) (statement)).Expression)).Arguments[0].ToString().Trim(new[]{'\''})); arrayExpression.Items.Add(stringLiteral); } return new MethodInvocationExpression( new ReferenceExpression("SetExcludeList"), arrayExpression ); }
public override void LeaveArrayLiteralExpression(ArrayLiteralExpression node) { IType expectedType = GetExpressionType(node).ElementType; if (!TypeSystemServices.IsPrimitiveNumber(expectedType)) return; foreach (Expression item in node.Items) { IType itemType = item.ExpressionType; if (item is LiteralExpression) { if (item.NodeType == NodeType.IntegerLiteralExpression) AssertLiteralInRange((IntegerLiteralExpression) item, expectedType); if (expectedType != itemType) BindExpressionType(item, expectedType); } } }
public override void OnBlockExpression(BlockExpression node) { var dependencies = new ArrayLiteralExpression(); foreach (Statement statement in node.Body.Statements) { var expressionStatement = (ExpressionStatement)statement; var expression = (MethodInvocationExpression)expressionStatement.Expression; OnMethodInvocationExpression(dependencies, expression); } if (dependencies.Items.Count == 0) return; var referenceExpression = new ReferenceExpression("AddDependencies"); var replacementMethod = new MethodInvocationExpression(referenceExpression, dependencies); ReplaceCurrentNode(replacementMethod); }
override public void OnArrayLiteralExpression(ArrayLiteralExpression node) { if (!_checked) return; base.OnArrayLiteralExpression(node); var expectedType = GetExpressionType(node).ElementType; if (!TypeSystemServices.IsPrimitiveNumber(expectedType)) return; foreach (var item in node.Items) { var integerLiteral = item as IntegerLiteralExpression; if (integerLiteral != null) { AssertLiteralInRange(integerLiteral, expectedType); continue; } } }
private void ReifyArrayLiteralExpression(IArrayType expectedArrayType, ArrayLiteralExpression arrayLiteralExpression) { arrayLiteralExpression.Type = (ArrayTypeReference)CodeBuilder.CreateTypeReference(expectedArrayType); }
private ArrayLiteralExpression GetArrayForIndices(SlicingExpression node) { ArrayLiteralExpression args = new ArrayLiteralExpression(); foreach (Slice index in node.Indices) { if (AstUtil.IsComplexSlice(index)) { throw CompilerErrorFactory.NotImplemented(index, "complex slice for duck"); } args.Items.Add(index.Begin); } BindExpressionType(args, TypeSystemServices.ObjectArrayType); return args; }
void BindComplexArraySlicing(SlicingExpression node) { if (AstUtil.IsLhsOfAssignment(node)) { return; } if (CheckComplexSlicingParameters(node)) { if (node.Indices.Count > 1) { IArrayType arrayType = (IArrayType)GetExpressionType(node.Target); MethodInvocationExpression mie = null; ArrayLiteralExpression collapse = new ArrayLiteralExpression(); ArrayLiteralExpression ranges = new ArrayLiteralExpression(); int collapseCount = 0; for (int i = 0; i < node.Indices.Count; i++) { ranges.Items.Add(node.Indices[i].Begin); if (node.Indices[i].End == null || node.Indices[i].End == OmittedExpression.Default) { BinaryExpression end = new BinaryExpression(BinaryOperatorType.Addition, node.Indices[i].Begin, new IntegerLiteralExpression(1)); ranges.Items.Add(end); BindExpressionType(end, GetExpressionType(node.Indices[i].Begin)); collapse.Items.Add(new BoolLiteralExpression(true)); collapseCount++; } else { ranges.Items.Add(node.Indices[i].End); collapse.Items.Add(new BoolLiteralExpression(false)); } } mie = CodeBuilder.CreateMethodInvocation(RuntimeServices_GetMultiDimensionalRange1, node.Target, ranges); mie.Arguments.Add(collapse); BindExpressionType(ranges, TypeSystemServices.Map(typeof(int[]))); BindExpressionType(collapse, TypeSystemServices.Map(typeof(bool[]))); BindExpressionType(mie, arrayType.ElementType.MakeArrayType(node.Indices.Count - collapseCount)); node.ParentNode.Replace(node, mie); } else { Slice slice = node.Indices[0]; if (CheckComplexSlicingParameters(slice)) { MethodInvocationExpression mie = null; if (null == slice.End || slice.End == OmittedExpression.Default) { mie = CodeBuilder.CreateMethodInvocation(RuntimeServices_GetRange1, node.Target, slice.Begin); } else { mie = CodeBuilder.CreateMethodInvocation(RuntimeServices_GetRange2, node.Target, slice.Begin, slice.End); } BindExpressionType(mie, GetExpressionType(node.Target)); node.ParentNode.Replace(node, mie); } } } }
private IArrayType InferArrayType(ArrayLiteralExpression node) { if (null != node.Type) return (IArrayType)node.Type.Entity; if (0 == node.Items.Count) return EmptyArrayType.Default; return GetMostGenericType(node.Items).MakeArrayType(1); }
public override void LeaveArrayLiteralExpression(ArrayLiteralExpression node) { TypeSystemServices.MapToConcreteExpressionTypes(node.Items); IArrayType type = InferArrayType(node); BindExpressionType(node, type); if (node.Type == null) node.Type = (ArrayTypeReference)CodeBuilder.CreateTypeReference(type); else CheckItems(type.ElementType, node.Items); }
protected Expression typed_array() //throws RecognitionException, TokenStreamException { Expression e; IToken t = null; e = null; ArrayLiteralExpression tle = null; TypeReference tr = null; Expression item = null; try { // for error handling t = LT(1); match(LPAREN); match(OF); tr=type_reference(); match(COLON); if (0==inputState.guessing) { e = tle = new ArrayLiteralExpression(ToLexicalInfo(t)); tle.Type = new ArrayTypeReference(tr.LexicalInfo, tr); } { switch ( LA(1) ) { case COMMA: { match(COMMA); break; } case ESEPARATOR: case CAST: case CHAR: case FALSE: case NOT: case NULL: case SELF: case SUPER: case THEN: case TRUE: case TYPEOF: case TRIPLE_QUOTED_STRING: case LPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case SPLICE_BEGIN: case DOT: case LBRACE: case QQ_BEGIN: case SUBTRACT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { { item=expression(); if (0==inputState.guessing) { tle.Items.Add(item); } { // ( ... )* for (;;) { if ((LA(1)==COMMA) && (tokenSet_5_.member(LA(2)))) { match(COMMA); item=expression(); if (0==inputState.guessing) { tle.Items.Add(item); } } else { goto _loop572_breakloop; } } _loop572_breakloop: ; } // ( ... )* { switch ( LA(1) ) { case COMMA: { match(COMMA); break; } case RPAREN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } } break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } match(RPAREN); } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "typed_array"); recover(ex,tokenSet_44_); } else { throw ex; } } return e; }
//throws RecognitionException, TokenStreamException protected Expression array_or_expression() { Expression e; IToken c = null; IToken t = null; e = null; ArrayLiteralExpression tle = null; try { // for error handling switch ( LA(1) ) { case COMMA: { { c = LT(1); match(COMMA); if (0==inputState.guessing) { e = new ArrayLiteralExpression(SourceLocationFactory.ToLexicalInfo(c)); } } break; } case ESEPARATOR: case CAST: case CHAR: case FALSE: case NOT: case NULL: case SELF: case SUPER: case TRUE: case TYPEOF: case ID: case TRIPLE_QUOTED_STRING: case LPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case LBRACK: case SUBTRACT: case SPLICE_BEGIN: case DOT: case MULTIPLY: case LBRACE: case QQ_BEGIN: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { { e=expression(); { switch ( LA(1) ) { case COMMA: { t = LT(1); match(COMMA); if (0==inputState.guessing) { tle = new ArrayLiteralExpression(e.LexicalInfo); tle.Items.Add(e); } { switch ( LA(1) ) { case ESEPARATOR: case CAST: case CHAR: case FALSE: case NOT: case NULL: case SELF: case SUPER: case TRUE: case TYPEOF: case ID: case TRIPLE_QUOTED_STRING: case LPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case LBRACK: case SUBTRACT: case SPLICE_BEGIN: case DOT: case MULTIPLY: case LBRACE: case QQ_BEGIN: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { e=expression(); if (0==inputState.guessing) { tle.Items.Add(e); } { // ( ... )* for (;;) { if ((LA(1)==COMMA) && (tokenSet_4_.member(LA(2)))) { match(COMMA); e=expression(); if (0==inputState.guessing) { tle.Items.Add(e); } } else { goto _loop375_breakloop; } } _loop375_breakloop: ; } // ( ... )* { switch ( LA(1) ) { case COMMA: { match(COMMA); break; } case EOF: case DEF: case DO: case IF: case UNLESS: case WHILE: case EOS: case NEWLINE: case RPAREN: case COLON: case RBRACE: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } break; } case EOF: case DEF: case DO: case IF: case UNLESS: case WHILE: case EOS: case NEWLINE: case RPAREN: case COLON: case RBRACE: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } if (0==inputState.guessing) { e = tle; } break; } case EOF: case DEF: case DO: case IF: case UNLESS: case WHILE: case EOS: case NEWLINE: case RPAREN: case COLON: case RBRACE: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } } break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_73_); } else { throw ex; } } return e; }
B.ArrayLiteralExpression ConvertArrayLiteralExpression(CollectionInitializerExpression aie) { B.ArrayLiteralExpression dims = new B.ArrayLiteralExpression(GetLexicalInfo(aie)); ConvertExpressions(aie.CreateExpressions, dims.Items); return(dims); }
public override void OnArrayLiteralExpression(ArrayLiteralExpression node) { IArrayType type = (IArrayType)node.ExpressionType; EmitArray(type.ElementType, node.Items); PushType(type); }
public static Expression export(BlockExpression exportUrls) { var exportList = new ArrayLiteralExpression(); foreach (var statement in exportUrls.Body.Statements) { var expression = (MethodInvocationExpression)((ExpressionStatement)statement).Expression; var sourceType = expression.Target.ToString(); var remoteUrl = ((StringLiteralExpression)expression.Arguments[0]).Value; MethodInvocationExpression export; if (expression.Arguments.Count == 1) { export = new MethodInvocationExpression(new ReferenceExpression("ExportData"), new StringLiteralExpression(remoteUrl), new StringLiteralExpression(sourceType)); exportList.Items.Add(export); continue; } var to = ((StringLiteralExpression)((MethodInvocationExpression)expression.Arguments[1]).Arguments[0]).Value; export = new MethodInvocationExpression(new ReferenceExpression("ExportData"), new StringLiteralExpression(remoteUrl), new StringLiteralExpression(sourceType), new StringLiteralExpression(to)); exportList.Items.Add(export); } return new MethodInvocationExpression(new ReferenceExpression("ParseExportList"), exportList); }
protected Expression array_or_expression() //throws RecognitionException, TokenStreamException { Expression e; IToken c = null; IToken t = null; e = null; ArrayLiteralExpression tle = null; try { // for error handling switch ( LA(1) ) { case COMMA: { { c = LT(1); match(COMMA); if (0==inputState.guessing) { e = new ArrayLiteralExpression(ToLexicalInfo(c)); } } break; } case ESEPARATOR: case CAST: case CHAR: case FALSE: case NOT: case NULL: case SELF: case SUPER: case THEN: case TRUE: case TYPEOF: case TRIPLE_QUOTED_STRING: case LPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case SPLICE_BEGIN: case DOT: case LBRACE: case QQ_BEGIN: case SUBTRACT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { { e=expression(); { switch ( LA(1) ) { case COMMA: { t = LT(1); match(COMMA); if (0==inputState.guessing) { tle = new ArrayLiteralExpression(e.LexicalInfo); tle.Items.Add(e); } { if ((tokenSet_5_.member(LA(1))) && (tokenSet_77_.member(LA(2)))) { e=expression(); if (0==inputState.guessing) { tle.Items.Add(e); } { // ( ... )* for (;;) { if ((LA(1)==COMMA) && (tokenSet_5_.member(LA(2)))) { match(COMMA); e=expression(); if (0==inputState.guessing) { tle.Items.Add(e); } } else { goto _loop430_breakloop; } } _loop430_breakloop: ; } // ( ... )* { switch ( LA(1) ) { case COMMA: { match(COMMA); break; } case EOF: case DEDENT: case ESEPARATOR: case EOL: case ASSEMBLY_ATTRIBUTE_BEGIN: case MODULE_ATTRIBUTE_BEGIN: case ABSTRACT: case BREAK: case CONTINUE: case CALLABLE: case CAST: case CHAR: case CLASS: case CONSTRUCTOR: case DEF: case DESTRUCTOR: case DO: case ENUM: case EVENT: case FINAL: case FOR: case FALSE: case GOTO: case INTERFACE: case INTERNAL: case IF: case NEW: case NULL: case OVERRIDE: case PARTIAL: case PUBLIC: case PROTECTED: case PRIVATE: case RAISE: case RETURN: case SELF: case SUPER: case STATIC: case STRUCT: case THEN: case TRY: case TRANSIENT: case TRUE: case TYPEOF: case UNLESS: case VIRTUAL: case WHILE: case YIELD: case TRIPLE_QUOTED_STRING: case EOS: case LPAREN: case RPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case SPLICE_BEGIN: case DOT: case COLON: case LBRACE: case RBRACE: case QQ_BEGIN: case QQ_END: case SUBTRACT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } } else if ((tokenSet_78_.member(LA(1))) && (tokenSet_79_.member(LA(2)))) { } else { throw new NoViableAltException(LT(1), getFilename()); } } if (0==inputState.guessing) { e = tle; } break; } case EOF: case DEDENT: case ESEPARATOR: case EOL: case ASSEMBLY_ATTRIBUTE_BEGIN: case MODULE_ATTRIBUTE_BEGIN: case ABSTRACT: case BREAK: case CONTINUE: case CALLABLE: case CAST: case CHAR: case CLASS: case CONSTRUCTOR: case DEF: case DESTRUCTOR: case DO: case ENUM: case EVENT: case FINAL: case FOR: case FALSE: case GOTO: case INTERFACE: case INTERNAL: case IF: case NEW: case NULL: case OVERRIDE: case PARTIAL: case PUBLIC: case PROTECTED: case PRIVATE: case RAISE: case RETURN: case SELF: case SUPER: case STATIC: case STRUCT: case THEN: case TRY: case TRANSIENT: case TRUE: case TYPEOF: case UNLESS: case VIRTUAL: case WHILE: case YIELD: case TRIPLE_QUOTED_STRING: case EOS: case LPAREN: case RPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case SPLICE_BEGIN: case DOT: case COLON: case LBRACE: case RBRACE: case QQ_BEGIN: case QQ_END: case SUBTRACT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } } break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "array_or_expression"); recover(ex,tokenSet_78_); } else { throw ex; } } return e; }
public static Expression include(BlockExpression includes) { var includeList = new ArrayLiteralExpression(); foreach (var statement in includes.Body.Statements) { var expression = (MethodInvocationExpression)((ExpressionStatement)statement).Expression; var repositoryName = ((ReferenceExpression)expression.Arguments[0]).Name; var includePath = ((StringLiteralExpression)((MethodInvocationExpression)expression.Arguments[1]).Arguments[0]).Value; var exportPath = ((StringLiteralExpression)((MethodInvocationExpression)expression.Arguments[2]).Arguments[0]).Value; ; var repositoryInclude = new MethodInvocationExpression(new ReferenceExpression("RepositoryElement"), new StringLiteralExpression(repositoryName), new StringLiteralExpression(includePath), new StringLiteralExpression(exportPath)); includeList.Items.Add(repositoryInclude); } return new MethodInvocationExpression(new ReferenceExpression("ParseIncludes"), includeList); }
void BindAssignmentToComplexSliceArray(BinaryExpression node) { var slice = (SlicingExpression)node.Left; var ale = new ArrayLiteralExpression(); var collapse = new ArrayLiteralExpression(); var compute_end = new ArrayLiteralExpression(); for (int i = 0; i < slice.Indices.Count; i++) { ale.Items.Add(slice.Indices[i].Begin); if (slice.Indices[i].End == null) { ale.Items.Add(new IntegerLiteralExpression(1 + (int)((IntegerLiteralExpression)slice.Indices[i].Begin).Value)); collapse.Items.Add(new BoolLiteralExpression(true)); compute_end.Items.Add(new BoolLiteralExpression(false)); } else if (slice.Indices[i].End == OmittedExpression.Default) { ale.Items.Add(new IntegerLiteralExpression(0)); collapse.Items.Add(new BoolLiteralExpression(false)); compute_end.Items.Add(new BoolLiteralExpression(true)); } else { ale.Items.Add(slice.Indices[i].End); collapse.Items.Add(new BoolLiteralExpression(false)); compute_end.Items.Add(new BoolLiteralExpression(false)); } } var mie = CodeBuilder.CreateMethodInvocation( MethodCache.RuntimeServices_SetMultiDimensionalRange1, node.Right, slice.Target, ale); mie.Arguments.Add(compute_end); mie.Arguments.Add(collapse); BindExpressionType(mie, TypeSystemServices.VoidType); BindExpressionType(ale, TypeSystemServices.Map(typeof(int[]))); BindExpressionType(compute_end, TypeSystemServices.Map(typeof(bool[]))); BindExpressionType(collapse, TypeSystemServices.Map(typeof(bool[]))); node.ParentNode.Replace(node, mie); }
public static Expression prebuild(BlockExpression commands) { var cmdList = new ArrayLiteralExpression(); foreach (Statement statement in commands.Body.Statements) { var expression = (MethodInvocationExpression)((ExpressionStatement)statement).Expression; cmdList.Items.Add(new StringLiteralExpression(expression.Arguments[0].ToString().Trim(new char[] { '\'' }))); } return new MethodInvocationExpression(new ReferenceExpression("ParseCommands"), cmdList); }
public ArrayLiteralExpression CreateArray(IType arrayType, ExpressionCollection items) { if (!arrayType.IsArray) throw new ArgumentException(string.Format("'{0}' is not an array type!", arrayType), "arrayType"); var array = new ArrayLiteralExpression(); array.ExpressionType = arrayType; array.Items.AddRange(items); TypeSystemServices.MapToConcreteExpressionTypes(array.Items); return array; }
public static Expression tasks(params ReferenceExpression[] expressions) { var arrayExpression = new ArrayLiteralExpression(); for (var i = 0; i < expressions.Length; i++) arrayExpression.Items.Add(new StringLiteralExpression(expressions[i].Name)); return new MethodInvocationExpression( new ReferenceExpression("SetBuildTargets"), arrayExpression ); }