Commit Graph

506 Commits

Author SHA1 Message Date
Neil Brown
849a41fcdd Where head is used (in this case on csMainLocals), protected it with a condition so that it gives a more useful error message than simply head: empty list 2007-08-22 11:07:56 +00:00
Neil Brown
017cb51bd8 Corrected what appeared to be a small bug in defineNonce 2007-08-22 10:55:57 +00:00
Neil Brown
262913fabd Rain: added parsing of output statements 2007-08-22 10:21:20 +00:00
Neil Brown
a39d95add4 Rain: refactored the parser a little (drawing out the each loops) 2007-08-22 10:14:51 +00:00
Neil Brown
005066e3d4 Rain: correcting numbering on some of the parse tests 2007-08-22 10:14:05 +00:00
Neil Brown
ce84ae3db6 Rain: added parsing of all the integer types (along with associated tests) 2007-08-22 10:04:21 +00:00
Neil Brown
7e51ad1b1c Started using the stopCaringPattern function to easily use assertPatternMatch (which pretty-prints its output) instead of assertEqual (which just uses Show) 2007-08-22 09:44:56 +00:00
Neil Brown
d514d40943 Changed the Rain parser to use the new LexRain tokens
This is similar (but not identical) to the change Adam was doing at the same type for occam.
I think the main difference is that rather than returning () from parsing a reserved word,
I return Meta so that you can easily write rules like:
  do { m <- sSemiColon ; return $ A.Skip m}

The tests have also been updated to use the new parser, and fail on either a lexing or a
parsing error.
2007-08-22 09:41:08 +00:00
Neil Brown
b1469fa65b Added LexRain, based heavily on (a slightly older version of) LexOccam 2007-08-22 09:37:27 +00:00
Neil Brown
1890b281fe Rain: moved the resolution of int (to a 64-bit signed integer) out to a pass 2007-08-21 11:00:41 +00:00
Neil Brown
5b19a7658f Rain: added support for parsing channel-end types 2007-08-21 10:53:07 +00:00
Neil Brown
2c26a8eab8 Rain: wrote some tests for parsing channel-end types 2007-08-21 10:47:52 +00:00
Neil Brown
a1ba7b3ef6 Added a useful function to TreeUtil that allows you to replace a given sub-pattern of a Pattern with the DontCare value 2007-08-21 18:32:25 +00:00
Neil Brown
16177f1153 Added better Eq implementation for Pattern, taking account of the poor Eq implementation of Constr 2007-08-21 18:31:39 +00:00
Adam Sampson
51ecf04a90 Move assignment simplification into a pass.
This is the code that expands array and record assignments out into multiple
assignments. Having it done as a pass means it can do a better job -- this
fixes some problems with cgtest56 where the old version of the code couldn't
handle record assignments from literals.

This is the first pass that's had to add a replicator to the tree, so this also
introduces a helper function for generating new replicator counters.
2007-08-22 19:55:52 +00:00
Adam Sampson
15a8f95647 Use show rather than pshow on CompState.
CompState now contains Sets and Maps, which aren't instances of Data and thus
break pshow. This could be fixed in the future by providing instance
definitions, assuming the GHC library maintainers don't beat us to it.
2007-08-22 19:18:26 +00:00
Adam Sampson
9829183a7a Apply unique naming to unscoped names too.
This means that field names end up as "foo_u123" rather than "foo" in the
generated source -- which is a good thing, because some of the cgtests use
field names like "bool" and "int".
2007-08-22 16:41:03 +00:00
Adam Sampson
95e01e54d5 Make underlyingType merge array dimensions.
This fixes a bug that cgtest56 exposed, where an array of a user-defined type
that was itself an array wound up being an array of arrays rather than a single
array.

As part of this, makeArrayType is now called addDimensions, and takes a list of
dimensions to add rather than just one.
2007-08-22 15:00:54 +00:00
Adam Sampson
01929b3f35 Fix handling of array-of-record literals.
isValidLiteralType was a bit too simplistic before; it needs to look at array
types one dimension at a time rather than trying to do the whole lot at once.
2007-08-22 12:55:41 +00:00
Adam Sampson
da89323dbc Rename Parse to ParseOccam. 2007-08-22 01:59:51 +00:00
Adam Sampson
e17db34eb6 Some Haddock tweaks. 2007-08-22 01:43:52 +00:00
Adam Sampson
95001681d4 Tidy up comments in AST.
This also makes the show instance for types print UINT32 etc. for the types
Neil's added, since that'd be the likely syntax for them in occam.
2007-08-22 01:40:51 +00:00
Neil Brown
96f6bc39fd Added a signed 8-bit type and unsigned 16-,32- and 64-bit types to the AST, adjusting all other code accordingly
The types have been added to the AST.  Beyond the obvious trivial changes (extra cases in functions, etc), the only
significant change was that isSafeConversion needed to be changed.  I took the opportunity to totally rewrite the 
function into a graph-like mechanism rather than just using a list.  To demonstrate its correctness I also wrote an
exhaustive test for it.
2007-08-21 12:43:00 +00:00
Neil Brown
3b14eec036 Added direction specifiers and further attributes (such as whether the channel is shared) to the Chan type in the AST 2007-08-21 10:35:18 +00:00
Adam Sampson
dfefcdfd41 Refactor AnalyseAsm to use a state monad.
This makes the code quite a bit cleaner, and since it can keep track of which
functions it's already analysed it goes a lot quicker on big files.
2007-08-22 00:11:20 +00:00
Adam Sampson
6f00d4f4a7 Make the label regex more specific.
This makes it only generate legal labels in the .post.c file.
2007-08-21 22:19:54 +00:00
Adam Sampson
bd44a1c748 Add a few bytes of stack to every function.
This also makes sure that every function gets a stack size constant.

There are some functions which don't do any stack adjustment -- where GCC's
smart enough to just compile them to a "ret" (because it knows it needs a
function pointer, but also that the function does nothing). CCSP doesn't like
it when you ask for a stack size of 0; I haven't yet investigated why, but this is likely to change anyway once Carl's changes go into CCSP trunk.
2007-08-21 22:06:21 +00:00
Adam Sampson
10b0b556d2 Update the Makefile for the new cgtests branch. 2007-08-21 21:36:35 +00:00
Adam Sampson
87574796fb Make the lexer only recognise known preprocessor directives.
This is another one for the list of occam oddities: there are situations where
both a hex literal and a preprocessor directive are legal, so the two can't be
ambiguous -- no #FACE or #ADA in the future!
2007-08-21 21:12:44 +00:00
Adam Sampson
1bac142a53 Rework the parser to use the new lexer.
The occam parser is now a GenParser Token OccState, rather than a GenParser
Char OccState, and a lot of now-redundant code has been removed. The parser is
also somewhat faster, which wasn't intended but is nice anyway.

I've also modified the Rain parser to not rely on the old preprocessing code;
it wasn't appropriate for Rain's syntax anyway, so I assume Neil will be
replacing it eventually.
2007-08-21 20:44:15 +00:00
Adam Sampson
1f490e9f7f Lex multiline strings as multiple tokens.
This is because the structure pass needs to be able to tell where new lines
start, and if the line number changes in the middle of a token then it'll get
confused.
2007-08-21 20:01:46 +00:00
Adam Sampson
3fb0cf088f Implement continuation line rules. 2007-08-21 17:46:30 +00:00
Adam Sampson
065df28bbc Make unknown preprocessor directives a warning rather than an error.
This is what the "old" preprocessor does; it's more useful at the moment.
2007-08-21 17:27:16 +00:00
Adam Sampson
1fc6dcd0e9 Add Outdents when reaching the end of a file.
This doesn't make a difference for regular programs and headers -- but it does
for .inc files containing processes.
2007-08-21 17:25:10 +00:00
Adam Sampson
3d66a7634b Fix lexing of preprocessor directives.
This looks more complicated than it is because it meant adding state to the
lexer -- it's now quite a neat little three-state machine.

This also renames DecimalLiteral to IntLiteral to match the rest of the code.
2007-08-21 17:22:25 +00:00
Adam Sampson
d28e945574 Don't allow *s in strings that aren't escapes. 2007-08-21 17:20:10 +00:00
Neil Brown
8a3edfd2e2 Actually added Pattern.hs
This file should have been in the earlier patch at 22:01 on Mon Aug 20, but it got missed out by accident.
2007-08-21 00:44:55 +00:00
Neil Brown
66eddfa672 Rain: added some tests for parsing data types 2007-08-20 22:39:58 +00:00
Neil Brown
6afbb5ecf4 Rain: changed the top-level parser from the dummy value to the proper value (topLevelDecl) 2007-08-20 22:37:47 +00:00
Neil Brown
43c3ae4aa7 Rain: added the parsing of top-level declarations (and tuple definitions) 2007-08-20 22:08:24 +00:00
Neil Brown
eb4a629d57 Rain: Fixed the meta tags for each part of a block 2007-08-20 22:07:58 +00:00
Neil Brown
923eefe317 Rain: refactored the parsing of blocks 2007-08-20 22:06:56 +00:00
Neil Brown
eee8ce2492 Rain: Corrected the parse tests for the top level declaration 2007-08-20 21:54:46 +00:00
Neil Brown
1213661b36 Added some helper functions for creating simple Patterns to TestUtil 2007-08-20 21:53:24 +00:00
Neil Brown
3e0b781b88 Added better pretty-printing for list Patterns, with a special case for strings that prints them out nicely 2007-08-20 21:35:19 +00:00
Neil Brown
391890faa7 Moved TreeUtil.Pattern to its own module (Pattern), which allowed me to show the pshowPattern function to be part of the PrettyShow.pshow function 2007-08-20 21:01:06 +00:00
Adam Sampson
223a14d767 Add a preprocessor that works with the new lexer.
The parser now gets a stream of tokens, rather than needing to worry about
loading files itself.

This also reworks the lexer's idea of what constitutes a Token -- it's now a
pair (Meta, TokenType), so it's always easy to pull out/rewrite the metadata --
and adds proper support for lexing preprocessor directives, rather than just
treating them as reserved words.
2007-08-20 23:46:57 +00:00
Adam Sampson
a640dabc04 Don't Haddock LexOccam.hs.
I think Haddock doesn't like the GHC preprocessor directives that Alex
generates, so just ignore the lexer source for now.
2007-08-20 23:44:47 +00:00
Adam Sampson
f95bcf6411 Tweak some Haddock syntax. 2007-08-20 23:44:10 +00:00
Neil Brown
30816b60ac On Adam's suggestion, renamed the occam 2.1 frontend to simply occam 2007-08-20 22:37:21 +00:00