?? sec-finding-errors.html
字號:
<HTML
><HEAD
><TITLE
>Finding Type Errors</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK
REL="HOME"
TITLE="Happy User Guide"
HREF="happy.html"><LINK
REL="UP"
TITLE="Tips"
HREF="sec-tips.html"><LINK
REL="PREVIOUS"
TITLE="Compilation-Time Tips"
HREF="sec-compilation-time.html"><LINK
REL="NEXT"
TITLE="Conflict Tips"
HREF="sec-conflict-tips.html"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Happy User Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sec-compilation-time.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 6. Tips</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sec-conflict-tips.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SEC-FINDING-ERRORS"
>6.3. Finding Type Errors</A
></H1
><P
>Finding type errors in grammar files is inherently
difficult because the code for reductions is moved around before
being placed in the parser. We currently have no way of passing
the original filename and line numbers to the Haskell compiler,
so there is no alternative but to look at the parser and match
the code to the grammar file. An info file (generated by the
<TT
CLASS="LITERAL"
>-i</TT
> option) can be helpful here.</P
><P
>Type signature sometimes help by pinning down the
particular error to the place where the mistake is made, not
half way down the file. For each production in the grammar,
there's a bit of code in the generated file that looks like
this:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>HappyAbsSyn<n> ( E )</PRE
></TD
></TR
></TABLE
><P
>where <TT
CLASS="LITERAL"
>E</TT
> is the Haskell expression from the
grammar file (with <TT
CLASS="LITERAL"
>$n</TT
> replaced by
<TT
CLASS="LITERAL"
>happy_var_n</TT
>). If there is a type signature for this
production, then <SPAN
CLASS="APPLICATION"
>Happy</SPAN
> will have taken it into
account when declaring the HappyAbsSyn datatype, and errors in
<TT
CLASS="LITERAL"
>E</TT
> will be caught right here. Of course, the error may
be really caused by incorrect use of one of the
<TT
CLASS="LITERAL"
>happy_var_n</TT
> variables.</P
><P
>(this section will contain more info as we gain experience
with creating grammar files. Please send us any helpful tips
you find.)</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sec-compilation-time.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="happy.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sec-conflict-tips.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Compilation-Time Tips</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="sec-tips.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Conflict Tips</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -