public static ParseResult CreateAggregationKindsFromTokenList(IEnumerable <Token> tokenList, Field.Kind fieldKind, out List <Aggregation.Kinds> aggregationTypes) { aggregationTypes = new List <Aggregation.Kinds>(); foreach (var token in tokenList) { Aggregation.Kinds aggrType = Aggregation.Kinds.Undefined; // check whether the aggregation type name exists if (!SemanticsAnalyzer.CreateAggregationTypeFromName(token.Text, ref aggrType)) { return(new ParseResult(ParseCode.SemanticsInvalidAggregationType, "Invalid aggregation type", token.ColumnPos)); } // check whether the aggregation type is supported by the field type if (!Field.IsAggregationAvailable(fieldKind, aggrType)) { return(new ParseResult(ParseCode.SemanticsInvalidAggregationType, "Invalid aggregation type for the requested field type", token.ColumnPos)); } aggregationTypes.Add(aggrType); } return(new ParseResult(ParseCode.Success)); }
public ParseResult CheckManifestFieldKindAndDefinition(string taskName, string eventName, string fieldName, Field.Kind expectedFieldKind, int columnPos) { // by-passing check in case semantic validadation against manifest files is disabled if (!this.manifestSemanticsCheckEnabled) { return(new ParseResult(ParseCode.Success)); } FieldDefinition fieldDef; if (!this.manifestLookup.TryGetField(taskName, eventName, fieldName, out fieldDef)) { return(new ParseResult( ParseCode.SemanticsUndefinedEventInManifest, string.Format("The specified field ({0}) is not available for the event defined by the pair (TaskName: {1}, EventName: {2})", fieldName, taskName, eventName), columnPos)); } // check whether field matches the expected type Field.Kind fieldKind = SemanticsAnalyzer.GetAggregationFieldKind(fieldDef); if (fieldKind != expectedFieldKind) { return(new ParseResult( ParseCode.SemanticsInvalidFieldKind, string.Format("The specified field ({0}) is of type ({1}) but was defined as a ({2}) type", fieldName, fieldKind.ToString(), expectedFieldKind.ToString()), columnPos)); } return(new ParseResult(ParseCode.Success)); }
// this method implements the D production for the grammar // D -> E F G private ParseResult D(Field.Kind fieldKind, ref TraceAggregationConfig telConfigEntry) { // try parsing E , i.e get the param names List <Token> fieldTokenList = new List <Token>(); ParseResult parseRes = this.E(fieldKind, telConfigEntry, ref fieldTokenList); if (parseRes.ParseCode != ParseCode.Success) { return(parseRes); } // get the field names List <Field> fieldParamList; parseRes = SemanticsAnalyzer.CreateFieldsFromTokenList(fieldTokenList, fieldKind, out fieldParamList); if (parseRes.ParseCode != ParseCode.Success) { return(parseRes); } // try parsing F , i.e get the aggregation kinds List <Token> aggregationParamList = new List <Token>(); parseRes = this.F(ref aggregationParamList); if (parseRes.ParseCode != ParseCode.Success) { return(parseRes); } // check if the aggregation kinds are valid List <Aggregation.Kinds> aggregationKindsList; parseRes = SemanticsAnalyzer.CreateAggregationKindsFromTokenList(aggregationParamList, fieldKind, out aggregationKindsList); if (parseRes.ParseCode != ParseCode.Success) { return(parseRes); } // sucessfully parsed the aggregation entry E F // setting the current aggregation entry telConfigEntry.AddAggregationEntries(fieldParamList, aggregationKindsList); // try to find a new aggregation G parseRes = this.G(ref telConfigEntry); if (parseRes.ParseCode != ParseCode.Success) { return(parseRes); } return(new ParseResult(ParseCode.Success)); }
// private constructor // the only public exposed method is the static method Parse private SyntaxAnalyzer(StreamReader fileStream, IEnumerable <string> manifestFilesPaths, LogErrorDelegate logErrorDelegate, bool verbose) { this.fileStream = fileStream; this.lexAnalyzer = null; this.semanticsAnalyzer = new SemanticsAnalyzer(manifestFilesPaths, manifestFilesPaths.Any(), logErrorDelegate, verbose); }