Neil Brown
bd26f758b4
Added tests for annotating the types of list literals and ranges in Rain
2008-03-20 14:44:19 +00:00
Neil Brown
8f51ead090
Rewrote transformRangeRep, stopping it requiring constants in ranges
2008-03-20 12:40:07 +00:00
Neil Brown
b20a7fcb0b
Fixed some tests in ParseRainTest
2008-03-20 12:39:42 +00:00
Neil Brown
1f6311d33e
Fixed a lot of tests in RainPassesTest
2008-03-20 12:38:59 +00:00
Neil Brown
ad7a76dace
Altered transformEachRange to make it more straight-forward
2008-03-20 09:36:26 +00:00
Neil Brown
b496912c51
Fixed conflicts with Adam's dimension changes
2008-03-19 17:49:32 +00:00
Neil Brown
05866457e4
Fixed the type of a range to at least be a list
2008-03-19 17:34:12 +00:00
Neil Brown
43b77ff1a0
Made names for loop variables unique in Rain, and made their abbreviation mode Abbrev
2008-03-19 17:19:58 +00:00
Neil Brown
6b04b6d944
Added a pass to pull up expressions in for-each loops into a variable
2008-03-19 17:18:56 +00:00
Neil Brown
45c2619307
Changed the rain parser to use ListLiteral for strings
2008-03-19 15:59:23 +00:00
Neil Brown
db0467f1ca
Adjusted the rain passes to use the new array constructor type, and weaned a few of them off everywhereM
2008-03-19 13:24:15 +00:00
Neil Brown
a930e17f89
Adjusted the parsers to store a type with array constructors (Rain will infer it later, so it uses Any)
2008-03-19 13:22:35 +00:00
Neil Brown
95fd6321d1
Added support for parsing list types in Rain
2008-03-18 11:53:57 +00:00
Neil Brown
806a5b9834
Added the tests for parsing list types in Rain
2008-03-18 11:52:59 +00:00
Adam Sampson
746e360a4a
Rename everywhereASTM to applyDepthM, and add a two-type version.
...
The renaming is because I can never remember which of everywhere and
everywhere' goes depth-first...
2008-03-20 11:40:19 +00:00
Adam Sampson
e08aac59d3
Move Retypes checking from the occam parser into a pass.
...
This also fixes a bug in the original algorithm: it used to let you retype
[]INT to BYTE.
2008-03-19 19:38:56 +00:00
Adam Sampson
b8caf7c3b6
Move everywhereASTM into Pass.
2008-03-19 18:11:49 +00:00
Adam Sampson
79eefd5e98
Move constant checking from the occam parser into a pass.
...
The parser now doesn't do any constant folding or checking.
2008-03-19 12:47:29 +00:00
Adam Sampson
b1416bb0cf
Change A.Dimension to take an Expression, not an Int.
...
This touches an awful lot of code, but cgtest07/17 (arrays and retyping) pass.
This is useful because there are going to be places in the future where we'll
want to represent dimensions that are known at runtime but not at compile time
-- for example, mobile allocations, or dynamically-sized arrays. It simplifies
the code in a number of places.
However, we do now need to be careful that expressions containing variables do
not leak into the State, since they won't be affected by later passes.
Two caveats (marked as FIXMEs in the source):
- Retypes checking in the occam parser is disabled, since the plan is to move
it out to a pass anyway.
- There's some (now very obvious) duplication, particularly in the backend, of
bits of code that construct expressions for the total size of an array
(either in bytes or elements); this should be moved to a couple of helper
functions that everything can use.
2008-03-18 16:45:38 +00:00
Adam Sampson
06ff5ccda6
Implement short-form PLACE, and fix PLACE IN WORKSPACE/VECSPACE.
2008-03-17 18:47:54 +00:00
Adam Sampson
17a1c0eef6
Clean up INITIAL a bit and add a test case.
...
There's no need for INITIALs to be early-constant-folded, since -- unlike VALs
-- they can't be used in later constant folding.
2008-03-17 18:43:07 +00:00
Adam Sampson
1fb6adb005
Fix array constructors in occam.
...
This works at least for simple examples, although it's probably a bit
restrictive on the array indexes you're allowed; it should attempt to
constant-fold them.
2008-03-17 18:34:23 +00:00
Adam Sampson
69ce2dce15
Resolve conflicts after merge.
2008-03-17 15:57:04 +00:00
Neil Brown
6f35e1e36c
Added support for array constructors to the occam parser
2008-03-10 22:58:36 +00:00
Neil Brown
b83bcc0f34
Added INITIAL variable abbreviations (as specifications) to the occam parser
2008-03-10 22:55:57 +00:00
Neil Brown
239dea3f36
Made the OF in CHAN OF optional in the occam parser
2008-03-10 22:43:18 +00:00
Adam Sampson
3005dfb506
Add a pass for folding constants in occam.
...
The existing constant-folding code in the parser is still there, since it needs
to know whether things are constant, and A.Dimension expects an Int.
However, this pass is useful because it does a better job of constant folding
than the parser would on its own: it can fold subexpressions of expressions
that are as a whole not constant.
2008-03-17 15:48:43 +00:00
Adam Sampson
89040a97b0
Move the dummy occam pass into an OccamPasses module.
...
(The plan is to gradually replace it with real passes.)
2008-03-15 14:40:17 +00:00
Adam Sampson
79a5799b8f
Some minor cleanups to ParseOccam.
2008-03-15 14:10:51 +00:00
Neil Brown
c778ff0031
Fixed some unused module import warnings, now that PassM is not build of monad transformers
2008-03-10 17:19:45 +00:00
Neil Brown
9f18b348e8
Corrected all the tests to use the new PassM monad
2008-03-10 17:07:48 +00:00
Neil Brown
6abda39ee2
Fixed a couple of uses of the PassM monad that depended on the old mechanism
2008-03-10 15:19:28 +00:00
Neil Brown
3d1aae72fc
Fixed a couple of tests for a Rain pass
2008-03-09 18:43:22 +00:00
Neil Brown
5c43172e46
Added an annotation to array subscripts to indicate whether they should have a run-time check added or not
2008-03-09 14:30:19 +00:00
Neil Brown
ba75f5b06c
Removed the initialiser expression on the Declaration item in the AST
2008-03-09 00:23:13 +00:00
Neil Brown
d02b771572
Tidied up the type of handleDirective to make it easier to use
2008-03-05 16:05:21 +00:00
Adam Sampson
d2c0fd674e
Rework the code for getting errors through the parser.
...
This used to work by adding a magic prefix to the error message, but it appears
that doesn't work with the GHC 6.6 version of Parsec. It now searches for a
magic substring anywhere in the error message.
It uses // as a delimeter rather than \0 now, since including nulls in Strings
causes problems -- for example, putStr "a\0b" will only print "a".
2008-03-04 12:52:25 +00:00
Adam Sampson
7ec6566495
Return sensible Meta from ParseOccam failures.
...
This means we get the nice annotated source display on a parser failure --
although we still get not-very-useful descriptions of errors sometimes...
2008-03-04 11:59:13 +00:00
Neil Brown
1e92333778
Added a try to fix the parsing of BYTESIN with a not obviously constant array dimension
2008-02-28 16:55:11 +00:00
Adam Sampson
d021edbd48
Add some reserved words that show up in ASM blocks.
2008-02-29 17:11:17 +00:00
Adam Sampson
a2a15cab64
Split include file expansion out into a separate pass.
...
The order of initial passes is now:
lex -> preprocess -> structure -> expand-include -> parse
which means that #IFing out structurally-invalid code (like inline VALOF) now
works. This also cleans up the preprocessor code a bit.
2008-02-29 15:01:19 +00:00
Adam Sampson
d7fbd93816
Add some tests for structureOccam.
2008-02-29 14:08:57 +00:00
Adam Sampson
c8b6be34e1
Implement comparisons in preprocessor expressions.
...
This brings Tock's conditional compilation facilities up to par with occ21.
2008-02-29 00:23:49 +00:00
Adam Sampson
a5fd73130a
Use Parsec to parse #DEFINE directives.
...
This is much neater, and I'll need most of the code to implement comparisons anyway.
2008-02-28 23:47:06 +00:00
Neil Brown
6d4f1dd702
Added labels to all the top-level tests that didn't have one
2008-02-28 16:11:01 +00:00
Adam Sampson
8f2575819b
Initial implementation of the occam-pi preprocessor.
...
This implements #DEFINE, #UNDEF, #IF, #ELSE and #ENDIF, macro expansion with
##, and TRUE, FALSE, AND, OR, NOT and DEFINED within #IF expressions, with the
same semantics as occ21.
The macro COMPILER.TOCK is always defined by default, so you can now say things
like "#IF NOT DEFINED (COMPILER.TOCK) ... #ENDIF".
2008-02-28 20:27:30 +00:00
Neil Brown
7af49a2d10
Fixed the checkFunction pass
2008-02-25 21:27:37 +00:00
Neil Brown
dcf419744a
Renamed the transformFunction pass into checkFunction, and adjusted the tests for it accordingly
2008-02-25 21:17:37 +00:00
Neil Brown
74838bcb80
Fixed functions to work again in the Rain parser, according to the new tests
2008-02-25 17:18:28 +00:00
Neil Brown
839c8ebe7c
Fixed the tests for parsing Rain functions, using the new Process body with functionname = returnvalue plan
2008-02-25 17:17:38 +00:00
Neil Brown
1edaacae89
Altered the AST to allow a function to be either an ExpressionList (classical occam) or a Process (Rain/proposed new occam)
2008-02-24 19:29:31 +00:00
Neil Brown
74f3cb7fc2
Removed the export of "m" in TestUtils, instead moving the definition to each module that uses it (less confusing that way)
2008-02-24 18:55:44 +00:00
Neil Brown
2e6718ac50
Changed all the lists of passes to add pre- and post- properties
2008-02-19 09:43:40 +00:00
Neil Brown
360abc195e
Moved the enabling/disabling of passes based on CompState from PassList to the point of the declaration of the passes
2008-02-16 11:09:25 +00:00
Neil Brown
3ce0eaf452
Made the first adjustment to the Pass system, ready to introduce properties and a dependency graph. For now passes are still executed in list order
2008-02-16 10:19:14 +00:00
Neil Brown
b037b6a8ca
Tidied up the new code relating to warnings, and moved it all into the Errors module (out of CompState and Pass)
2008-02-08 13:31:37 +00:00
Neil Brown
f17ff5071c
Added a Warn monad for warnings, and incorporated a WriterT monad into the PassM stack to support the Warn monad, then changed all the rest of the code accordingly, including adding a Warn instance for the GenParser parser that hides it in the state
2008-02-08 13:22:23 +00:00
Neil Brown
95cdb39789
Generalised the type of the monad for the excludeConstr function, and correspondingly the functions that use it
2008-02-08 11:33:19 +00:00
Neil Brown
e3e9e912f2
Added a read-only version of CSM, named CSMR
2008-02-08 11:17:50 +00:00
Neil Brown
1fd85fbe51
Added the -fwarn-missing-signatures option and added all missing type signatures for non-test modules (and most for test modules too)
2008-02-05 23:06:03 +00:00
Neil Brown
acd57d74de
Changed the A.Structured type to be parameterised
...
This patch is actually an amalgam of multiple (already large) patches. Those patches conflicted (parameterised Structured vs. changes to usage checking and FlowGraph) and encountered a nasty bug in darcs 1 involving exponential time (see http://wiki.darcs.net/DarcsWiki/ConflictsFAQ for more details). Reasoning that half an hour (of 100% CPU use) was too long to apply patches, I opted to re-record the parameterised Structured changes as this new large patch. Here are the commit messages originally used for the patches (which, as mentioned, were already large patches):
A gigantic patch switching all the non-test modules over to using parameterised A.Structured
Changed the FlowGraph module again to handle any sort of Structured you want to pass to it (mainly for testing)
A further gigantic patch changing all the tests to work with the new parameterised Structured
Fixed a nasty bug involving functions being named incorrectly inside transformInputCase
Added a hand-written instance of Data for Structured that allows us to use ext1M properly
Fixed a few warnings in the code
2008-02-05 19:40:27 +00:00
Neil Brown
6c4e7ee713
Added a few more TestLabels
2008-02-05 16:19:16 +00:00
Neil Brown
edc3a7e910
Removed the die function (that has no source position) and as far as possible replaced all its uses with dieP and a valid position
2008-01-28 17:21:13 +00:00
Neil Brown
2120b830dc
Corrected the use of the -fno-warn-tabs flag in the alex files so that it works under GHC 6.6.x
2008-01-28 12:03:03 +00:00
Neil Brown
bdda623d7e
Added types to all the cases where the monomorhpism restriction applied
2008-01-26 20:51:11 +00:00
Neil Brown
741a01de5a
Removed various tab characters and replaced them with spaces
2008-01-26 19:38:24 +00:00
Neil Brown
34584130d4
Turned off tab warnings for the files auto-generated by Alex (which contain a lot of tabs)
2008-01-26 19:37:43 +00:00
Neil Brown
0706cb4d51
Rearranged PreprocessOccam a little so that you can now parse occam source directly from a String (as well as from a filename, as before)
2008-01-16 03:26:49 +00:00
Neil Brown
26dd2fa5c4
Renamed the TestUtil and TreeUtil modules to TestUtils and TreeUtils, to be consistent with the Utils module
2007-12-13 19:05:29 +00:00
Neil Brown
4c20f99ac3
Changed some tests to use the new mSeq matching helpers
2007-11-28 14:30:56 +00:00
Neil Brown
8ec8374bc6
Converted most of ParseRainTest to use the pat function with normal AST fragments, rather than the more verbose explicit Patterns
2007-11-21 15:33:17 +00:00
Neil Brown
14cb5d7642
Changed some Named Patterns to use the new @@ operator
2007-11-21 14:26:08 +00:00
Neil Brown
1a7d77d9c4
Added more documentation to the tests for the Rain frontend passes
2007-11-12 15:45:07 +00:00
Neil Brown
da76be9dab
Changed RainParseTest to stop relying on the Meta tag hack, and also added some more documentation.
2007-11-10 14:13:14 +00:00
Neil Brown
16df6a1774
Fixed some conflicts between some branches, in RainPassesTest
2007-10-28 18:34:28 +00:00
Neil Brown
25f2efb94c
Changed the existing Rain code (and tests) to use the new List type rather than the Array type
2007-10-25 10:13:17 +00:00
Neil Brown
6b95827cab
Added an optional initialiser-expression to Declaration in the AST, and changed the rest of the code accordingly
2007-10-24 23:50:00 +00:00
Neil Brown
7d8f170b7d
Added support for the #COMMENT directive to the occam parser
2007-10-15 17:12:53 +00:00
Neil Brown
d4a766c594
Changed the occam parser to use A.Several with an empty list for its terminator, rather than A.Main
2007-10-17 13:43:12 +00:00
Neil Brown
e582f5e508
Changed the terminator in Rain source files from A.Main to A.Several (with an empty list), and updated the tests accordingly
2007-10-17 13:42:13 +00:00
Neil Brown
1c858e112c
Changed the occam and Rain parsers to return a Structured rather than a Process (which will simplify the generated ASTs)
2007-10-17 13:21:17 +00:00
Neil Brown
15ecb2b178
Added the -fwarn-type-defaults compiler option (for when integer literals are given a default type) and fixed the few warnings that arose from doing so
2007-09-27 13:29:16 +00:00
Neil Brown
38c409d378
Added the -fwarn-unused-imports compiler option to warn about unused imports, and then set about pruning and ordering (mostly in my code) the import lists for all the modules
2007-09-27 13:13:46 +00:00
Neil Brown
028c27eb73
Rain: implemented type-checking for wait guards
2007-09-26 23:42:40 +00:00
Neil Brown
c38978c123
Rain: added tests for checking types in wait guards
2007-09-26 23:42:16 +00:00
Neil Brown
d79de5a936
Rain: implemented parsing of wait guards
2007-09-26 23:34:55 +00:00
Neil Brown
cbd2d04371
Rain: added tests for parsing wait guards
2007-09-26 23:34:42 +00:00
Neil Brown
a65953ad89
Rain: added type-checking for wait statements
2007-09-26 23:08:55 +00:00
Neil Brown
41ac788601
Rain: added tests for checking the types in wait statements
2007-09-26 23:08:37 +00:00
Neil Brown
5af96110c7
Rain: implemented the parsing of wait statements
2007-09-26 23:00:58 +00:00
Neil Brown
13584ed2cb
Added a wait statement to the AST, and added Rain tests for parsing wait statements
2007-09-26 23:00:09 +00:00
Neil Brown
a12d46401a
Rain: implementing type checking for inputs inside alts
2007-09-26 22:37:32 +00:00
Neil Brown
5c827fdacb
Rain: added testing for correct types in input statements in alts
2007-09-26 22:37:03 +00:00
Neil Brown
4cc0628757
Corrected the name of one of the RainTypesTest tests
2007-09-26 22:24:01 +00:00
Neil Brown
db4f05932b
Fixed a conflict between the old time-related patches and the new alt patches
2007-09-26 21:39:16 +00:00
Neil Brown
769dc3c79a
Rain: changed the if, while and each loops to require a block as their body, rather than just a statement.
2007-09-26 18:03:42 +00:00
Neil Brown
68c468fbea
Rain: added the parsing of else (skip) guards in alts
2007-09-26 19:56:22 +00:00
Neil Brown
420839ef1e
Rain: added tests for parsing else guards in alts
2007-09-26 19:56:11 +00:00
Neil Brown
9c87478110
Corrected a test number in ParseRainTest
2007-09-26 19:44:33 +00:00
Neil Brown
205b090cef
Rain: implemented the parsing of alt statements
2007-09-26 19:40:04 +00:00