How to create a parser from Regex in Scala to parse a path?

后端 未结 2 2030
半阙折子戏
半阙折子戏 2021-01-25 04:43

I am writing a parser in which I am trying to parse a path and do arithmetic calculations. since I cannot use RegexParsers with StandardTokenParsers I am trying to make my own.

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-25 05:05

    I solved it writing a trait and using JavaTokenParsers rather than StandardToken Parser.

     trait pathIdentifier extends RegexParsers{
    
          def pathIdent: Parser[String] ={
              """hdfs://([\d\.]+):(\d+)/([\w/]+/(\w+\.\w+))""".r
        }
    }
    

    @Tilo Thanks for your help your solution is working as well but changing extended class to JavaTokenParser helped to solve the problem.

提交回复
热议问题