class LineParser extends JavaTokenParsers
LineParser: class to parse lines of a CSV file. NOTE: list elements always appear as a string in the form { element0 , element1 , ... }
- Alphabetic
- By Inheritance
- LineParser
- JavaTokenParsers
- RegexParsers
- Parsers
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new LineParser(delimiter: Regex, string: Regex, enclosures: String, listSeparator: Char, quote: Char, verbose: Boolean = false)
- delimiter
a Regex used to match a delimiter between cells in a row.
- string
a Regex used to match the content of a cell.
- enclosures
the enclosure characters around a list (if any).
- listSeparator
the list separator character.
- quote
the quote character which is able to preempt the string regex: between two quote characters, there can be any number of any character (other than quote).
- verbose
will print the various parameters.
Type Members
- type Elem = Char
- Definition Classes
- RegexParsers → Parsers
- case class Error extends NoSuccess with Product with Serializable
- Definition Classes
- Parsers
- case class Failure extends NoSuccess with Product with Serializable
- Definition Classes
- Parsers
- type Input = Reader[Elem]
- Definition Classes
- Parsers
- sealed abstract class NoSuccess extends ParseResult[Nothing]
- Definition Classes
- Parsers
- trait OnceParser[+T] extends Parser[T]
- Definition Classes
- Parsers
- sealed abstract class ParseResult[+T] extends AnyRef
- Definition Classes
- Parsers
- abstract class Parser[+T] extends (Input) => ParseResult[T]
- Definition Classes
- Parsers
- case class Success[+T] extends ParseResult[T] with Product with Serializable
- Definition Classes
- Parsers
- case class ~[+a, +b] extends Product with Serializable
- Definition Classes
- Parsers
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def OnceParser[T](f: (Input) => ParseResult[T]): Parser[T] with OnceParser[T]
- Definition Classes
- Parsers
- def Parser[T](f: (Input) => ParseResult[T]): Parser[T]
- Definition Classes
- Parsers
- def accept[U](expected: String, f: PartialFunction[Elem, U]): Parser[U]
- Definition Classes
- Parsers
- def accept[ES](es: ES)(implicit f: (ES) => List[Elem]): Parser[List[Elem]]
- Definition Classes
- Parsers
- implicit def accept(e: Elem): Parser[Elem]
- Definition Classes
- Parsers
- def acceptIf(p: (Elem) => Boolean)(err: (Elem) => String): Parser[Elem]
- Definition Classes
- Parsers
- def acceptMatch[U](expected: String, f: PartialFunction[Elem, U]): Parser[U]
- Definition Classes
- Parsers
- def acceptSeq[ES](es: ES)(implicit f: (ES) => Iterable[Elem]): Parser[List[Elem]]
- Definition Classes
- Parsers
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- lazy val cell: Parser[String]
A
Parserthat attempts to parse a cell value in a variety of forms.A
Parserthat attempts to parse a cell value in a variety of forms.The
cellparser evaluates different parsing strategies in sequence:quotedString: Parses a string enclosed in quotation marks.list: Parses a list structure.string: Parses a generic string.failure("invalid string"): Returns a parsing failure with the message "invalid string" if none of the other parsers are successful.
This parser is declared as
lazyto allow it to be initialized when first accessed, enabling any dependencies it might have to be resolved at runtime. - def chainl1[T, U](first: => Parser[T], p: => Parser[U], q: => Parser[(T, U) => T]): Parser[T]
- Definition Classes
- Parsers
- def chainl1[T](p: => Parser[T], q: => Parser[(T, T) => T]): Parser[T]
- Definition Classes
- Parsers
- def chainr1[T, U](p: => Parser[T], q: => Parser[(T, U) => U], combine: (T, U) => U, first: U): Parser[U]
- Definition Classes
- Parsers
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def commit[T](p: => Parser[T]): Parser[T]
- Definition Classes
- Parsers
- def decimalNumber: Parser[String]
- Definition Classes
- JavaTokenParsers
- def elem(e: Elem): Parser[Elem]
- Definition Classes
- Parsers
- def elem(kind: String, p: (Elem) => Boolean): Parser[Elem]
- Definition Classes
- Parsers
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def err(msg: String): Parser[Nothing]
- Definition Classes
- RegexParsers → Parsers
- def failure(msg: String): Parser[Nothing]
- Definition Classes
- Parsers
- def floatingPointNumber: Parser[String]
- Definition Classes
- JavaTokenParsers
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def guard[T](p: => Parser[T]): Parser[T]
- Definition Classes
- Parsers
- def handleWhiteSpace(source: CharSequence, offset: Int): Int
- Attributes
- protected
- Definition Classes
- RegexParsers
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def ident: Parser[String]
- Definition Classes
- JavaTokenParsers
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- lazy val list: Parser[String]
A lazy val for a Parser that parses a list-like structure encapsulated by open and close characters.
A lazy val for a Parser that parses a list-like structure encapsulated by open and close characters.
The parser works as follows: 1. It expects an opening character (
getOpenChar). 2. It parses a component followed by alistSeparator, and one or more components separated bylistSeparatorusingrep1sep. 3. It concludes by expecting a closing character (getCloseChar). 4. Finally, it transforms the parsed elements into a String representation where the components are encapsulated by curly braces and separated by commas, e.g., "{component1,component2,...}".- returns
A
Parser[String]that produces the string representation of the parsed list.
- implicit def literal(s: String): Parser[String]
- Definition Classes
- RegexParsers
- def log[T](p: => Parser[T])(name: String): Parser[T]
- Definition Classes
- Parsers
- def mkList[T]: (~[T, List[T]]) => List[T]
- Definition Classes
- Parsers
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def not[T](p: => Parser[T]): Parser[Unit]
- Definition Classes
- Parsers
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def opt[T](p: => Parser[T]): Parser[Option[T]]
- Definition Classes
- Parsers
- def parse[T](p: Parser[T], in: Reader): ParseResult[T]
- Definition Classes
- RegexParsers
- def parse[T](p: Parser[T], in: CharSequence): ParseResult[T]
- Definition Classes
- RegexParsers
- def parse[T](p: Parser[T], in: Reader[Char]): ParseResult[T]
- Definition Classes
- RegexParsers
- def parseAll[T](p: Parser[T], in: CharSequence): ParseResult[T]
- Definition Classes
- RegexParsers
- def parseAll[T](p: Parser[T], in: Reader): ParseResult[T]
- Definition Classes
- RegexParsers
- def parseAll[T](p: Parser[T], in: Reader[Char]): ParseResult[T]
- Definition Classes
- RegexParsers
- def parseRow(indexedString: (String, Int)): Try[Strings]
Method to parse a Row.
Method to parse a Row.
NOTE: the expressions "end of input expected" and "end of input" are defined in (trait) Parsers: def phrase[T](p: Parser[T]): Parser[T] def acceptMatch[U]... def acceptIf... It's a shame that they didn't make it a constant in Parsers!
CONSIDER checking that sequential lines really are sequential. Currently, no use is made of
indexedString._2- indexedString
a tuple of String and Int denoting the line and its index in the file.
- returns
a Try[Strings].
- def phrase[T](p: Parser[T]): Parser[T]
- Definition Classes
- RegexParsers → Parsers
- def positioned[T <: Positional](p: => Parser[T]): Parser[T]
- Definition Classes
- RegexParsers → Parsers
- lazy val pureQuotedString: Parser[String]
A
Parserthat extracts a quoted string from the input.A
Parserthat extracts a quoted string from the input.The parser is defined as a combination of three elements: -
quote: Matches the opening quote character. -stringInQuotes: Parses the content inside the quotes. -quote: Matches the closing quote character.This parser uses the sequence combinators (
~>and<~) to drop the quote characters themselves.- returns
a
Parser[String]that successfully parses a string enclosed in quotes and returns the content within the quotes as aString.
- lazy val quotedString: Parser[String]
A parser for quoted strings in the input, using a combination of possible parsing strategies.
A parser for quoted strings in the input, using a combination of possible parsing strategies.
The
quotedStringmethod combines three different parsers to handle quoted strings: 1.quotedStringWithQuotes: Parses quoted strings that include surrounding quotation marks. 2.pureQuotedString: Parses quoted strings but may apply stricter conditions (e.g., specific delimiters or special characters). 3.failure("invalid quoted string"): Ensures that any string not following the valid quoted string format results in a failure.This is defined as a lazy val, meaning the parser's initialization is deferred until it is first accessed.
- returns
A
Parser[String]that matches valid quoted strings in the input.
- lazy val quotedStringWithQuotes: Parser[String]
Parser for quoted strings that includes the surrounding quotes as part of the result.
Parser for quoted strings that includes the surrounding quotes as part of the result.
This lazy value utilizes
quotedStringWithQuotesAsList, which parses the string components into a list of strings. It then combines those components into a single string by adding the surrounding quotes (as defined by thequotevariable).The resulting parsed string includes both the content of the quoted string and the enclosing quote characters.
For example: Input:
"Hello, World!"Output:"Hello, World!"(as a single string, including the quotation marks)- returns
a parser that yields the entire quoted string, including the enclosing quotes.
- lazy val quotedStringWithQuotesAsList: Parser[Strings]
A parser that extracts a sequence of strings (Strings) from a quoted string, interpreting quotes and escaped quotes appropriately.
A parser that extracts a sequence of strings (Strings) from a quoted string, interpreting quotes and escaped quotes appropriately.
The input is expected to start and end with a quote character. Inside the quotes, delimited substrings can be separated by pairs of quote characters.
Example Input: "abc""def""ghi" Parsed Output: Seq("abc", "def", "ghi")
The parser works as follows: -
quote ~>ensures that the input starts with a single opening quote. -repsep(stringInQuotes, s"$quote$quote")parses a repetition of strings defined bystringInQuotes, with consecutive strings separated by double quotes (""). -<~ quoteensures the input ends with a single closing quote.- returns
a Parser[Strings] capable of parsing a quoted string into a sequence of substrings.
- implicit def regex(r: Regex): Parser[String]
- Definition Classes
- RegexParsers
- def rep[T](p: => Parser[T]): Parser[List[T]]
- Definition Classes
- Parsers
- def rep1[T](first: => Parser[T], p0: => Parser[T]): Parser[List[T]]
- Definition Classes
- Parsers
- def rep1[T](p: => Parser[T]): Parser[List[T]]
- Definition Classes
- Parsers
- def rep1sep[T](p: => Parser[T], q: => Parser[Any]): Parser[List[T]]
- Definition Classes
- Parsers
- def repN[T](num: Int, p: => Parser[T]): Parser[List[T]]
- Definition Classes
- Parsers
- def repNM[T](n: Int, m: Int, p: Parser[T], sep: Parser[Any]): Parser[List[T]]
- Definition Classes
- Parsers
- def repsep[T](p: => Parser[T], q: => Parser[Any]): Parser[List[T]]
- Definition Classes
- Parsers
- lazy val row: Parser[Strings]
A parser for parsing a single row consisting of multiple cells separated by a delimiter.
A parser for parsing a single row consisting of multiple cells separated by a delimiter.
This parser matches and extracts repetitions of cells (parsed by the
cellparser) separated by the specified delimiter. The result is returned as a sequence of strings (Strings).- The
rep1sepcombinator ensures that at least one cell is expected in the row. - The delimiter parser defines the separator between cells.This parser can be used in conjunction with other parsers to process row-based data with a specific format or structure.
- def skipWhitespace: Boolean
- Definition Classes
- LineParser → RegexParsers
- lazy val stringInQuotes: Parser[String]
A
Parserthat matches a string that includes zero or more characters (other than quote characters as defined by thequoteparameter).A
Parserthat matches a string that includes zero or more characters (other than quote characters as defined by thequoteparameter).This parser specifically matches a sequence of characters that does not include the quote character (
"). Thequotecharacter in this context is expected to be defined elsewhere in the class or inherited scope.Usage: This parser can be used to identify and extract substrings within a larger input that are enclosed in quotes, as part of a more complex parsing process.
- returns
a string that matches the defined regular expression.
- def stringLiteral: Parser[String]
- Definition Classes
- JavaTokenParsers
- def success[T](v: T): Parser[T]
- Definition Classes
- Parsers
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- LineParser → AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- val whiteSpace: Regex
- Attributes
- protected
- Definition Classes
- RegexParsers
- def wholeNumber: Parser[String]
- Definition Classes
- JavaTokenParsers
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)