'How to handle a long sequential composition in Scala Parser Combinators?
How can I process a sequential composition such as
(String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String) ~ (String, String)?
Normally I would handle it as
def member: Parser[(String, Any)] =
stringLiteral~":"~value ˆˆ
{ case name~":"~value => (name, value) }
How to handle a long sequential composition?
My goal is to create a Map of all (String, String) pairs.
If I try to do it similar way then it would look as
^^ {
case (str1, str2) ~ (str3, str4) ~ (str5, str6).... => {
// Add all (k,v) into a Map[String, String]
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
