private static string GetName(CSharpSymbol sym)
 {
     if (sym.Type == CSharpSymbolType.Keyword)
     {
         return(CSharpLanguageCharacteristics.GetKeyword(sym.Keyword.Value));
     }
     return(sym.Content);
 }
 private void MapKeywords(Action <bool> handler, bool topLevel, params CSharpKeyword[] keywords)
 {
     foreach (CSharpKeyword keyword in keywords)
     {
         _keywordParsers.Add(keyword, handler);
         if (topLevel)
         {
             Keywords.Add(CSharpLanguageCharacteristics.GetKeyword(keyword));
         }
     }
 }
        private void EmbeddedExpression()
        {
            // First, verify the type of the block
            Assert(CSharpSymbolType.Transition);
            CSharpSymbol transition = CurrentSymbol;

            NextToken();

            if (At(CSharpSymbolType.Transition))
            {
                // Escaped "@"
                Output(SpanKind.Code);

                // Output "@" as hidden span
                Accept(transition);
                Span.CodeGenerator = SpanCodeGenerator.Null;
                Output(SpanKind.Code);

                Assert(CSharpSymbolType.Transition);
                AcceptAndMoveNext();
                StandardStatement();
            }
            else
            {
                // Throw errors as necessary, but continue parsing
                if (At(CSharpSymbolType.Keyword))
                {
                    Context.OnError(CurrentLocation,
                                    RazorResources.ParseError_Unexpected_Keyword_After_At,
                                    CSharpLanguageCharacteristics.GetKeyword(CurrentSymbol.Keyword.Value));
                }
                else if (At(CSharpSymbolType.LeftBrace))
                {
                    Context.OnError(CurrentLocation, RazorResources.ParseError_Unexpected_Nested_CodeBlock);
                }

                // @( or @foo - Nested expression, parse a child block
                PutCurrentBack();
                PutBack(transition);

                // Before exiting, add a marker span if necessary
                AddMarkerSymbolIfNecessary();

                NestedBlock();
            }
        }