Context Navigation


Changeset 20


Ignore:
Timestamp:
Nov 23, 2007, 1:03:07 AM (18 years ago)
Author:
neil.c.c.brown
Message:

Changed the CodeGen stuff in the backend examples to be CodeGenM (to match earlier monad mention), trimmed down the example code, and put back my special symbols in the tests (in my opinion, it's important that they be things that won't occur in C, and I don't think it makes the slide confusing)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/trunk/200711-tock-seminars/200711-tock-slides.tex

    r19 r20
    924924\begin{lstlisting}
    925925type GenOps = GenOps { ...
    926 genWhile :: GenOps -> Expression -> Statement -> CodeGen(削除) (削除ここまで) (),
    927 genExpression :: GenOps -> Expression -> CodeGen(削除) (削除ここまで) (),
    928 genStatement :: GenOps -> Statement -> CodeGen(削除) (削除ここまで) (),
    926 genWhile :: GenOps -> Expression -> Statement -> CodeGen(追記) M (追記ここまで) (),
    927 genExpression :: GenOps -> Expression -> CodeGen(追記) M (追記ここまで) (),
    928 genStatement :: GenOps -> Statement -> CodeGen(追記) M (追記ここまで) (),
    929929 ...
    930930}
    931931
    932genWhileC :: GenOps -> Expression -> Statement -> CodeGen(削除) (削除ここまで) ()
    932genWhileC :: GenOps -> Expression -> Statement -> CodeGen(追記) M (追記ここまで) ()
    933933genWhileC ops exp body
    934934 = do tell ["while ("]
    943943\begin{lstlisting}
    944944type GenOps = GenOps { ...
    945 genExpression :: GenOps -> Expression -> CodeGen (),
    946 genStatement :: GenOps -> Statement -> CodeGen (),
    945 genWhile :: GenOps -> Expression -> Statement -> CodeGenM (),
    946 genExpression :: GenOps -> Expression -> CodeGenM (),
    947 genStatement :: GenOps -> Statement -> CodeGenM (),
    947948 ...
    948949}
    949950
    950genWhileC ops exp body
    951 = do tell ["while("]
    952 genExpression ops ops exp
    953 tell [")"]
    954 genStatement ops ops body
    955
    956testgenWhile = (assertEqual "testgenWhile") "while(X)Y"
    951testgenWhile = (assertEqual "testgenWhile") "while(@@@)$$$"
    957952 (runCodeGen (genWhileC whileOps undefined undefined))
    958953 where
    959 whileOps = GenOps { genExpression = (\_ _ -> tell ["(削除) X (削除ここまで)"]),
    960 genStatement = (\_ _ -> tell ["(削除) Y (削除ここまで)"]) }
    954 whileOps = GenOps { genExpression = (\_ _ -> tell ["(追記) @@@ (追記ここまで)"]),
    955 genStatement = (\_ _ -> tell ["(追記) $$$ (追記ここまで)"]) }
    961956\end{lstlisting}
    962957\end{frame}
Note: See TracChangeset for help on using the changeset viewer.

AltStyle によって変換されたページ (->オリジナル) /