Example #1
0
 /// <summary>
 /// Parses the #elif-#else-#endif part of an #if-#elif-#else-#endif construct, starting at the character following "elif". 
 /// Updates the last IfDirective instance added to this.preprocessorInformation with an additional ElifPart.
 /// Leaves this.fragmentIndex pointing to the start of the first line after the #endif directive.
 /// Returns all source locations that are to be included in the preprocessor output. (No locations are returned if the include parameter is false.)
 /// </summary>
 /// <param name="include">True if the definition is part of an included block. If false, the directive is parsed but ignored. (No locations are returned.)</param>
 private IEnumerable<ISourceLocation> ParseElif(bool include) {
   Expression condition = this.ParseExpression();
   ElifPart elif = new ElifPart(condition, this.GetSourceLocation(this.startOfCurrentLine, this.fragmentIndex-this.startOfCurrentLine));
   this.preprocessorInformation.AddElif(elif);
   this.SkipPastBlanksCommentAndNewLine();
   bool allowElseToInclude = include;
   if (include) {
     include = condition.IsDefined(this.preprocessorDefinedSymbols);
     if (include) allowElseToInclude = false;
   }
   foreach (ISourceLocation includedSourceFragment in this.ParseSection(true, true, false, include, allowElseToInclude))
     yield return includedSourceFragment;
 }
Example #2
0
 internal void AddElif(ElifPart elif) {
   for (int i = this.directives.Count; i > 0; i--) {
     IfDirective/*?*/ ifDirective = this.directives[i-1] as IfDirective;
     if (ifDirective == null) continue;
     ifDirective.elifs.Add(elif);
     return;
   }
 }