cvs commit: fptools/ghc/compiler HsVersions.h Makefile
fptools/ghc/compiler/basicTypes Literal.lhs RdrName.lhs SrcLoc.lhs
fptools/ghc/compiler/coreSyn
CoreLint.lhs MkExternalCore.lhs fptools/ghc/compiler/deSugar ...
Simon Marlow
simonmar at glass.cse.ogi.edu
Wed Dec 10 06:15:39 EST 2003
simonmar 2003/12/10 06:15:38 PST
Modified files:
ghc/compiler HsVersions.h Makefile
ghc/compiler/basicTypes Literal.lhs RdrName.lhs SrcLoc.lhs
ghc/compiler/codeGen CgCon.lhs
ghc/compiler/coreSyn CoreLint.lhs MkExternalCore.lhs
ghc/compiler/deSugar Check.lhs Desugar.lhs DsArrows.lhs
DsBinds.lhs DsCCall.lhs DsExpr.hi-boot-5
DsExpr.hi-boot-6 DsExpr.lhs DsForeign.lhs
DsGRHSs.lhs DsListComp.lhs DsMeta.hs
DsMonad.lhs DsUtils.lhs Match.hi-boot-5
Match.hi-boot-6 Match.lhs MatchCon.lhs
MatchLit.lhs
ghc/compiler/ghci ByteCodeAsm.lhs ByteCodeGen.lhs
InteractiveUI.hs
ghc/compiler/hsSyn Convert.lhs HsBinds.lhs HsDecls.lhs
HsExpr.hi-boot-5 HsExpr.hi-boot-6
HsExpr.lhs HsImpExp.lhs HsLit.lhs
HsPat.lhs HsSyn.lhs HsTypes.lhs
ghc/compiler/iface LoadIface.lhs TcIface.lhs
ghc/compiler/main CmdLineOpts.lhs ErrUtils.lhs HscMain.lhs
HscStats.lhs HscTypes.lhs ParsePkgConf.y
ghc/compiler/nativeGen AbsCStixGen.lhs StixPrim.lhs
ghc/compiler/parser Lexer.x ParserCore.y RdrHsSyn.lhs
ghc/compiler/rename RnBinds.lhs RnEnv.lhs RnExpr.lhs
RnHsSyn.lhs RnNames.lhs
RnSource.hi-boot-5 RnSource.hi-boot-6
RnSource.lhs RnTypes.lhs
ghc/compiler/stgSyn StgLint.lhs
ghc/compiler/typecheck Inst.lhs TcArrows.lhs TcBinds.lhs
TcClassDcl.lhs TcDefaults.lhs
TcDeriv.lhs TcEnv.lhs TcExpr.hi-boot-5
TcExpr.hi-boot-6 TcExpr.lhs
TcForeign.lhs TcGenDeriv.lhs
TcHsSyn.lhs TcHsType.lhs TcInstDcls.lhs
TcMType.lhs TcMatches.hi-boot-5
TcMatches.hi-boot-6 TcMatches.lhs
TcPat.lhs TcRnDriver.lhs TcRnMonad.lhs
TcRnTypes.lhs TcRules.lhs
TcSimplify.lhs TcSplice.hi-boot-6
TcSplice.lhs TcTyClsDecls.lhs
TcTyDecls.lhs TcUnify.lhs
ghc/compiler/types Generics.lhs
ghc/compiler/utils Bag.lhs Outputable.lhs Pretty.lhs
Added files:
ghc/compiler/parser Parser.y.pp
Removed files:
ghc/compiler/parser Parser.y
Log:
Add accurate source location annotations to HsSyn
-------------------------------------------------
Every syntactic entity in HsSyn is now annotated with a SrcSpan, which
details the exact beginning and end points of that entity in the
original source file. All honest compilers should do this, and it was
about time GHC did the right thing.
The most obvious benefit is that we now have much more accurate error
messages; when running GHC inside emacs for example, the cursor will
jump to the exact location of an error, not just a line somewhere
nearby. We haven't put a huge amount of effort into making sure all
the error messages are accurate yet, so there could be some tweaking
still needed, although the majority of messages I've seen have been
spot-on.
Error messages now contain a column number in addition to the line
number, eg.
read001.hs:25:10: Variable not in scope: `+#'
To get the full text span info, use the new option -ferror-spans. eg.
read001.hs:25:10-11: Variable not in scope: `+#'
I'm not sure whether we should do this by default. Emacs won't
understand the new error format, for one thing.
In a more elaborate editor setting (eg. Visual Studio), we can arrange
to actually highlight the subexpression containing an error. Eventually
this information will be used so we can find elements in the abstract
syntax corresponding to text locations, for performing high-level editor
functions (eg. "tell me the type of this expression I just highlighted").
Performance of the compiler doesn't seem to be adversely affected.
Parsing is still quicker than in 6.0.1, for example.
Implementation:
This was an excrutiatingly painful change to make: both Simon P.J. and
myself have been working on it for the last three weeks or so. The
basic changes are:
- a new datatype SrcSpan, which represents a beginning and end position
in a source file.
- To reduce the pain as much as possible, we also defined:
data Located e = L SrcSpan e
- Every datatype in HsSyn has an equivalent Located version. eg.
type LHsExpr id = Located (HsExpr id)
and pretty much everywhere we used to use HsExpr we now use
LHsExpr. Believe me, we thought about this long and hard, and
all the other options were worse :-)
Additional changes/cleanups we made at the same time:
- The abstract syntax for bindings is now less arcane. MonoBinds
and HsBinds with their built-in list constructors have gone away,
replaced by HsBindGroup and HsBind (see HsSyn/HsBinds.lhs).
- The various HsSyn type synonyms have now gone away (eg. RdrNameHsExpr,
RenamedHsExpr, and TypecheckedHsExpr are now HsExpr RdrName,
HsExpr Name, and HsExpr Id respectively).
- Utilities over HsSyn are now collected in a new module HsUtils.
More stuff still needs to be moved in here.
- MachChar now has a real Char instead of an Int. All GHC versions that
can compile GHC now support 32-bit Chars, so this was a simplification.
Revision Changes Path
1.31 +6 -0 fptools/ghc/compiler/HsVersions.h
1.256 +11 -6 fptools/ghc/compiler/Makefile
1.45 +7 -7 fptools/ghc/compiler/basicTypes/Literal.lhs
1.28 +2 -2 fptools/ghc/compiler/basicTypes/RdrName.lhs
1.26 +247 -19 fptools/ghc/compiler/basicTypes/SrcLoc.lhs
1.45 +3 -1 fptools/ghc/compiler/codeGen/CgCon.lhs
1.74 +3 -3 fptools/ghc/compiler/coreSyn/CoreLint.lhs
1.25 +1 -3 fptools/ghc/compiler/coreSyn/MkExternalCore.lhs
1.34 +85 -82 fptools/ghc/compiler/deSugar/Check.lhs
1.67 +28 -31 fptools/ghc/compiler/deSugar/Desugar.lhs
1.9 +94 -101 fptools/ghc/compiler/deSugar/DsArrows.lhs
1.53 +40 -30 fptools/ghc/compiler/deSugar/DsBinds.lhs
1.68 +1 -1 fptools/ghc/compiler/deSugar/DsCCall.lhs
1.3 +3 -2 fptools/ghc/compiler/deSugar/DsExpr.hi-boot-5
1.3 +3 -2 fptools/ghc/compiler/deSugar/DsExpr.hi-boot-6
1.104 +136 -160 fptools/ghc/compiler/deSugar/DsExpr.lhs
1.82 +6 -6 fptools/ghc/compiler/deSugar/DsForeign.lhs
1.33 +20 -17 fptools/ghc/compiler/deSugar/DsGRHSs.lhs
1.46 +51 -53 fptools/ghc/compiler/deSugar/DsListComp.lhs
1.49 +220 -249 fptools/ghc/compiler/deSugar/DsMeta.hs
1.52 +17 -14 fptools/ghc/compiler/deSugar/DsMonad.lhs
1.75 +39 -30 fptools/ghc/compiler/deSugar/DsUtils.lhs
1.5 +2 -2 fptools/ghc/compiler/deSugar/Match.hi-boot-5
1.3 +2 -2 fptools/ghc/compiler/deSugar/Match.hi-boot-6
1.65 +43 -40 fptools/ghc/compiler/deSugar/Match.lhs
1.18 +3 -2 fptools/ghc/compiler/deSugar/MatchCon.lhs
1.35 +10 -10 fptools/ghc/compiler/deSugar/MatchLit.lhs
1.9 +2 -1 fptools/ghc/compiler/ghci/ByteCodeAsm.lhs
1.101 +3 -3 fptools/ghc/compiler/ghci/ByteCodeGen.lhs
1.162 +1 -9 fptools/ghc/compiler/ghci/InteractiveUI.hs
1.42 +121 -121 fptools/ghc/compiler/hsSyn/Convert.lhs
1.71 +120 -184 fptools/ghc/compiler/hsSyn/HsBinds.lhs
1.101 +131 -108 fptools/ghc/compiler/hsSyn/HsDecls.lhs
1.9 +7 -5 fptools/ghc/compiler/hsSyn/HsExpr.hi-boot-5
1.4 +5 -2 fptools/ghc/compiler/hsSyn/HsExpr.hi-boot-6
1.89 +179 -221 fptools/ghc/compiler/hsSyn/HsExpr.lhs
1.23 +9 -6 fptools/ghc/compiler/hsSyn/HsImpExp.lhs
1.14 +2 -2 fptools/ghc/compiler/hsSyn/HsLit.lhs
1.43 +72 -57 fptools/ghc/compiler/hsSyn/HsPat.lhs
1.44 +61 -76 fptools/ghc/compiler/hsSyn/HsSyn.lhs
1.77 +82 -56 fptools/ghc/compiler/hsSyn/HsTypes.lhs
1.7 +2 -2 fptools/ghc/compiler/iface/LoadIface.lhs
1.11 +1 -1 fptools/ghc/compiler/iface/TcIface.lhs
1.183 +6 -1 fptools/ghc/compiler/main/CmdLineOpts.lhs
1.43 +38 -47 fptools/ghc/compiler/main/ErrUtils.lhs
1.190 +16 -17 fptools/ghc/compiler/main/HscMain.lhs
1.12 +23 -20 fptools/ghc/compiler/main/HscStats.lhs
1.108 +2 -2 fptools/ghc/compiler/main/HscTypes.lhs
1.17 +14 -13 fptools/ghc/compiler/main/ParsePkgConf.y
1.59 +3 -1 fptools/ghc/compiler/nativeGen/AbsCStixGen.lhs
1.94 +3 -2 fptools/ghc/compiler/nativeGen/StixPrim.lhs
1.20 +120 -125 fptools/ghc/compiler/parser/Lexer.x
1.17 +24 -20 fptools/ghc/compiler/parser/ParserCore.y
1.61 +414 -460 fptools/ghc/compiler/parser/RdrHsSyn.lhs
1.90 +128 -134 fptools/ghc/compiler/rename/RnBinds.lhs
1.172 +96 -85 fptools/ghc/compiler/rename/RnEnv.lhs
1.127 +249 -228 fptools/ghc/compiler/rename/RnExpr.lhs
1.76 +33 -59 fptools/ghc/compiler/rename/RnHsSyn.lhs
1.153 +53 -49 fptools/ghc/compiler/rename/RnNames.lhs
1.13 +5 -7 fptools/ghc/compiler/rename/RnSource.hi-boot-5
1.7 +4 -4 fptools/ghc/compiler/rename/RnSource.hi-boot-6
1.163 +170 -156 fptools/ghc/compiler/rename/RnSource.lhs
1.23 +139 -104 fptools/ghc/compiler/rename/RnTypes.lhs
1.45 +6 -5 fptools/ghc/compiler/stgSyn/StgLint.lhs
1.131 +57 -41 fptools/ghc/compiler/typecheck/Inst.lhs
1.6 +56 -53 fptools/ghc/compiler/typecheck/TcArrows.lhs
1.121 +209 -145 fptools/ghc/compiler/typecheck/TcBinds.lhs
1.138 +95 -98 fptools/ghc/compiler/typecheck/TcClassDcl.lhs
1.32 +10 -9 fptools/ghc/compiler/typecheck/TcDefaults.lhs
1.123 +36 -31 fptools/ghc/compiler/typecheck/TcDeriv.lhs
1.126 +39 -16 fptools/ghc/compiler/typecheck/TcEnv.lhs
1.10 +8 -6 fptools/ghc/compiler/typecheck/TcExpr.hi-boot-5
1.6 +6 -6 fptools/ghc/compiler/typecheck/TcExpr.hi-boot-6
1.162 +129 -111 fptools/ghc/compiler/typecheck/TcExpr.lhs
1.65 +26 -33 fptools/ghc/compiler/typecheck/TcForeign.lhs
1.102 +315 -368 fptools/ghc/compiler/typecheck/TcGenDeriv.lhs
1.95 +225 -325 fptools/ghc/compiler/typecheck/TcHsSyn.lhs
1.8 +118 -110 fptools/ghc/compiler/typecheck/TcHsType.lhs
1.166 +39 -39 fptools/ghc/compiler/typecheck/TcInstDcls.lhs
1.54 +5 -4 fptools/ghc/compiler/typecheck/TcMType.lhs
1.10 +6 -7 fptools/ghc/compiler/typecheck/TcMatches.hi-boot-5
1.7 +4 -5 fptools/ghc/compiler/typecheck/TcMatches.hi-boot-6
1.80 +77 -83 fptools/ghc/compiler/typecheck/TcMatches.lhs
1.93 +47 -42 fptools/ghc/compiler/typecheck/TcPat.lhs
1.54 +63 -60 fptools/ghc/compiler/typecheck/TcRnDriver.lhs
1.29 +48 -20 fptools/ghc/compiler/typecheck/TcRnMonad.lhs
1.33 +21 -17 fptools/ghc/compiler/typecheck/TcRnTypes.lhs
1.48 +15 -15 fptools/ghc/compiler/typecheck/TcRules.lhs
1.126 +37 -32 fptools/ghc/compiler/typecheck/TcSimplify.lhs
1.6 +5 -6 fptools/ghc/compiler/typecheck/TcSplice.hi-boot-6
1.30 +27 -24 fptools/ghc/compiler/typecheck/TcSplice.lhs
1.105 +62 -55 fptools/ghc/compiler/typecheck/TcTyClsDecls.lhs
1.94 +14 -6 fptools/ghc/compiler/typecheck/TcTyDecls.lhs
1.53 +4 -3 fptools/ghc/compiler/typecheck/TcUnify.lhs
1.33 +50 -52 fptools/ghc/compiler/types/Generics.lhs
1.12 +34 -31 fptools/ghc/compiler/utils/Bag.lhs
1.57 +4 -36 fptools/ghc/compiler/utils/Outputable.lhs
1.28 +19 -1 fptools/ghc/compiler/utils/Pretty.lhs
More information about the Cvs-ghc
mailing list