/// <summary> /// Parse a <see cref="ConversionOperatorDecl"/>. /// </summary> public ConversionOperatorDecl(Parser parser, CodeObject parent, ParseFlags flags) : base(parser, parent, false, flags) { parser.NextToken(); // Move past 'operator' _modifiers = ModifiersHelpers.Parse(parser, this); // Parse any modifiers in reverse from the Unused list _name = GetInternalName(_modifiers); // Get the name ParseUnusedAnnotations(parser, this, false); // Parse attributes and/or doc comments from the Unused list SetField(ref _returnType, Expression.Parse(parser, this, true, Expression.ParseTokenStartGroup), false); ParseParameters(parser); ParseTerminatorOrBody(parser, flags); }
/// <summary> /// Parse a <see cref="LocalDecl"/>. /// </summary> public LocalDecl(Parser parser, CodeObject parent, bool standAlone, bool allowInit, bool hasType, bool isMulti) : base(parser, parent) { if (isMulti) { ParseName(parser, parent); // Parse the name if (allowInit) { ParseInitialization(parser, parent); // Parse the initialization (if any) } } else { if (standAlone) { // Parse the name from the Unused list Token token = parser.RemoveLastUnusedToken(); _name = token.NonVerbatimText; MoveLocationAndComment(token); ParseUnusedType(parser, ref _type); // Parse the type from the Unused list // Parse any modifiers in reverse from the Unused list. // NOTE: Only 'const' is valid for LocalDecls. _modifiers = ModifiersHelpers.Parse(parser, this); if (allowInit) { ParseInitialization(parser, parent); // Parse the initialization (if any) } } else { if (hasType) { ParseType(parser); // Parse the type } ParseName(parser, parent); // Parse the name if (allowInit) { ParseInitialization(parser, parent); // Parse the initialization (if any) } } if (standAlone && parser.TokenText != Expression.ParseTokenSeparator) { ParseTerminator(parser); } } }
protected FieldDecl(Parser parser, CodeObject parent, bool isMulti) : base(parser, parent) { // Ignore for derived types (FixedSizeBufferDecl) if (GetType() != typeof(FieldDecl)) { return; } if (isMulti) { // Parse the name _name = parser.GetIdentifierText(); MoveLocationAndComment(parser.LastToken); ParseInitialization(parser, parent); // Parse the initialization (if any) } else { // Parse the name from the Unused list Token token = parser.RemoveLastUnusedToken(); _name = token.NonVerbatimText; MoveLocationAndComment(token); ParseUnusedType(parser, ref _type); // Parse the type from the Unused list _modifiers = ModifiersHelpers.Parse(parser, this); // Parse any modifiers in reverse from the Unused list ParseUnusedAnnotations(parser, this, false); // Parse attributes and/or doc comments from the Unused list ParseInitialization(parser, parent); // Parse the initialization (if any) if (parser.TokenText != Expression.ParseTokenSeparator) { ParseTerminator(parser); } // Check for compiler directives, storing them as postfix annotations on the parent Block.ParseCompilerDirectives(parser, this, AnnotationFlags.IsPostfix, false); // Force field decls to always start on a new line IsFirstOnLine = true; } }
protected void ParseModifiersAndAnnotations(Parser parser) { _modifiers = ModifiersHelpers.Parse(parser, this); // Parse any modifiers in reverse from the Unused list ParseUnusedAnnotations(parser, this, false); // Parse attributes and/or doc comments from the Unused list }