platinum-parsing-0.1.0.0: General Framework for compiler development.

Copyright(c) 2017 Patrick Champion
Licensesee LICENSE file
Maintainerchlablak@gmail.com
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

PP.Rule

Contents

Description

 

Synopsis

Canonical low-level rule

data Rule Source #

Canonical rule type

Constructors

Rule String [Rule]

A rule is defined by a non terminal and a list of Term and NonTerm The list should end with Empty

NonTerm String

Non terminal string

Term IToken

Terminal character

TermToken String

Terminal token

Empty

Empty

Concat [Rule]

Concatenated rules, useful for PP.InputGrammar.rules

RegEx String

Regular expression, useful for lexical rules

RegExString String

No parse-string

Instances

Eq Rule Source # 

Methods

(==) :: Rule -> Rule -> Bool #

(/=) :: Rule -> Rule -> Bool #

Ord Rule Source # 

Methods

compare :: Rule -> Rule -> Ordering #

(<) :: Rule -> Rule -> Bool #

(<=) :: Rule -> Rule -> Bool #

(>) :: Rule -> Rule -> Bool #

(>=) :: Rule -> Rule -> Bool #

max :: Rule -> Rule -> Rule #

min :: Rule -> Rule -> Rule #

Show Rule Source # 

Methods

showsPrec :: Int -> Rule -> ShowS #

show :: Rule -> String #

showList :: [Rule] -> ShowS #

Binary Rule Source # 

Methods

put :: Rule -> Put #

get :: Get Rule #

putList :: [Rule] -> Put #

uniformize :: [Rule] -> [Rule] Source #

Uniformize a list of rules `uniformize = sort . nub . concatMap (flatten . clean)`

extend :: [Rule] -> Either String [Rule] Source #

Generate an augmented grammar

separate :: [Rule] -> ([Rule], [Rule]) Source #

Separate rules into (parsing rules, lexing rules)

regexfy :: [Rule] -> [Rule] Source #

Transform lexing rules to have only one RegEx on right

Canonical rules as Map

type RuleSet = Map String [[Rule]] Source #

Rules as a map

ruleSet :: [Rule] -> RuleSet Source #

Compute the rule set

rule :: String -> RuleSet -> [Rule] Source #

Get rule from a RuleSet

check :: RuleSet -> ([String], [String]) Source #

Check a rule set, return: (errors, warnings)

Rules first set (Map)

type FirstSet = Map String [Rule] Source #

First set type

firstSet :: RuleSet -> FirstSet Source #

Compute the complete first set

first :: Rule -> FirstSet -> [Rule] Source #

Compute first set of a given rule