private void CompileStringValueType(GrammarSymbol decl) { var result = new DataModelLeafTypeBuilder(decl); var member = new DataModelMember("STRING", "StringValue", "stringValue", null, "stringValue", null, null, null, null, null, 0, false); result.Members.Add(member); result.ToStringEntries.Add(new ToStringEntry(member)); this.AddCompiledType(result); }
private void CompileEnumValueType(GrammarSymbol decl, Token token) { var result = new DataModelLeafTypeBuilder(decl); var declaredValues = new List <string>(); declaredValues.Add(token.GetText()); result.G4DeclaredValues = declaredValues; this.AddCompiledType(result); }
private void CompileEnumValueType(GrammarSymbol decl, ImmutableArray <GrammarSymbol> enumMembers) { var result = new DataModelLeafTypeBuilder(decl); var declaredValues = new List <string>(); foreach (GrammarSymbol symbol in enumMembers) { declaredValues.Add(symbol.FirstToken.GetText()); } result.G4DeclaredValues = declaredValues; this.AddCompiledType(result); }
private void AddCompiledType(DataModelLeafTypeBuilder builder) { _compiledTypes.Add(builder.G4DeclaredName, builder); }
private void CompileStandardType(GrammarSymbol decl, ImmutableArray <GrammarSymbol> groupList) { var result = new DataModelLeafTypeBuilder(decl); int idx = 0; while (idx < groupList.Length) { List <string> staticStrings = GetStringValuesAfter(groupList, idx); foreach (string staticString in staticStrings) { result.ToStringEntries.Add(new ToStringEntry(staticString, null)); } idx += staticStrings.Count; if (idx >= groupList.Length) { break; } GrammarSymbol currentSymbol = groupList[idx]; GrammarSymbol memberDeclSymbol = GetDeclaringIdentifierSymbol(currentSymbol, result.G4DeclaredName); GrammarSymbol lookAheadSymbol = GetSymbolOrEmpty(groupList, idx + 1); // Check for patterns: if (MatchesDelimitedCollectionPattern(currentSymbol, memberDeclSymbol, lookAheadSymbol)) { // x ('delimiter' x)* string delimeter = lookAheadSymbol[0][0].GetLogicalText(); result.AddMember(memberDeclSymbol, 1, currentSymbol.Kind == SymbolKind.Identifier, delimeter); idx += 2; continue; } int rank; bool required; switch (currentSymbol.Kind) { case SymbolKind.Identifier: // x rank = 0; required = true; break; case SymbolKind.ZeroOrOneQuantifier: // x? rank = 0; required = false; break; case SymbolKind.ZeroOrMoreQuantifier: // x* rank = 1; required = false; break; case SymbolKind.OneOrMoreQuantifier: // x+ rank = 1; required = true; break; default: throw new G4ParseFailureException(currentSymbol.GetLocation(), Strings.UnrecognizedDataModel, result.G4DeclaredName); } ++idx; result.AddMember(memberDeclSymbol, rank, required); } this.AddCompiledType(result); }