Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:42:39+00:00 2026-06-09T12:42:39+00:00

I am trying to define an external DSL using the scala parser combinators. I

  • 0

I am trying to define an external DSL using the scala parser combinators. I see that the ‘stringLit’ token parser does not accomodate multi line strings using the triple quotes. Is there something similar to a multiLineStringLit in the scala parser combinator world?

Thanks in advance,
Kishore

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:42:40+00:00Added an answer on June 9, 2026 at 12:42 pm

    Not that I’m aware of, but it’s not too hard to write your own:

    import scala.util.parsing.combinator._
    
    object myParser extends JavaTokenParsers {
      def mlStringLiteral: Parser[String] = (
        "\"\"\"" +
        """(\n|[^"\p{Cntrl}\\]|\\[\\/bfnrt]|\\u[a-fA-F0-9]{4})*""" +
        "\"\"\""
      ).r
    }
    

    This is just stringLiteral with a couple of minor edits: I’ve changed the delimiter from " to """ and added \n to the character match.

    scala> val s = "\"\"\"This is a multi-\nline string literal.\"\"\""
    s: java.lang.String = 
    """This is a multi-
    line string literal."""
    
    scala> myParser.parseAll(myParser.mlStringLiteral, s)
    res0: myParser.ParseResult[String] = 
    [2.24] parsed: """This is a multi-
    line string literal."""
    

    It’s not an exact match for Scala’s implementation of multi-line string literals (you can’t have an unescaped " in the string, for example), but it can easily be tweaked, and may work for you as it is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does the Cyrus SASL api not support the EXTERNAL mechanism? I'm trying to use
I'm trying to define a HtmlComponent to open an external link in LWUIT but
I'm trying to define a method in my vb.net interface that will only accept
I am trying to define an abstract class that has operators to compare two
I'm trying to define a service endpoint in my web.config file so that I
I am trying to redefine an element definition contained in an external xsd (that
I'm using Oracle 11g, and trying to create a table define constraints on the
I'm not too familiar with using the <h:messages> element in JSF. What I'm trying
I'm trying to use an external configuration file to define multiple location elements within
I am trying to use the xaml below to define a Button that will:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.