Ejemplo n.º 1
0
 public static UnifiedContinue Create(
     UnifiedExpression value = null)
 {
     return(new UnifiedContinue {
         Value = value,
     });
 }
Ejemplo n.º 2
0
 public static UnifiedDelete Create(
     UnifiedExpression value = null)
 {
     return(new UnifiedDelete {
         Value = value,
     });
 }
Ejemplo n.º 3
0
 public static UnifiedStringConversion Create(
     UnifiedExpression value = null)
 {
     return(new UnifiedStringConversion {
         Value = value,
     });
 }
Ejemplo n.º 4
0
 public static UnifiedReturn Create(
     UnifiedExpression value = null)
 {
     return(new UnifiedReturn {
         Value = value,
     });
 }
Ejemplo n.º 5
0
 public static UnifiedType Create(
     UnifiedExpression basicExpression = null)
 {
     return new UnifiedBasicType {
             BasicTypeName = basicExpression,
     };
 }
Ejemplo n.º 6
0
 public static UnifiedPrintChevron Create(
     UnifiedExpression value = null)
 {
     return(new UnifiedPrintChevron {
         Value = value,
     });
 }
Ejemplo n.º 7
0
 public static UnifiedType Create(
     UnifiedExpression basicExpression = null)
 {
     return(new UnifiedBasicType {
         BasicTypeName = basicExpression,
     });
 }
Ejemplo n.º 8
0
 public static UnifiedEigenConstrain Create(
     UnifiedExpression eigenObject)
 {
     return(new UnifiedEigenConstrain {
         EigenObject = eigenObject,
     });
 }
Ejemplo n.º 9
0
 public static UnifiedBlock ToBlock(this UnifiedExpression singleton)
 {
     if (singleton == null)
     {
         return(UnifiedBlock.Create());
     }
     return(UnifiedBlock.Create(singleton));
 }
Ejemplo n.º 10
0
 public static UnifiedIf Create(
     UnifiedExpression condition, UnifiedBlock body)
 {
     return(new UnifiedIf {
         Body = body,
         Condition = condition,
     });
 }
Ejemplo n.º 11
0
 public static UnifiedOrderByKey Create(
     UnifiedExpression expression, bool ascending)
 {
     return(new UnifiedOrderByKey {
         Expression = expression,
         Ascending = ascending,
     });
 }
Ejemplo n.º 12
0
		public static UnifiedSetComprehension Create(
				UnifiedExpression element,
				UnifiedSet<UnifiedExpression> generator) {
			return new UnifiedSetComprehension {
					Element = element,
					Generator = generator,
			};
		}
Ejemplo n.º 13
0
 public static UnifiedCase Create(
     UnifiedExpression condtion = null,
     UnifiedBlock body          = null)
 {
     return(new UnifiedCase {
         Body = body,
         Condition = condtion,
     });
 }
Ejemplo n.º 14
0
 public static UnifiedSelectQuery Create(
     UnifiedExpression expression,
     UnifiedVariableIdentifier receiver = null)
 {
     return(new UnifiedSelectQuery {
         Expression = expression,
         Receiver = receiver,
     });
 }
Ejemplo n.º 15
0
 public static UnifiedKeyValue Create(
     UnifiedExpression key   = null,
     UnifiedExpression value = null)
 {
     return(new UnifiedKeyValue {
         Key = key,
         Value = value,
     });
 }
Ejemplo n.º 16
0
 public static UnifiedAnnotation Create(
     UnifiedExpression name = null,
     UnifiedSet <UnifiedArgument> arguments = null)
 {
     return(new UnifiedAnnotation {
         Name = name,
         Arguments = arguments,
     });
 }
Ejemplo n.º 17
0
 public static UnifiedLetQuery Create(
     UnifiedVariableIdentifier variable,
     UnifiedExpression expression)
 {
     return(new UnifiedLetQuery {
         Variable = variable,
         Expression = expression
     });
 }
Ejemplo n.º 18
0
 public static UnifiedAlias Create(
     UnifiedExpression value = null,
     UnifiedExpression alias = null)
 {
     return(new UnifiedAlias {
         Value = value,
         Alias = alias,
     });
 }
Ejemplo n.º 19
0
 public static UnifiedRange Create(
     UnifiedExpression min = null,
     UnifiedExpression max = null)
 {
     return(new UnifiedRange {
         Min = min,
         Max = max,
     });
 }
Ejemplo n.º 20
0
 public static UnifiedSynchronized Create(
     UnifiedExpression value = null,
     UnifiedBlock body       = null)
 {
     return(new UnifiedSynchronized {
         Value = value,
         Body = body,
     });
 }
Ejemplo n.º 21
0
 public static UnifiedCountedLoop Create(
     UnifiedExpression count,
     UnifiedBlock body)
 {
     return(new UnifiedCountedLoop {
         Count = count,
         Body = body
     });
 }
Ejemplo n.º 22
0
 public static UnifiedIndexer Create(
     UnifiedExpression current           = null,
     UnifiedSet <UnifiedArgument> create = null)
 {
     return(new UnifiedIndexer {
         Target = current,
         Arguments = create
     });
 }
Ejemplo n.º 23
0
 public static UnifiedSwitch Create(
     UnifiedExpression value        = null,
     UnifiedSet <UnifiedCase> cases = null)
 {
     return(new UnifiedSwitch {
         Value = value,
         Cases = cases,
     });
 }
Ejemplo n.º 24
0
 public static UnifiedUnaryExpression Create(
     UnifiedExpression operand,
     UnifiedUnaryOperator unaryOperator)
 {
     return(new UnifiedUnaryExpression {
         Operand = operand,
         Operator = unaryOperator,
     });
 }
Ejemplo n.º 25
0
 public static UnifiedCast Create(
     UnifiedType type,
     UnifiedExpression createExpression)
 {
     return(new UnifiedCast {
         Type = type,
         Expression = createExpression
     });
 }
Ejemplo n.º 26
0
 public static UnifiedArrayLiteral ToArrayLiteral(
     this UnifiedExpression singleton)
 {
     if (singleton == null)
     {
         return(UnifiedArrayLiteral.Create());
     }
     return(UnifiedArrayLiteral.Create(singleton));
 }
Ejemplo n.º 27
0
 public static UnifiedFix Create(
     UnifiedExpression value = null,
     UnifiedBlock body       = null)
 {
     return(new UnifiedFix {
         Value = value,
         Body = body,
     });
 }
Ejemplo n.º 28
0
 public static UnifiedProgram ToProgram(
     this UnifiedExpression singleton)
 {
     if (singleton == null)
     {
         return(UnifiedProgram.Create(UnifiedBlock.Create()));
     }
     return(UnifiedProgram.Create(singleton.ToBlock()));
 }
Ejemplo n.º 29
0
 public static UnifiedIterableLiteral ToLazyListLiteral(
     this UnifiedExpression singleton)
 {
     if (singleton == null)
     {
         return(UnifiedIterableLiteral.Create());
     }
     return(UnifiedIterableLiteral.Create(singleton));
 }
Ejemplo n.º 30
0
 public static UnifiedGroupByQuery Create(
     UnifiedExpression element, UnifiedExpression key,
     UnifiedVariableIdentifier receiver = null)
 {
     return(new UnifiedGroupByQuery {
         Element = element,
         Key = key,
         Receiver = receiver
     });
 }
Ejemplo n.º 31
0
 public static UnifiedAssert Create(
     UnifiedExpression value   = null,
     UnifiedExpression message = null
     )
 {
     return(new UnifiedAssert {
         Value = value,
         Message = message,
     });
 }
 public static UnifiedExpression CreateCallExpressionSuffix(
     UnifiedExpression prefix, XElement node)
 {
     Contract.Requires(node != null);
     Contract.Requires(node.Name() == "callExpressionSuffix");
     /*
      * callExpressionSuffix
      *		: arguments
      *		| indexSuffix
      *		| propertyReferenceSuffix
      */
     var first = node.NthElement(0);
     switch (first.Name()) {
     case "arguments":
         return UnifiedCall.Create(prefix, CreateArguments(first));
     case "indexSuffix":
         return CreateIndexSuffix(prefix, first);
     case "propertyReferenceSuffix":
         return CreatePropertyReferenceSuffix(prefix, first);
     default:
         throw new InvalidOperationException();
     }
 }
 public static UnifiedProperty CreatePropertyReferenceSuffix(
     UnifiedExpression prefix, XElement node)
 {
     Contract.Requires(node != null);
     Contract.Requires(node.Name() == "propertyReferenceSuffix");
     /*
      * propertyReferenceSuffix
      *		: '.' LT!* Identifier
      */
     return UnifiedProperty.Create(
             ".", prefix,
             UnifiedVariableIdentifier.Create(
                     node.Element("Identifier").Value));
 }
Ejemplo n.º 34
0
		public static UnifiedExpression CreateInnerCreator(
				UnifiedExpression prefix,
				XElement node) {
			Contract.Requires(node != null);
			Contract.Requires(node.Name() == "innerCreator");
			/*
			 * innerCreator  
			 * :   '.' 'new' (nonWildcardTypeArguments)? IDENTIFIER (typeArguments)? classCreatorRest 
			 */

			//コード例
			// X . new <T> Sample <E> (1,2){}

			var typeArguments = node.HasElement("typeArguments")
										? CreateTypeArguments(
												node.Element("typeArguments"))
										: null;
			var type = UnifiedType.Create(
					node.Element("IDENTIFIER").Value).WrapGeneric(typeArguments);
			var creatorRest =
					CreateClassCreatorRest(node.Element("classCreatorRest"));
			var typeParameters = node.HasElement("nonWildcardTypeArguments")
										? CreateNonWildcardTypeArguments(
												node.Element(
														"nonWildcardTypeArguments"))
										: null;
			var prop = UnifiedNew.Create(
					type, creatorRest.Item1, typeParameters, null,
					creatorRest.Item2);

			return UnifiedProperty.Create(".", prefix, prop);
		}
Ejemplo n.º 35
0
		public static UnifiedExpression CreateSelector(
				UnifiedExpression prefix, XElement node) {
			Contract.Requires(node != null);
			Contract.Requires(node.Name() == "selector");
			/*
			 *  selector  
				:   '.' IDENTIFIER arguments? //student.getName()
				|   '.' nonWildcardTypeArguments IDENTIFIER arguments // fix to support "obj.method().<Object>method2()"
				|   '.' 'this' //OuterClass.this
				|   '.' 'super' superSuffix //Outer.super()
				|   innerCreator
				|   '[' expression ']' 
			 */
			var secondElement = node.NthElementOrDefault(1);
			if (secondElement == null) {
				return CreateInnerCreator(prefix, node.FirstElement());
			}

			if (secondElement.Name() == "IDENTIFIER") {
				prefix = UnifiedProperty.Create(
						".", prefix,
						UnifiedVariableIdentifier.Create(secondElement.Value));
				var arguments = node.Element("arguments");
				if (arguments != null) {
					prefix = UnifiedCall.Create(
							prefix, CreateArguments(arguments));
				}
				return prefix;
			}
			if (secondElement.Name() == "nonWildcardTypeArguments") {
				prefix = UnifiedProperty.Create(
						".", prefix,
						UnifiedVariableIdentifier.Create(
								node.NthElement(2).Value));
				return UnifiedCall.Create(
						prefix,
						CreateArguments(node.NthElement(3)),
						CreateNonWildcardTypeArguments(secondElement));
			}
			if (secondElement.Value == "this") {
				return UnifiedProperty.Create(
						".", prefix, UnifiedVariableIdentifier.Create("this"));
			}
			if (secondElement.Value == "super") {
				var prop = UnifiedProperty.Create(
						".", prefix, UnifiedSuperIdentifier.Create("super"));
				return CreateSuperSuffix(prop, node.Element("superSuffix"));
			}
			if (secondElement.Name() == "expression") {
				return UnifiedIndexer.Create(
						prefix,
						UnifiedArgument.Create(
								CreateExpression(secondElement), null, null).
								ToSet());
			}

			throw new InvalidOperationException();
		}
Ejemplo n.º 36
0
		public static UnifiedExpression CreateIdentifierSuffix(
				UnifiedExpression prefixProp, XElement node) {
			Contract.Requires(node != null);
			Contract.Requires(node.Name() == "identifierSuffix");
			/*
			 * identifierSuffix
			 * :   ('[' ']')+ '.' 'class'	// java.lang.String[].class
			 * |   ('[' expression ']' )+	// strs[10]
			 * |   arguments				// func(1, 2)
			 * |   '.' 'class'				// java.lang.String.class
			 *			// this.<Integer>m(1), super.<Integer>m(1)
			 * |   '.' nonWildcardTypeArguments IDENTIFIER arguments
			 * |   '.' 'this'				// Outer.this
			 * |   '.' 'super' arguments	// new Outer().super();
			 * |   innerCreator				// new Outer().new <Integer> Inner<String>(1);
			 */

			var second = node.NthElementOrDefault(1);
			if (second == null) {
				// arguments				// func(1, 2)
				if (node.FirstElement().Name() == "arguments") {
					return UnifiedCall.Create(
							prefixProp, CreateArguments(node.FirstElement()));
				}
				// innerCreator				// new Outer().new <Integer> Inner<String>(1);
				return CreateInnerCreator(
						prefixProp, node.Element("innerCreator"));
			}
			// ('[' expression ']' )+	// strs[10]
			if (second.Name() == "expression") {
				return node.Elements("expression")
						.Select(CreateExpression)
						.Aggregate(
								prefixProp, (current, exp) =>
											UnifiedIndexer.Create(
													current,
													UnifiedSet<UnifiedArgument>.
															Create(
																	UnifiedArgument
																			.
																			Create
																			(
																					exp,
																					null,
																					null)))
						);
			}
			// '.' 'class'				// java.lang.String.class
			if (second.Value == "class") {
				return UnifiedTypeof.Create(UnifiedType.Create(prefixProp));
			}
			// ('[' ']')+ '.' 'class'	// java.lang.String[].class
			if (node.LastElement().Value == "class") {
				var d = node.ElementsByContent("[").Count();
				return
						UnifiedTypeof.Create(
								(UnifiedType.Create(prefixProp)).
										WrapArrayRepeatedly(d));
			}
			// '.' nonWildcardTypeArguments IDENTIFIER arguments
			if (second.Name() == "nonWildcardTypeArguments") {
				var prop = UnifiedProperty.Create(
						".", prefixProp,
						UnifiedVariableIdentifier.Create(
								node.NthElement(2).Value));
				return UnifiedCall.Create(
						prop, CreateArguments(node.Element("arguments")),
						CreateNonWildcardTypeArguments(
								node.Element("nonWildcardTypeArguments")));
			}
			// '.' 'this'				// Outer.this
			if (second.Value == "this") {
				return UnifiedProperty.Create(
						".", prefixProp, UnifiedThisIdentifier.Create("this"));
			}
			// '.' 'super' arguments	// new Outer().super();
			if (second.Value == "super") {
				var prop = UnifiedProperty.Create(
						".", prefixProp, UnifiedSuperIdentifier.Create("super"));
				return UnifiedCall.Create(
						prop, CreateArguments(node.Element("arguments")));
			}

			throw new InvalidOperationException();
		}
Ejemplo n.º 37
0
		public static UnifiedExpression CreateSuperSuffix(
				UnifiedExpression prefix,
				XElement node) {
			Contract.Requires(node != null);
			Contract.Requires(node.Name() == "superSuffix");
			/*
			 * superSuffix  
			 * :   arguments
			 * |   '.' (typeArguments)? IDENTIFIER (arguments)?
			 */
			if (node.FirstElement().Name == "arguments") {
				// super(arg1, arg2)
				return UnifiedCall.Create(
						prefix, CreateArguments(node.FirstElement()));
			}
			var typeArgumentsNode = node.Element("typeArguments");
			var typeArguments = typeArgumentsNode != null
										? CreateTypeArguments(typeArgumentsNode)
										: null;
			var argumentsNode = node.Element("arguments");
			var arguments = argumentsNode != null
									? CreateArguments(argumentsNode)
									: null;
			var property = UnifiedProperty.Create(
					".", prefix,
					UnifiedVariableIdentifier.Create(
							node.Element("IDENTIFIER").Value));
			if (arguments != null) {
				// super.<Integer>method(arg1)
				return UnifiedCall.Create(property, arguments, typeArguments);
			}
			// super.field1
			return property;
		}
        public static UnifiedIndexer CreateIndexSuffix(
            UnifiedExpression prefix, XElement node)
        {
            Contract.Requires(node != null);
            Contract.Requires(node.Name() == "indexSuffix");
            /*
             * indexSuffix
             *		: '[' LT!* expression LT!* ']'
             */

            return UnifiedIndexer.Create(
                    prefix,
                    UnifiedArgument.Create(
                            CreateExpression(node.Element("expression")), null,
                            null).
                            ToSet());
        }
 public static UnifiedExpression CreateTrailer(
     UnifiedExpression prefix, XElement node)
 {
     Contract.Requires(node != null);
     Contract.Requires(node.Name() == "trailer");
     /*
      * trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
      */
     switch (node.FirstElement().Value) {
     case "(":
         var arglistNode = node.Element("arglist");
         return arglistNode != null
                        ? UnifiedCall.Create(
                                prefix, CreateArglist(arglistNode))
                        : UnifiedCall.Create(
                                prefix,
                                UnifiedSet<UnifiedArgument>.Create());
     case "[":
         var second = node.NthElement(1);
         return UnifiedIndexer.Create(
                 prefix, CreateSubscriptlist(second));
     case ".":
         return UnifiedProperty.Create(
                 ".", prefix,
                 UnifiedVariableIdentifier.Create(
                         node.LastElement().Value));
     default:
         throw new IndexOutOfRangeException();
     }
 }