hectoparsec-0.1.0.0: Flexible and powerful parser combinators
Copyright(c) comp 2020
LicenseMIT
Maintaineronecomputer00@gmail.com
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hectoparsec.Pos

Description

Data type for source position.

Synopsis

Positional data

data Pos Source #

The position of a token within the source text.

Constructors

Pos 

Fields

Instances

Instances details
Show Pos Source # 
Instance details

Defined in Hectoparsec.Pos

Eq Pos Source # 
Instance details

Defined in Hectoparsec.Pos

Methods

(==) :: Pos -> Pos -> Bool Source #

(/=) :: Pos -> Pos -> Bool Source #

Ord Pos Source # 
Instance details

Defined in Hectoparsec.Pos

Methods

compare :: Pos -> Pos -> Ordering Source #

(<) :: Pos -> Pos -> Bool Source #

(<=) :: Pos -> Pos -> Bool Source #

(>) :: Pos -> Pos -> Bool Source #

(>=) :: Pos -> Pos -> Bool Source #

max :: Pos -> Pos -> Pos Source #

min :: Pos -> Pos -> Pos Source #

initialPos :: FilePath -> Pos Source #

Creates a Pos for the start of a source text (line 1, column 1) with a given file path.

updatePos Source #

Arguments

:: (a -> Bool)

Whether the token is a new line.

-> a

The token.

-> Pos

The position to update.

-> Pos 

Updates position based on a character-like token.

Tokens which are considered newlines will increment the line number by 1 and set the column number to 1. Otherwise, the column number is incremented by one.