2011-05-10 15 views

Respuesta

11

Puede usar una expresión regular simple, siempre que no anide comentarios. Póngalo dentro de whiteSpace:

scala> object T extends JavaTokenParsers { 
    | protected override val whiteSpace = """(\s|//.*|(?m)/\*(\*(?!/)|[^*])*\*/)+""".r 
    | def simpleParser = ident+ 
    | } 
defined module T 

scala> val testString = """ident // comment to the end of line 
    | another ident /* start comment 
    | end comment */ final ident""" 
testString: java.lang.String = 
ident // comment to the end of line 
another ident /* start comment 
end comment */ final ident 

scala> T.parseAll(T.simpleParser, testString) 
res0: T.ParseResult[List[String]] = [3.27] parsed: List(ident, another, ident, final, ident) 
+0

@ziggystar Ok, espera un segundo ... –

Cuestiones relacionadas