private IDynamicProperty Parse(IParsingSourceStream sourceStream, ref string line, ref int indentation, ref bool useTab) { while (string.IsNullOrEmpty(line) && !sourceStream.EndOfStream) { sourceStream.ReadLine(); line = sourceStream.Line; } IDeclarationSource PropertySource; string ResultValue; ParserDomain.ParseStringPair(sourceStream, ':', out PropertySource, out ResultValue); if (string.IsNullOrEmpty(PropertySource.Name)) { throw new ParsingException(209, sourceStream, "Missing dynamic property name."); } string CSharpName = ParserDomain.ToCSharpName(PropertySource.Source, PropertySource.Name); DynamicOperationResults Result; if (ResultValue == "boolean") { Result = DynamicOperationResults.Boolean; } else { throw new ParsingException(210, sourceStream, $"Invalid dynamic property type '{ResultValue}'."); } Stack <IDynamicOperation> OperationStack = new Stack <IDynamicOperation>(); IDynamicOperation RootOperation = null; for (;;) { sourceStream.ReadLine(); line = sourceStream.Line; if (string.IsNullOrEmpty(line)) { break; } if (indentation < 0) { MeasureIndentation(sourceStream, ref indentation, ref useTab); } int Depth = GetIndentation(sourceStream, indentation, useTab); string Text = line.Trim(); if (Text == "NOT") { OperationStack.Push(new UnaryOperation(DynamicOperationTypes.NOT)); } else if (Text == "OR") { OperationStack.Push(new BinaryOperation(DynamicOperationTypes.OR)); } else if (Text == "AND") { OperationStack.Push(new BinaryOperation(DynamicOperationTypes.AND)); } else if (Text == "EQUALS") { OperationStack.Push(new BinaryOperation(DynamicOperationTypes.EQUALS)); } else if (Text == "GREATER THAN") { OperationStack.Push(new BinaryOperation(DynamicOperationTypes.GREATER_THAN)); } else if (Text == "IS EMPTY") { OperationStack.Push(new UnaryOperation(DynamicOperationTypes.IS_EMPTY)); } else { IDynamicOperation Operand; int IntegerConstantValue; if (int.TryParse(Text, out IntegerConstantValue)) { Operand = new IntegerConstantOperation(IntegerConstantValue); } else { IDeclarationSource ObjectSource; IDeclarationSource MemberSource; IDeclarationSource KeySource; if (!ParserDomain.TryParseObjectProperty(sourceStream, Text, out ObjectSource, out MemberSource, out KeySource)) { throw new ParsingException(211, sourceStream, $"Expected operator, integer constant or object property."); } ComponentInfo Info = new ComponentInfo(); Info.ObjectSource = ObjectSource; Info.MemberSource = MemberSource; Info.KeySource = KeySource; ComponentProperty ValueProperty = new ComponentProperty(Info); Operand = new PropertyValueOperation(ValueProperty); } while (OperationStack.Count > 0) { IDynamicOperation CurrentOperation = OperationStack.Peek(); if ((CurrentOperation is IUnaryOperation AsUnary) && (AsUnary.Operand == null)) { AsUnary.SetOperand(Operand); RootOperation = OperationStack.Pop(); Operand = RootOperation; }
private IComponentEvent ParseQueryEvent(IParsingSourceStream sourceStream, string line) { ComponentInfo Info = ComponentInfo.Parse(sourceStream, line); return(new ComponentEvent(Info)); }
private IComponent ParseComponent(IParsingSourceStream sourceStream) { IDeclarationSource NameSource; string ComponentInfo; ParserDomain.ParseStringPair(sourceStream, ':', out NameSource, out ComponentInfo); string[] SplittedInfo = ComponentInfo.Split(','); if (SplittedInfo.Length < 1) { throw new ParsingException(25, sourceStream, "Component type expected."); } string ComponentTypeName = SplittedInfo[0].Trim(); if (string.IsNullOrEmpty(ComponentTypeName)) { throw new ParsingException(25, sourceStream, "Component type expected."); } List <ComponentInfo> InfoList = new List <ComponentInfo>(); for (int i = 1; i < SplittedInfo.Length; i++) { InfoList.Add(Parser.ComponentInfo.Parse(sourceStream, SplittedInfo[i])); } if (ComponentTypeName == "area") { return(ParseComponentArea(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "button") { return(ParseComponentButton(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "checkbox") { return(ParseComponentCheckBox(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "text") { return(ParseComponentText(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "html") { return(ParseComponentHtml(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "image") { return(ParseComponentImage(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "edit") { return(ParseComponentEdit(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "password edit") { return(ParseComponentPasswordEdit(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "popup") { return(ParseComponentPopup(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "selector") { return(ParseComponentSelector(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "index") { return(ParseComponentIndex(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "container") { return(ParseComponentContainer(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "container list") { return(ParseComponentContainerList(NameSource, sourceStream, InfoList)); } else if (ComponentTypeName == "radio button") { return(ParseComponentRadioButton(NameSource, sourceStream, InfoList)); } else { throw new ParsingException(26, sourceStream, $"Unknown component type '{ComponentTypeName}'."); } }