Changeset 20
- 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 924 924 \begin{lstlisting} 925 925 type 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 (追記ここまで) (), 929 929 ... 930 930 } 931 931 932 genWhileC :: GenOps -> Expression -> Statement -> CodeGen (削除) (削除ここまで)()932 genWhileC :: GenOps -> Expression -> Statement -> CodeGen(追記) M (追記ここまで) () 933 933 genWhileC ops exp body 934 934 = do tell ["while ("] … … 943 943 \begin{lstlisting} 944 944 type 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 (), 947 948 ... 948 949 } 949 950 950 genWhileC ops exp body 951 = do tell ["while("] 952 genExpression ops ops exp 953 tell [")"] 954 genStatement ops ops body 955 956 testgenWhile = (assertEqual "testgenWhile") "while(X)Y" 951 testgenWhile = (assertEqual "testgenWhile") "while(@@@)$$$" 957 952 (runCodeGen (genWhileC whileOps undefined undefined)) 958 953 where 959 whileOps = GenOps { genExpression = (\_ _ -> tell [" (削除) X (削除ここまで)"]),960 genStatement = (\_ _ -> tell [" (削除) Y (削除ここまで)"]) }954 whileOps = GenOps { genExpression = (\_ _ -> tell ["(追記) @@@ (追記ここまで)"]), 955 genStatement = (\_ _ -> tell ["(追記) $$$ (追記ここまで)"]) } 961 956 \end{lstlisting} 962 957 \end{frame}
Note:
See TracChangeset
for help on using the changeset viewer.