Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parser that accepts Scala Identifiers?

Tags:

parsing

scala

I was wondering whether the standard Scala parser combinators contain a parser that accepts the same identifiers that the Scala language itself also accepts (as specified in the Scala Language Specification, Section 1.1).

The StdTokenParsers trait has an ident parser, but it rejects identifiers like empty_?.

(If there is indeed no such parser, I could also just instantiate the Scala parser itself, but that wouldn't be as lightweight anymore.)

like image 590
Mirko Stocker Avatar asked Jun 14 '10 06:06

Mirko Stocker


1 Answers

Not a standard parser combinator, but there are canonical tools for testing Scala id-ness in scala.tools.nsc.util.Chars. No need to instantiate either Global or a Scala scanner.

like image 91
Miles Sabin Avatar answered Oct 22 '22 11:10

Miles Sabin