pec-0.2.0: Language/Pec/Par.y
{
{-# OPTIONS -w #-}
-- Haskell module generated by grm *** DO NOT EDIT ***
module Language.Pec.Par where
import Grm.Prims
import Grm.Lex
import Language.Pec.Abs
}
%tokentype { (Token Point) }
%name grmParse
%token
"#" { TSymbol _ "#" }
"(" { TSymbol _ "(" }
")" { TSymbol _ ")" }
"," { TSymbol _ "," }
"->" { TSymbol _ "->" }
"." { TSymbol _ "." }
".." { TSymbol _ ".." }
"::" { TSymbol _ "::" }
";" { TSymbol _ ";" }
"<-" { TSymbol _ "<-" }
"=" { TSymbol _ "=" }
"=>" { TSymbol _ "=>" }
"@" { TSymbol _ "@" }
"Array" { TSymbol _ "Array" }
"[" { TSymbol _ "[" }
"\\" { TSymbol _ "\\" }
"]" { TSymbol _ "]" }
"as" { TSymbol _ "as" }
"branch" { TSymbol _ "branch" }
"case" { TSymbol _ "case" }
"do" { TSymbol _ "do" }
"exports" { TSymbol _ "exports" }
"extern" { TSymbol _ "extern" }
"imports" { TSymbol _ "imports" }
"in" { TSymbol _ "in" }
"instance" { TSymbol _ "instance" }
"let" { TSymbol _ "let" }
"module" { TSymbol _ "module" }
"of" { TSymbol _ "of" }
"switch" { TSymbol _ "switch" }
"type" { TSymbol _ "type" }
"where" { TSymbol _ "where" }
"{" { TSymbol _ "{" }
"|" { TSymbol _ "|" }
"}" { TSymbol _ "}" }
uident { TUident _ _ }
usym { TUsym _ _ }
lident { TLident _ _ }
string { TString _ _ }
char { TChar _ _ }
number { TNumber _ _ }
%%
Module
: "module" Modid ExportDecls ImportDecls "where" "{" TopDeclList "}" {Module (lrPoint [point $1
,point $2
,point $3
,point $4
,point $5
,point $6
,lrPointList $7
,point $8]) $2 $3 $4 $7 }
ExportDecls
: "exports" "{" ExportList "}" {ExpListD (lrPoint [point $1
,point $2
,lrPointList $3
,point $4]) $3 }
| {ExpAllD noPoint}
ImportDecls
: "imports" "{" ImportList "}" {ImpListD (lrPoint [point $1
,point $2
,lrPointList $3
,point $4]) $3 }
| {ImpNoneD noPoint}
Export
: Con Spec {TypeEx (lrPoint [point $1
,point $2]) $1 $2}
| Var {VarEx (point $1) $1}
Import
: Modid AsSpec {Import (lrPoint [point $1
,point $2]) $1 $2}
AsSpec
: "as" Modid {AsAS (lrPoint [point $1
,point $2]) $2}
| {EmptyAS noPoint}
Spec
: {Neither noPoint}
| "(" "." ")" {Decon (lrPoint [point $1
,point $2
,point $3]) }
| "(" ".." ")" {Both (lrPoint [point $1
,point $2
,point $3]) }
TopDecl
: "extern" ExtNm Var "::" Type {ExternD (lrPoint [point $1
,point $2
,point $3
,point $4
,point $5]) $2 $3 $5}
| "type" Con VarList "=" TyDecl {TypeD (lrPoint [point $1
,point $2
,lrPointList $3
,point $4
,point $5]) $2 $3 $5}
| "type" Con VarList {TypeD0 (lrPoint [point $1
,point $2
,lrPointList $3]) $2 $3}
| Var "::" Type {AscribeD (lrPoint [point $1
,point $2
,point $3]) $1 $3}
| Var DeclSym Exp {VarD (lrPoint [point $1
,point $2
,point $3]) $1 $2 $3}
| Var Exp0List DeclSym Exp {ProcD (lrPoint [point $1
,lrPointList $2
,point $3
,point $4]) $1 $2 $3 $4}
| "instance" Con Type {InstD (lrPoint [point $1
,point $2
,point $3]) $2 $3}
DeclSym
: "=>" {Macro (point $1) }
| "=" {Define (point $1) }
ExtNm
: string {SomeNm (point $1) (unTString $1)}
| {NoneNm noPoint}
Exp
: "do" "{" Exp5List "}" {BlockE (lrPoint [point $1
,point $2
,lrPointList $3
,point $4]) $3 }
| Exp5 { $1 }
Exp5
: Exp4 DeclSym Exp {LetS (lrPoint [point $1
,point $2
,point $3]) $1 $2 $3}
| "let" Exp4 DeclSym Exp "in" Exp {LetE (lrPoint [point $1
,point $2
,point $3
,point $4
,point $5
,point $6]) $2 $3 $4 $6}
| "\\" Exp0List "->" Exp {LamE (lrPoint [point $1
,lrPointList $2
,point $3
,point $4]) $2 $4}
| Exp4 "<-" Exp {StoreE (lrPoint [point $1
,point $2
,point $3]) $1 $3}
| "case" Exp "of" "{" CaseAltList DefaultAlt "}" {CaseE (lrPoint [point $1
,point $2
,point $3
,point $4
,lrPointList $5
,point $6
,point $7]) $2 $5 $6 }
| "switch" Exp "of" "{" SwitchAltList DefaultAlt "}" {SwitchE (lrPoint [point $1
,point $2
,point $3
,point $4
,lrPointList $5
,point $6
,point $7]) $2 $5 $6 }
| "branch" "{" BranchAltList "|" Exp ";" "}" {BranchE (lrPoint [point $1
,point $2
,lrPointList $3
,point $4
,point $5
,point $6
,point $7]) $3 $5 }
| Exp4 { $1 }
Exp4
: Exp3 usym Exp3 {BinOpE (lrPoint [point $1
,point $2
,point $3]) $1 (unTUsym $2) $3}
| Exp3 { $1 }
Exp3
: Exp3 Exp2 {AppE (lrPoint [point $1
,point $2]) $1 $2}
| Exp2 { $1 }
Exp2
: UnOp Exp1 {UnOpE (lrPoint [point $1
,point $2]) $1 $2}
| Exp1 { $1 }
Exp1
: Exp1 "[" Exp "]" {IdxE (lrPoint [point $1
,point $2
,point $3
,point $4]) $1 $3 }
| Exp1 "." Field {FldE (lrPoint [point $1
,point $2
,point $3]) $1 $3}
| Exp0 { $1 }
Exp0
: "Array" "[" ExpList "]" {ArrayE (lrPoint [point $1
,point $2
,lrPointList $3
,point $4]) $3 }
| "{" FieldDList "}" {RecordE (lrPoint [point $1
,lrPointList $2
,point $3]) $2 }
| "(" ExpList ")" {TupleE (lrPoint [point $1
,lrPointList $2
,point $3]) $2 }
| "(" Exp "::" Type ")" {AscribeE (lrPoint [point $1
,point $2
,point $3
,point $4
,point $5]) $2 $4 }
| Count {CountE (point $1) $1}
| Var {VarE (point $1) $1}
| Lit {LitE (point $1) $1}
UnOp
: "@" {Load (point $1) }
CaseAlt
: Con VarList "->" Exp {CaseAlt (lrPoint [point $1
,lrPointList $2
,point $3
,point $4]) $1 $2 $4}
SwitchAlt
: Lit "->" Exp {SwitchAlt (lrPoint [point $1
,point $2
,point $3]) $1 $3}
DefaultAlt
: Var "->" Exp ";" {DefaultAlt (lrPoint [point $1
,point $2
,point $3
,point $4]) $1 $3 }
| {DefaultNone noPoint}
BranchAlt
: Exp4 "->" Exp {BranchAlt (lrPoint [point $1
,point $2
,point $3]) $1 $3}
Cxt
: Con VarList {Cxt (lrPoint [point $1
,lrPointList $2]) $1 $2}
Type
: "{" CxtList "}" "=>" Type3 {TyCxt (lrPoint [point $1
,lrPointList $2
,point $3
,point $4
,point $5]) $2 $5}
| Type3 { $1 }
Type3
: Type2 "->" Type3 {TyFun (lrPoint [point $1
,point $2
,point $3]) $1 $3}
| Type2 { $1 }
Type2
: "Array" Type1 Type1 {TyArray (lrPoint [point $1
,point $2
,point $3]) $2 $3}
| Con Type1List {TyConstr (lrPoint [point $1
,lrPointList $2]) $1 $2}
| Type1 { $1 }
Type1
: Type0 { $1 }
Type0
: "(" TypeList ")" {TyTuple (lrPoint [point $1
,lrPointList $2
,point $3]) $2 }
| Count {TyCount (point $1) $1}
| TyVar {TyVarT (point $1) $1}
| Con {TyConstr0 (point $1) $1}
TyDecl
: "{" FieldTList "}" {TyRecord (lrPoint [point $1
,lrPointList $2
,point $3]) $2 }
| "|" ConCList {TyTagged (lrPoint [point $1
,lrPointList $2]) $2}
| Type {TySyn (point $1) $1}
ConC
: Con Type0List {ConC (lrPoint [point $1
,lrPointList $2]) $1 $2}
FieldT
: Field "::" Type {FieldT (lrPoint [point $1
,point $2
,point $3]) $1 $3}
Lit
: char {CharL (point $1) (unTChar $1)}
| string {StringL (point $1) (unTString $1)}
| number {NmbrL (point $1) (unTNumber $1)}
| Con {EnumL (point $1) $1}
FieldD
: Field "=" Exp {FieldD (lrPoint [point $1
,point $2
,point $3]) $1 $3}
Count
: "#" number {Count (lrPoint [point $1
,point $2]) (unTNumber $2)}
Var
: lident {Var (point $1) (unTLident $1)}
Con
: uident {Con (point $1) (unTUident $1)}
Modid
: uident {Modid (point $1) (unTUident $1)}
Field
: lident {Field (point $1) (unTLident $1)}
TyVar
: lident {VarTV (point $1) (unTLident $1)}
| "#" lident {CntTV (lrPoint [point $1
,point $2]) (unTLident $2)}
BranchAltList
: REV_BranchAltList {reverse $1}
| {- empty -} { [] }
REV_BranchAltList
: BranchAlt ";" {[$1]}
| REV_BranchAltList BranchAlt ";" {$2 : $1}
CaseAltList
: REV_CaseAltList {reverse $1}
| {- empty -} { [] }
REV_CaseAltList
: CaseAlt ";" {[$1]}
| REV_CaseAltList CaseAlt ";" {$2 : $1}
SwitchAltList
: REV_SwitchAltList {reverse $1}
| {- empty -} { [] }
REV_SwitchAltList
: SwitchAlt ";" {[$1]}
| REV_SwitchAltList SwitchAlt ";" {$2 : $1}
TopDeclList
: REV_TopDeclList {reverse $1}
| {- empty -} { [] }
REV_TopDeclList
: TopDecl ";" {[$1]}
| REV_TopDeclList TopDecl ";" {$2 : $1}
ImportList
: REV_ImportList {reverse $1}
REV_ImportList
: Import ";" {[$1]}
| REV_ImportList Import ";" {$2 : $1}
Exp5List
: REV_Exp5List {reverse $1}
REV_Exp5List
: Exp5 ";" {[$1]}
| REV_Exp5List Exp5 ";" {$2 : $1}
ExportList
: REV_ExportList {reverse $1}
REV_ExportList
: Export ";" {[$1]}
| REV_ExportList Export ";" {$2 : $1}
ConCList
: REV_ConCList {reverse $1}
REV_ConCList
: ConC {[$1]}
| REV_ConCList "|" ConC {$3 : $1}
Exp0List
: REV_Exp0List {reverse $1}
REV_Exp0List
: Exp0 {[$1]}
| REV_Exp0List Exp0 {$2 : $1}
VarList
: REV_VarList {reverse $1}
| {- empty -} { [] }
REV_VarList
: Var {[$1]}
| REV_VarList Var {$2 : $1}
ExpList
: REV_ExpList {reverse $1}
| {- empty -} { [] }
REV_ExpList
: Exp {[$1]}
| REV_ExpList "," Exp {$3 : $1}
FieldDList
: REV_FieldDList {reverse $1}
REV_FieldDList
: FieldD {[$1]}
| REV_FieldDList "," FieldD {$3 : $1}
FieldTList
: REV_FieldTList {reverse $1}
REV_FieldTList
: FieldT {[$1]}
| REV_FieldTList "," FieldT {$3 : $1}
Type0List
: REV_Type0List {reverse $1}
| {- empty -} { [] }
REV_Type0List
: Type0 {[$1]}
| REV_Type0List Type0 {$2 : $1}
Type1List
: REV_Type1List {reverse $1}
REV_Type1List
: Type1 {[$1]}
| REV_Type1List Type1 {$2 : $1}
TypeList
: REV_TypeList {reverse $1}
| {- empty -} { [] }
REV_TypeList
: Type3 {[$1]}
| REV_TypeList "," Type3 {$3 : $1}
CxtList
: REV_CxtList {reverse $1}
REV_CxtList
: Cxt {[$1]}
| REV_CxtList "," Cxt {$3 : $1}