score:1
here i assume, that the text you parse always contains exactly two say nodes and that you don't want to check that the line --make_123--
is valid (i.e., has the same id as the first line).
you don't have to omit the empty line manually. it gets skipped automatically, because it's whitespace.
you are using parseall
, that means that your parser should match the whole text sent to it. so you have to add to your grammar the code to parse the second say line and the closing line --make_123--
.
that's simple to do with the parser functions you have already defined, and with a slight modification to the function producing mapcontent
from the parsed result.
the parserequest
function should be changed to have the following definition:
def parserequest: parser[mapcontent] =
parsemakeid ~ parsetext ~ parsetext <~ parsemakeid ^^ {
case makeid ~ firstnode ~ secondnode =>
mapcontent(
map("makeid" -> makeid,
"firstnode" -> firstnode,
"secondnode" -> secondnode))
}
Source: stackoverflow.com
Related Query
- scala parsing next line
- Parsing command line args and executing a function in scala
- how to read a .dat file with delimiter /u0001 and record next record will be separating by next line in spark with scala
- New line character in Scala
- Line continuation character in Scala
- Scala and HTML parsing
- Built in parsing of a string to a Scala case object?
- Accessing the next element in list to compare in Scala
- Parsing JSON in Play2 and Scala without Data Type
- Parsing of binary data with scala
- Parsing multipart HTTP form data with file upload content using Scala
- In Scala or Java, how to print a line to console replacing its previous content instead of appending?
- Cant move to next line while reading csv file
- Play 2 Scala - Best way to upload a big CSV file with Iteratee in order to process each line reactively
- Reading Multiple Inputs from the Same Line the Scala Way
- Scala code crashing with java.util.NoSuchElementException: next on empty iterator
- Scala logging line numbers - slf4s/slf4j?
- Print json string in one line using circe in scala
- Scala command line parser using Scallop
- How to modify previous line in REPL - scala to modify the typing errors to save time compare to entering each line using up/down arrows
- Why does this Scala line return a Unit?
- parsing recursive structures in scala
- Grammars, Scala Parsing Combinators and Orderless Sets
- Parsing an indentation based language using scala parser combinators
- Scala coding standards: curly braces on the same line
- Parsing scala 3 code from a String into Scala 3 AST at runtime
- Scala Parsing RSS/Atom feeds
- How to get first line from file in Scala
- Creating an O(1)-memory Iterable from an initial object and a function which generates the next object, in Scala
- What does this split line in Scala mean?
More Query from same tag
- Pattern matching on function parameters
- How does the <:< operator work in Scala?
- Class path error using spark-submit
- Scala + Android IDE
- Spark: Error on writing DataFrame
- How to mock actors in a cluster sharding test environment?
- yield() gives an incorrect mismatch error
- Gatling CSV feeder keeps getting the first value in the csv when using repeat() or during() and when using 1 virtual user
- Fastest algorithm to calculate the number of business days between two dates?
- Why does the Scala worksheet evaluate the stream?
- How to convert DateTimeComparator to an Ordering[DateTime] in Scala
- Query and find the path of an JSON element value with Play JSON
- Passing In Config In Gatling Tests
- Error handling in list of scala futures - Apache Spark
- Play Framework - add a field to JSON object
- How to make my java class writable by extending it with scala class?
- Scala List.updated
- When to use val or def in Scala traits?
- How to continue processing if an exception is thrown in call to function?
- Not found in pattern matching
- akka http not handling parameters with dollar signs properly?
- Why cannot this case of implicit conversions be optimized?
- Calculate average in scala
- Spark 2 iterating over a partition to create a new partition
- Toree on Jupyter for Spark 2.2.0
- type mismatch error in akka dsl route directive
- Loading xgboost model trained in python to scala
- Scala - How to implement implicit JSON reader
- Filter Spark dataset using custom function in scala
- How to stop the entire Akka Cluster (Sharding)