Changed precedence of projection to be higher than application.

This commit is contained in:
bringert
2005-11-28 21:45:58 +00:00
parent 02c23401a7
commit 5d7bcac1e5
7 changed files with 42 additions and 42 deletions

View File

@@ -69,9 +69,9 @@ data Tree :: * -> * where
EMul :: Exp -> Exp -> Tree Exp_
EDiv :: Exp -> Exp -> Tree Exp_
EMod :: Exp -> Exp -> Tree Exp_
EProj :: Exp -> Ident -> Tree Exp_
ENeg :: Exp -> Tree Exp_
EApp :: Exp -> Exp -> Tree Exp_
EProj :: Exp -> Ident -> Tree Exp_
EEmptyRec :: Tree Exp_
ERecType :: [FieldType] -> Tree Exp_
ERec :: [FieldValue] -> Tree Exp_
@@ -132,9 +132,9 @@ composOpM f t = case t of
EMul exp0 exp1 -> return EMul `ap` f exp0 `ap` f exp1
EDiv exp0 exp1 -> return EDiv `ap` f exp0 `ap` f exp1
EMod exp0 exp1 -> return EMod `ap` f exp0 `ap` f exp1
EProj exp i -> return EProj `ap` f exp `ap` f i
ENeg exp -> return ENeg `ap` f exp
EApp exp0 exp1 -> return EApp `ap` f exp0 `ap` f exp1
EProj exp i -> return EProj `ap` f exp `ap` f i
ERecType fieldtypes -> return ERecType `ap` mapM f fieldtypes
ERec fieldvalues -> return ERec `ap` mapM f fieldvalues
EVar i -> return EVar `ap` f i
@@ -178,9 +178,9 @@ composOpFold zero combine f t = case t of
EMul exp0 exp1 -> f exp0 `combine` f exp1
EDiv exp0 exp1 -> f exp0 `combine` f exp1
EMod exp0 exp1 -> f exp0 `combine` f exp1
EProj exp i -> f exp `combine` f i
ENeg exp -> f exp
EApp exp0 exp1 -> f exp0 `combine` f exp1
EProj exp i -> f exp `combine` f i
ERecType fieldtypes -> foldr combine zero (map f fieldtypes)
ERec fieldvalues -> foldr combine zero (map f fieldvalues)
EVar i -> f i
@@ -228,9 +228,9 @@ instance Show (Tree c) where
EMul exp0 exp1 -> opar n . showString "EMul" . showChar ' ' . showsPrec 1 exp0 . showChar ' ' . showsPrec 1 exp1 . cpar n
EDiv exp0 exp1 -> opar n . showString "EDiv" . showChar ' ' . showsPrec 1 exp0 . showChar ' ' . showsPrec 1 exp1 . cpar n
EMod exp0 exp1 -> opar n . showString "EMod" . showChar ' ' . showsPrec 1 exp0 . showChar ' ' . showsPrec 1 exp1 . cpar n
EProj exp i -> opar n . showString "EProj" . showChar ' ' . showsPrec 1 exp . showChar ' ' . showsPrec 1 i . cpar n
ENeg exp -> opar n . showString "ENeg" . showChar ' ' . showsPrec 1 exp . cpar n
EApp exp0 exp1 -> opar n . showString "EApp" . showChar ' ' . showsPrec 1 exp0 . showChar ' ' . showsPrec 1 exp1 . cpar n
EProj exp i -> opar n . showString "EProj" . showChar ' ' . showsPrec 1 exp . showChar ' ' . showsPrec 1 i . cpar n
EEmptyRec -> showString "EEmptyRec"
ERecType fieldtypes -> opar n . showString "ERecType" . showChar ' ' . showsPrec 1 fieldtypes . cpar n
ERec fieldvalues -> opar n . showString "ERec" . showChar ' ' . showsPrec 1 fieldvalues . cpar n
@@ -286,9 +286,9 @@ johnMajorEq (ESub exp0 exp1) (ESub exp0_ exp1_) = exp0 == exp0_ && exp1 == exp1_
johnMajorEq (EMul exp0 exp1) (EMul exp0_ exp1_) = exp0 == exp0_ && exp1 == exp1_
johnMajorEq (EDiv exp0 exp1) (EDiv exp0_ exp1_) = exp0 == exp0_ && exp1 == exp1_
johnMajorEq (EMod exp0 exp1) (EMod exp0_ exp1_) = exp0 == exp0_ && exp1 == exp1_
johnMajorEq (EProj exp i) (EProj exp_ i_) = exp == exp_ && i == i_
johnMajorEq (ENeg exp) (ENeg exp_) = exp == exp_
johnMajorEq (EApp exp0 exp1) (EApp exp0_ exp1_) = exp0 == exp0_ && exp1 == exp1_
johnMajorEq (EProj exp i) (EProj exp_ i_) = exp == exp_ && i == i_
johnMajorEq EEmptyRec EEmptyRec = True
johnMajorEq (ERecType fieldtypes) (ERecType fieldtypes_) = fieldtypes == fieldtypes_
johnMajorEq (ERec fieldvalues) (ERec fieldvalues_) = fieldvalues == fieldvalues_
@@ -343,9 +343,9 @@ instance Ord (Tree c) where
index (EMul _ _) = 32
index (EDiv _ _) = 33
index (EMod _ _) = 34
index (EProj _ _) = 35
index (ENeg _) = 36
index (EApp _ _) = 37
index (ENeg _) = 35
index (EApp _ _) = 36
index (EProj _ _) = 37
index (EEmptyRec ) = 38
index (ERecType _) = 39
index (ERec _) = 40
@@ -395,9 +395,9 @@ instance Ord (Tree c) where
compareSame (EMul exp0 exp1) (EMul exp0_ exp1_) = mappend (compare exp0 exp0_) (compare exp1 exp1_)
compareSame (EDiv exp0 exp1) (EDiv exp0_ exp1_) = mappend (compare exp0 exp0_) (compare exp1 exp1_)
compareSame (EMod exp0 exp1) (EMod exp0_ exp1_) = mappend (compare exp0 exp0_) (compare exp1 exp1_)
compareSame (EProj exp i) (EProj exp_ i_) = mappend (compare exp exp_) (compare i i_)
compareSame (ENeg exp) (ENeg exp_) = compare exp exp_
compareSame (EApp exp0 exp1) (EApp exp0_ exp1_) = mappend (compare exp0 exp0_) (compare exp1 exp1_)
compareSame (EProj exp i) (EProj exp_ i_) = mappend (compare exp exp_) (compare i i_)
compareSame EEmptyRec EEmptyRec = EQ
compareSame (ERecType fieldtypes) (ERecType fieldtypes_) = compare fieldtypes fieldtypes_
compareSame (ERec fieldvalues) (ERec fieldvalues_) = compare fieldvalues fieldvalues_

View File

@@ -213,17 +213,17 @@ All other symbols are terminals.\\
\end{tabular}\\
\begin{tabular}{lll}
{\nonterminal{Exp8}} & {\arrow} &{\nonterminal{Exp8}} {\terminal{.}} {\nonterminal{Ident}} \\
{\nonterminal{Exp8}} & {\arrow} &{\terminal{{$-$}}} {\nonterminal{Exp8}} \\
& {\delimit} &{\nonterminal{Exp9}} \\
\end{tabular}\\
\begin{tabular}{lll}
{\nonterminal{Exp9}} & {\arrow} &{\terminal{{$-$}}} {\nonterminal{Exp9}} \\
{\nonterminal{Exp9}} & {\arrow} &{\nonterminal{Exp9}} {\nonterminal{Exp10}} \\
& {\delimit} &{\nonterminal{Exp10}} \\
\end{tabular}\\
\begin{tabular}{lll}
{\nonterminal{Exp10}} & {\arrow} &{\nonterminal{Exp10}} {\nonterminal{Exp11}} \\
{\nonterminal{Exp10}} & {\arrow} &{\nonterminal{Exp10}} {\terminal{.}} {\nonterminal{Ident}} \\
& {\delimit} &{\nonterminal{Exp11}} \\
\end{tabular}\\

File diff suppressed because one or more lines are too long

View File

@@ -203,17 +203,17 @@ Exp7 : Exp7 '*' Exp8 { EMul $1 $3 }
Exp8 :: { Exp }
Exp8 : Exp8 '.' Ident { EProj $1 $3 }
Exp8 : '-' Exp8 { ENeg $2 }
| Exp9 { $1 }
Exp9 :: { Exp }
Exp9 : '-' Exp9 { ENeg $2 }
Exp9 : Exp9 Exp10 { EApp $1 $2 }
| Exp10 { $1 }
Exp10 :: { Exp }
Exp10 : Exp10 Exp11 { EApp $1 $2 }
Exp10 : Exp10 '.' Ident { EProj $1 $3 }
| Exp11 { $1 }

View File

@@ -115,9 +115,9 @@ instance Print (Tree c) where
EMul exp0 exp1 -> prPrec _i 7 (concatD [prt 7 exp0 , doc (showString "*") , prt 8 exp1])
EDiv exp0 exp1 -> prPrec _i 7 (concatD [prt 7 exp0 , doc (showString "/") , prt 8 exp1])
EMod exp0 exp1 -> prPrec _i 7 (concatD [prt 7 exp0 , doc (showString "%") , prt 8 exp1])
EProj exp i -> prPrec _i 8 (concatD [prt 8 exp , doc (showString ".") , prt 0 i])
ENeg exp -> prPrec _i 9 (concatD [doc (showString "-") , prt 9 exp])
EApp exp0 exp1 -> prPrec _i 10 (concatD [prt 10 exp0 , prt 11 exp1])
ENeg exp -> prPrec _i 8 (concatD [doc (showString "-") , prt 8 exp])
EApp exp0 exp1 -> prPrec _i 9 (concatD [prt 9 exp0 , prt 10 exp1])
EProj exp i -> prPrec _i 10 (concatD [prt 10 exp , doc (showString ".") , prt 0 i])
EEmptyRec -> prPrec _i 11 (concatD [doc (showString "{") , doc (showString "}")])
ERecType fieldtypes -> prPrec _i 11 (concatD [doc (showString "{") , prt 0 fieldtypes , doc (showString "}")])
ERec fieldvalues -> prPrec _i 11 (concatD [doc (showString "{") , prt 0 fieldvalues , doc (showString "}")])

View File

@@ -46,9 +46,9 @@ transTree t = case t of
EMul exp0 exp1 -> failure t
EDiv exp0 exp1 -> failure t
EMod exp0 exp1 -> failure t
EProj exp i -> failure t
ENeg exp -> failure t
EApp exp0 exp1 -> failure t
EProj exp i -> failure t
EEmptyRec -> failure t
ERecType fieldtypes -> failure t
ERec fieldvalues -> failure t
@@ -119,9 +119,9 @@ transExp t = case t of
EMul exp0 exp1 -> failure t
EDiv exp0 exp1 -> failure t
EMod exp0 exp1 -> failure t
EProj exp i -> failure t
ENeg exp -> failure t
EApp exp0 exp1 -> failure t
EProj exp i -> failure t
EEmptyRec -> failure t
ERecType fieldtypes -> failure t
ERec fieldvalues -> failure t

View File

@@ -79,11 +79,11 @@ EMul. Exp7 ::= Exp7 "*" Exp8 ;
EDiv. Exp7 ::= Exp7 "/" Exp8 ;
EMod. Exp7 ::= Exp7 "%" Exp8 ;
EProj. Exp8 ::= Exp8 "." Ident ;
ENeg. Exp8 ::= "-" Exp8 ;
ENeg. Exp9 ::= "-" Exp9 ;
EApp. Exp9 ::= Exp9 Exp10 ;
EApp. Exp10 ::= Exp10 Exp11 ;
EProj. Exp10 ::= Exp10 "." Ident ;
EEmptyRec. Exp11 ::= "{" "}" ;