position

parsley.position$
object position

TODO: Document These parsers provide a way to extract position information during a parse. This can be important for when the final result of the parser needs to encode position information for later consumption: this is particularly useful for abstract syntax trees.

Attributes

Source:
position.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Concise view

pos

This parser returns the current column number of the input without having any other effect.

This parser returns the current column number of the input without having any other effect.

When this combinator is ran, no input is required, nor consumed, and the current column number will always be successfully returned. It has no other effect on the state of the parser.

Attributes

Returns:

a parser that returns the column number the parser is currently at.

Note:

in the presence of wide unicode characters, the value returned may be inaccurate.

Example:

scala> import parsley.Parsley.col, parsley.character.char
scala> col.parse("")
val res0 = Success(1)
scala> (char('a') *> col).parse("a")
val res0 = Success(2)
scala> (char('\n') *> col).parse("\n")
val res0 = Success(1)
Source:
position.scala

This parser returns the current line number of the input without having any other effect.

This parser returns the current line number of the input without having any other effect.

When this combinator is ran, no input is required, nor consumed, and the current line number will always be successfully returned. It has no other effect on the state of the parser.

Attributes

Returns:

a parser that returns the line number the parser is currently at.

Example:

scala> import parsley.Parsley.line, parsley.character.char
scala> line.parse("")
val res0 = Success(1)
scala> (char('a') *> line).parse("a")
val res0 = Success(1)
scala> (char('\n') *> line).parse("\n")
val res0 = Success(2)
Source:
position.scala
val pos: Parsley[(Int, Int)]

This parser returns the current line and column numbers of the input without having any other effect.

This parser returns the current line and column numbers of the input without having any other effect.

When this combinator is ran, no input is required, nor consumed, and the current line and column number will always be successfully returned. It has no other effect on the state of the parser.

Attributes

Returns:

a parser that returns the line and column number the parser is currently at.

Note:

in the presence of wide unicode characters, the column value returned may be inaccurate.

Example:

scala> import parsley.Parsley.pos, parsley.character.char
scala> pos.parse("")
val res0 = Success((1, 1))
scala> (char('a') *> pos).parse("a")
val res0 = Success((1, 2))
scala> (char('\n') *> pos).parse("\n")
val res0 = Success((2, 1))
Source:
position.scala

Value members

Concrete fields

TODO: Document

TODO: Document

Attributes

Source:
position.scala