public void ParseBlockReadsToAfterOffKeywordIfOptionExplicitBlock() { ParseBlockTest("Option Explicit Off Foo Bar Baz", new DirectiveBlock( Factory.MetaCode("Option Explicit Off") .With(SetVBOptionCodeGenerator.Explicit(false)))); }
public void VB_Option_Explicit_Statement() { ParseBlockTest(@"@Option Explicit Off", new DirectiveBlock( Factory.CodeTransition(), Factory.MetaCode("Option Explicit Off") .With(SetVBOptionCodeGenerator.Explicit(false)))); }
protected virtual bool OptionStatement() { try { Context.CurrentBlock.Type = BlockType.Directive; Assert(VBKeyword.Option); AcceptAndMoveNext(); AcceptWhile(VBSymbolType.WhiteSpace); if (!At(VBSymbolType.Identifier)) { if (CurrentSymbol != null) { Context.OnError(CurrentLocation, String.Format(CultureInfo.CurrentCulture, RazorResources.ParseError_Unexpected, CurrentSymbol.Content)); } return(false); } SourceLocation optionLoc = CurrentLocation; string option = CurrentSymbol.Content; AcceptAndMoveNext(); AcceptWhile(VBSymbolType.WhiteSpace); bool boolVal; if (At(VBKeyword.On)) { AcceptAndMoveNext(); boolVal = true; } else if (At(VBSymbolType.Identifier)) { if (String.Equals(CurrentSymbol.Content, SyntaxConstants.VB.OffKeyword, StringComparison.OrdinalIgnoreCase)) { AcceptAndMoveNext(); boolVal = false; } else { Context.OnError(CurrentLocation, String.Format(CultureInfo.CurrentCulture, RazorResources.ParseError_InvalidOptionValue, option, CurrentSymbol.Content)); AcceptAndMoveNext(); return(false); } } else { if (!EndOfFile) { Context.OnError(CurrentLocation, String.Format(CultureInfo.CurrentCulture, RazorResources.ParseError_Unexpected, CurrentSymbol.Content)); AcceptAndMoveNext(); } return(false); } if (String.Equals(option, SyntaxConstants.VB.StrictKeyword, StringComparison.OrdinalIgnoreCase)) { Span.CodeGenerator = SetVBOptionCodeGenerator.Strict(boolVal); } else if (String.Equals(option, SyntaxConstants.VB.ExplicitKeyword, StringComparison.OrdinalIgnoreCase)) { Span.CodeGenerator = SetVBOptionCodeGenerator.Explicit(boolVal); } else { Span.CodeGenerator = new SetVBOptionCodeGenerator(option, boolVal); Context.OnError(optionLoc, RazorResources.ParseError_UnknownOption, option); } } finally { if (Span.Symbols.Count > 0) { Output(SpanKind.MetaCode); } } return(true); }