summaryrefslogtreecommitdiff
path: root/compiler/parser/Lexer.x
Commit message (Collapse)AuthorAgeFilesLines
...
* * Refactor CLabel.RtsLabel to CLabel.CmmLabelBen.Lippmeier@anu.edu.au2009-11-061-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The type of the CmmLabel ctor is now CmmLabel :: PackageId -> FastString -> CmmLabelInfo -> CLabel - When you construct a CmmLabel you have to explicitly say what package it is in. Many of these will just use rtsPackageId, but I've left it this way to remind people not to pretend labels are in the RTS package when they're not. - When parsing a Cmm file, labels that are not defined in the current file are assumed to be in the RTS package. Labels imported like import label are assumed to be in a generic "foreign" package, which is different from the current one. Labels imported like import "package-name" label are marked as coming from the named package. This last one is needed for the integer-gmp library as we want to refer to labels that are not in the same compilation unit, but are in the same non-rts package. This should help remove the nasty #ifdef __PIC__ stuff from integer-gmp/cbits/gmp-wrappers.cmm
* Comments and variable naming onlysimonpj@microsoft.com2009-10-291-3/+3
|
* Add 'rec' to stmts in a 'do', and deprecate 'mdo'simonpj@microsoft.com2009-10-281-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change is this (see Trac #2798). Instead of writing mdo { a <- getChar ; b <- f c ; c <- g b ; putChar c ; return b } you would write do { a <- getChar ; rec { b <- f c ; c <- g b } ; putChar c ; return b } That is, * 'mdo' is eliminated * 'rec' is added, which groups a bunch of statements into a single recursive statement This 'rec' thing is already present for the arrow notation, so it makes the two more uniform. Moreover, 'rec' lets you say more precisely where the recursion is (if you want to), whereas 'mdo' just says "there's recursion here somewhere". Lastly, all this works with rebindable syntax (which mdo does not). Currently 'mdo' is enabled by -XRecursiveDo. So we now deprecate this flag, with another flag -XDoRec to enable the 'rec' keyword. Implementation notes: * Some changes in Lexer.x * All uses of RecStmt now use record syntax I'm still not really happy with the "rec_ids" and "later_ids" in the RecStmt constructor, but I don't dare change it without consulting Ross about the consequences for arrow syntax.
* Add flag -XExplicitForAll and document itsimonpj@microsoft.com2009-10-071-20/+15
| | | | | | | | | | | | | This implements the Haskell Prime proposal http://hackage.haskell.org/trac/haskell-prime/wiki/ExplicitForall Flag is -XExplicitForAll Implied by Opt_RankNTypes, Opt_Rank2Types, Opt_ScopedTypeVariables, Opt_LiberalTypeSynonyms, Opt_ExistentialQuantification, Opt_PolymorphicComponents
* Three improvements to Template Haskell (fixes #3467)simonpj@microsoft.com2009-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements three significant improvements to Template Haskell. Declaration-level splices with no "$" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This change simply allows you to omit the "$(...)" wrapper for declaration-level TH splices. An expression all by itself is not legal, so we now treat it as a TH splice. Thus you can now say data T = T1 | T2 deriveMyStuff ''T where deriveMyStuff :: Name -> Q [Dec] This makes a much nicer interface for clients of libraries that use TH: no scary $(deriveMyStuff ''T). Nested top-level splices ~~~~~~~~~~~~~~~~~~~~~~~~ Previously TH would reject this, saying that splices cannot be nested: f x = $(g $(h 'x)) But there is no reason for this not to work. First $(h 'x) is run, yielding code <blah> that is spliced instead of the $(h 'x). Then (g <blah>) is typechecked and run, yielding code that replaces the $(g ...) splice. So this simply lifts the restriction. Fix Trac #3467: non-top-level type splices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It appears that when I added the ability to splice types in TH programs, I failed to pay attention to non-top-level splices -- that is, splices inside quotatation brackets. This patch fixes the problem. I had to modify HsType, so there's a knock-on change to Haddock. Its seems that a lot of lines of code has changed, but almost all the new lines are comments! General tidying up ~~~~~~~~~~~~~~~~~~ As a result of thinking all this out I re-jigged the data type ThStage, which had far too many values before. And I wrote a nice state transition diagram to make it all precise; see Note [Template Haskell state diagram] in TcSplice Lots more refactoring in TcSplice, resulting in significantly less code. (A few more lines, but actually less code -- the rest is comments.) I think the result is significantly cleaner.
* Remove unused data constructor ITpragma in type Lexer.Tokensimonpj@microsoft.com2009-09-051-2/+0
|
* Remove old 'foreign import dotnet' codeSimon Marlow2009-07-271-2/+0
| | | | It still lives in darcs, if anyone wants to revive it sometime.
* Add an extension to disable n+k patternsIan Lynagh2009-07-251-0/+4
|
* Remove GHC's haskell98 dependencyIan Lynagh2009-07-241-1/+1
|
* Allow mixed case in the LINE pragma; patch from squadette; fixes #1817Ian Lynagh2009-07-171-12/+10
|
* Remove maybePrefixMatch, using stripPrefix insteadIan Lynagh2009-07-091-2/+2
| | | | | We already require GHC 6.8 to build, and that included stripPrefix in Data.List.
* Allow mixed case pragmas; #1817. Patch from squadetteIan Lynagh2009-07-091-51/+72
| | | | | This patch allow you to use "Language CPP", or even "LaNgUaGe CPP", if you wish, as the manual claims you can.
* White space onlysimonpj@microsoft.com2009-07-021-3/+3
|
* Lexing and parsing for "foreign import prim"Duncan Coutts2009-06-091-0/+3
| | | | | We only allow simple function label imports, not the normal complicated business with "wrapper" "dynamic" or data label "&var" imports.
* Deprecate the threadsafe kind of foreign importDuncan Coutts2009-06-111-1/+1
|
* remove old todo commentSimon Marlow2009-05-201-1/+0
|
* Hide warnings from alex/happy sourcesIan Lynagh2009-05-141-1/+1
|
* Fix some warnings in LexerIan Lynagh2009-05-131-14/+88
|
* Require a bang pattern when unlifted types are where/let bound; #3182Ian Lynagh2009-04-241-1/+1
| | | | | For now we only get a warning, rather than an error, because the alex and happy templates don't follow the new rules yet.
* Fix Trac #3155: better error message when -XRankNTypes is omittedsimonpj@microsoft.com2009-04-091-2/+2
| | | | | | | | | | | | | | | | | | | | | This patch sligtly re-adjusts the way in which the syntax of types is handled: * In the lexer, '.' and '*' are always accepted in types (previously it was conditional). This things can't mean anything else in H98, which is the only reason for doing things conditionally in the lexer. * As a result '.' in types is never treated as an operator. Instead, lacking a 'forall' keyword, it turns into a plain parse error. * Test for -XKindSignatures in the renamer when processing a) type variable bindings b) types with sigs (ty :: kind-sig) * Make -XKindSignatures be implied by -XTypeFamilies Previously this was buried in the conditonal lexing of '*'
* Add the notion of "constructor-like" Ids for rule-matchingsimonpj@microsoft.com2009-03-181-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds an optional CONLIKE modifier to INLINE/NOINLINE pragmas, {-# NOINLINE CONLIKE [1] f #-} The effect is to allow applications of 'f' to be expanded in a potential rule match. Example {-# RULE "r/f" forall v. r (f v) = f (v+1) #-} Consider the term let x = f v in ..x...x...(r x)... Normally the (r x) would not match the rule, because GHC would be scared about duplicating the redex (f v). However the CONLIKE modifier says to treat 'f' like a constructor in this situation, and "look through" the unfolding for x. So (r x) fires, yielding (f (v+1)). The main changes are: - Syntax - The inlinePragInfo field of an IdInfo has a RuleMatchInfo component, which records whether or not the Id is CONLIKE. Of course, this needs to be serialised in interface files too. - The occurrence analyser (OccAnal) and simplifier (Simplify) treat CONLIKE thing like constructors, by ANF-ing them - New function coreUtils.exprIsExpandable is like exprIsCheap, but additionally spots applications of CONLIKE functions - A CoreUnfolding has a field that caches exprIsExpandable - The rule matcher consults this field. See Note [Expanding variables] in Rules.lhs. On the way I fixed a lurking variable bug in the way variables are expanded. See Note [Do not expand locally-bound variables] in Rule.lhs. I also did a bit of reformatting and refactoring in Rules.lhs, so the module has more lines changed than are really different.
* Add CONTRACT to the pragmas that we recognise.Ian Lynagh2009-03-061-1/+1
| | | | It's used by ESC/Haskell.
* Fix Trac #2931simonpj@microsoft.com2009-01-131-1/+1
| | | | | | Fix the lexical analyser when it encounters 'x<EOF> and Template Haskell is on.
* Add OPTIONS_CATCH,DERIVE,YHC to those that GHC knows about; trac #2847Ian Lynagh2008-12-091-1/+1
|
* Parse pragma names better; trac #2847Ian Lynagh2008-12-091-21/+36
| | | | | | We require that pragma names are not followed by pragma character, defined as isAlphaNum c || c == '_'
* Remove a CPP test that's always true (__GLASGOW_HASKELL__ >= 605)Ian Lynagh2008-11-081-2/+0
|
* Remove the GHC 6.4 unicode compat stuff; we can now just use Data.CharIan Lynagh2008-11-081-3/+1
|
* Add (a) CoreM monad, (b) new Annotations featuresimonpj@microsoft.com2008-10-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch, written by Max Bolingbroke, does two things 1. It adds a new CoreM monad (defined in simplCore/CoreMonad), which is used as the top-level monad for all the Core-to-Core transformations (starting at SimplCore). It supports * I/O (for debug printing) * Unique supply * Statistics gathering * Access to the HscEnv, RuleBase, Annotations, Module The patch therefore refactors the top "skin" of every Core-to-Core pass, but does not change their functionality. 2. It adds a completely new facility to GHC: Core "annotations". The idea is that you can say {#- ANN foo (Just "Hello") #-} which adds the annotation (Just "Hello") to the top level function foo. These annotations can be looked up in any Core-to-Core pass, and are persisted into interface files. (Hence a Core-to-Core pass can also query the annotations of imported things.) Furthermore, a Core-to-Core pass can add new annotations (eg strictness info) of its own, which can be queried by importing modules. The design of the annotation system is somewhat in flux. It's designed to work with the (upcoming) dynamic plug-ins mechanism, but is meanwhile independently useful. Do not merge to 6.10!
* Fix trac #2687Ian Lynagh2008-10-151-3/+3
| | | | | OtherPunctuation, ConnectorPunctuation and DashPunctuation are now treated as symbols, rather than merely graphic characters.
* Fix Trac #2497; two separate typos in Lexer.xsimonpj@microsoft.com2008-10-151-2/+2
| | | | | | The patch to switch on lexing of 'forall' inside a RULES pragma wasn't working. This fixes it so that it does.
* add -XNewQualifiedOperators (Haskell' qualified operator syntax)Simon Marlow2008-09-221-13/+36
|
* RichTokenStream supportChaddai Fouche2008-09-181-17/+41
| | | | | | | | | | | | | | | | | | | | | | This patch adds support for raw token streams, that contain more information than normal token streams (they contains comments at least). The "lexTokenStream" function brings this support to the Lexer module. In addition to that, functions have been added to the GHC module to make easier to recover of the token stream of a module ("getTokenStream"). Building on that, I added what could be called "rich token stream": token stream to which have been added the source string corresponding to each token, the function addSourceToToken takes a StringBuffer and a starting SrcLoc and a token stream and build this rich token stream. getRichTokenStream is a convenience function to get a module rich token stream. "showRichTokenStream" use the SrcLoc information in such a token stream to get a string similar to the original source (except unsignificant whitespaces). Thus "putStrLn . showRichTokenStream =<< getRichTokenStream s mod" should print a valid module source, the interesting part being to modify the token stream between the get and the show of course.
* Better documentation for -XLiberalTypeSynonyms, and steal forall keyword simonpj@microsoft.com2008-08-271-0/+1
| | | | | | | | | In my travels through the front end I discoverd that -XLiberalTypeSynonyms is rather thinly described. Furthermore, it alleges that you can write a forall on the RHS of a type synonym decl, so that means it should enable the forall keyword.
* always treat 'forall' and '.' as reserved keywords inside RULES pragmasSimon Marlow2008-08-201-12/+21
|
* Warn about unrecognised pragmas; these often mean we've typoedIan Lynagh2008-07-221-3/+17
|
* Fix Haddock errors.Thomas Schilling2008-07-201-1/+1
|
* Add a WARNING pragmaIan Lynagh2008-07-201-0/+3
|
* Move another flag from the Makefile into a pragmaIan Lynagh2008-07-101-0/+2
|
* Treat the Unicode "Letter, Other" class as lowercase letters (#1103)Simon Marlow2008-07-091-1/+1
| | | | | | | | | | This is an arbitrary choice, but it's strictly more useful than the current situation, where these characters cannot be used in identifiers at all. In Haskell' we may revisit this decision (it's on my list of things to discuss), but for now this is an improvement for those using caseless languages.
* Get rid of compat/Ian Lynagh2008-07-081-5/+1
| | | | | | Compat.Unicode is not utils/Unicode in the compiler. We build the hpc package with the stage1 compiler. Nothing else in the compat package was still used.
* Remove special handling for character types of characters >= 128, <= 255Ian Lynagh2008-06-211-6/+6
| | | | | Many of the character types were wrong. Now the asc* names really do mean ASCII, rather than latin-1.
* More commandline flag improvementsIan Lynagh2008-06-161-3/+3
| | | | | | | * Allow -ffoo flags to be deprecated * Mark some -ffoo flags as deprecated * Avoid using deprecated flags in error messages, in the build system, etc * Add a flag to en/disable the deprecated flag warning
* Pass dynflags down through to pragStateIan Lynagh2008-06-141-6/+4
| | | | so we no longer need to use defaultDynFlags there
* Define and use is_decdigit for lexing escapes; fixes trac #2304Ian Lynagh2008-06-131-1/+1
|
* Add 123## literals for Word#Ian Lynagh2008-04-231-1/+7
|
* Whitespace changes onlyIan Lynagh2008-04-231-9/+9
|
* (F)SLIT -> (f)sLit in LexerIan Lynagh2008-04-121-4/+2
|
* Fix Trac #2114: error reporting for 'forall' without appropriate flagssimonpj@microsoft.com2008-02-221-2/+2
|
* Fixed warnings in parser/Lexer.xTwan van Laarhoven2008-02-041-25/+32
| | | | The -w flag can not be removed, because alex also generates code with lots of warnings.
* A couple more parser tweaksIan Lynagh2008-01-251-0/+1
|