Syntax.ParseToken expected behavior is ambiguous for context sensitive keywords

Answered Syntax.ParseToken expected behavior is ambiguous for context sensitive keywords

  • 11. února 2012 20:45
     
     

    I expected Syntax.ParseToken("from") to return FromKeyword token not an identifier "from". If I want an identifier token then I'll call Syntax.Identifier.

    Actually Roslyn should not have a Syntax.ParseToken as it's behavior is ambiguous for context senstive keywords. Instead, I Roslyn should partition keywords and provide parse functions for each family. E.g. ParseKeyword, ParseIdentifier, ParsePunctuation, etc. 

    Thanks,
    Chris

Všechny reakce

  • 11. února 2012 21:51
     
     
    You can use Syntax.Token(SyntaxKind.FromKeyword) instead.
    • Upravený svick 11. února 2012 21:51
    • Upravený svick 11. února 2012 21:51
    • Upravený svick 11. února 2012 21:51
    •  
  • 12. února 2012 20:12
     
     

    Svick, yeah, that's what I did but having one unambiguous API doesn't makeup for the ambiguous one. A C# ParseToken is context sensitive and the current API doesn't accept a context.

     
  • 13. února 2012 20:24
    Vlastník
     
     Odpovědět
    Thats a good suggestion Chris. I agree that the .ParseToken() API is confusing / ambiguous. Could you please log this suggestion via Connect? Alternately just let me know and I can log this internally on your behalf. Thanks!

    Shyam Namboodiripad | Software Development Engineer in Test | Roslyn Compilers Team

    • Označen jako odpověď kingces95 14. února 2012 21:24
    •  
  • 14. února 2012 21:24
     
     

    Shyam,

    Please log for me. Connect is of limited value to me because issues are closed before I consider them resolved. For example, my connect issue "ability to access private data members" was closed with a note that it was a good idea and pushed onto an internal backlog. Does that mean that it'll get done eventually or that it might get dropped? I don't know. And if the decision is made one way or another I won't know. 

    So going forward please just open issues for me unless the connect policy changes. 

    Thanks,
    Chris