Commit Graph

100 Commits

Author SHA1 Message Date
Neil Brown
f755458545 Turned *EXTERNAL pragmas into specifications in the occam parser
There was a bug where things scoped in via pragmas were never scoped out again, which was screwing up the local names stack.  I then realised/decided that pragmas were really specifications, and decided to put them there in the parser.

The rest of this patch is just some rewiring to allow the special name munging involved in pragmas (they have already got a munged version of their name) and to stop the scoped in pragmas appearing in the AST.
2009-04-03 21:06:24 +00:00
Neil Brown
4a36d578c0 Added a check that the names being scoped out match the names that were scoped in, which helps find bugs in the parser 2009-04-03 21:03:19 +00:00
Neil Brown
8220630426 Attempted to fix a problem with parsing pragmas, but I suspect it's still a bit haphazard 2009-04-03 16:50:41 +00:00
Neil Brown
0d63eeb400 Fixed a small parser bug involving variant 2009-04-03 15:34:33 +00:00
Neil Brown
70789661f1 Got pragma-declared FUNCTIONS to be turned into PROCs and handled properly 2009-04-02 18:13:51 +00:00
Neil Brown
460c3e287f Changed names to be uniquified based on their source position, and fixed the source position for things in pragmas
The second part of the patch is essential, given the first.  Otherwise names in different pragmas in the same file can overlap -- this already happened in oak!
2009-04-02 17:45:31 +00:00
Neil Brown
a843d07463 Changed the pragmas to support FUNCTIONs, and to order the names the other way (as Adam wanted) 2009-04-02 16:57:11 +00:00
Neil Brown
9e3e71c70a Added a bit of extra help when a name is not found (suggesting other names) 2009-04-02 15:42:02 +00:00
Neil Brown
51f67f59b4 Reworked the pragma generation again for occam PROCs
One change, based on Adam's suggestion, was to rename the pragma to TOCKEXTERNAL.

Another, also based on Adam's suggestion, was to generate both the munged name and the original name, which allows (along with a previous patch) different files to declare the same PROC, and will remove the need for the occam_ prefix in the backend.

I also stopped using specific states in the lexer, in favour of just using the normal lexing function (which has had its type generalised slightly).
2009-04-02 15:33:32 +00:00
Neil Brown
ca818d423c Made the munging of the names include the file name, to help with separate compilation
This will allow (along with a few patches in a minute) different occam files to declare the same PROC, and have it resolved correctly based on the order of their declaration, just like if it was all in one file.
2009-04-02 15:31:50 +00:00
Neil Brown
c79fd70959 Made sure that warnings are shown along with errors in the parser
The solution is a bit hacky, but this was an important problem.  If your PRAGMA failed to parse, that was worthy of a warning.  But if that then caused the parse to fail, all you would get is the parser error (could not find name), and you would never see the warnings about the pragmas not being recognised.  So now the pragmas are shoved into the error (using a basic encoding) and pulled out and issued if the parser dies.
2009-04-02 15:07:39 +00:00
Neil Brown
7e7a437a3b Switched to using a different kind of pragma for occam externals, and munged the names to avoid collisions
The separately compiled occam PROCs now use #PRAGMA OCCAMEXTERNAL, which also discards the "= number" thing at the end.  These PROCs then need to be processed differently when adding on the sizes (C externals have one size per dimension, occam externals have the normal array of sizes).

We also now record which processes were originally at the top-level, and keep their original names (i.e. minus the _u43 suffixes) plus an "occam_" prefix to avoid collisions.
2009-04-01 19:21:40 +00:00
Neil Brown
7b55c96781 Fixed up the parsing of PRAGMAs to make it a bit simple, and match with other changes to the lexer and parser 2009-04-01 17:26:27 +00:00
Neil Brown
512d05dd36 Removed the redundant warnings from the occam parser (after I put them back into CompState, a long time ago) 2009-04-01 16:56:37 +00:00
Neil Brown
334d22acd8 Corrected a try, so that we don't mistake a CHAN type for a CHAN TYPE type 2009-03-31 11:50:24 +00:00
Neil Brown
dbc3b97343 Changed the lexing and parsing of PRAGMAs again, to allow unknown pragmas
With my previous change to PRAGMAs, unknown pragmas would fatally fail in the lexer, so that an unknown pragma would always stop compilation, which is not good.  I've changed it more towards Adam's suggestion of re-lexing and re-parsing the pragma from the parser, so we now gracefully ignore unknown pragmas again.  The lexer is a bit messy, though.
2009-03-31 11:08:53 +00:00
Neil Brown
c46346ffa2 Changed the occam parser to parse SIZE followed by a variable into the new VariableSizes item 2009-03-30 15:33:36 +00:00
Neil Brown
eb99480484 Finished off the support for external C functions 2009-03-26 22:37:28 +00:00
Neil Brown
5418916245 Added the parsing of channel-array literals in PROC parameters 2009-03-25 16:38:21 +00:00
Neil Brown
7cbe98d200 Modified the lexer and parser to be able to parse PRAGMA EXTERNAL (and added #DEFINE support in the lexer) 2009-03-25 16:36:59 +00:00
Neil Brown
45b22472c3 Changed the rest of tock to reflect the changes to the Is constructor 2009-03-24 23:57:24 +00:00
Neil Brown
030e06f173 Allowed pragmas at the top-level of an occam file 2009-03-24 02:15:23 +00:00
Neil Brown
19e0fb0573 Added an AllocChannelBundle constructor in ExpressionList for assignments that allocate the two ends of a mobile channel bundle 2009-03-23 18:58:50 +00:00
Neil Brown
41805aaacf Changed the ChanEnd constructor to only keep information about its shared-ness, not about the whole channel 2009-03-23 18:40:28 +00:00
Neil Brown
ef4c73aece Added support in the parser for allocating mobile channel bundles, and for shared normal channels 2009-03-23 15:54:49 +00:00
Neil Brown
69d7bc6455 Fixed recursive channel bundle types to work properly 2009-03-23 15:54:24 +00:00
Neil Brown
084861e0be Altered the parser to change CLAIM from being a process into a specification 2009-03-23 15:52:44 +00:00
Neil Brown
5f9d0c6429 Added various keywords, AST elements and parser bits related to channel bundles, claim blocks and shared channels 2009-03-22 22:49:49 +00:00
Neil Brown
8492dc03d4 Introduced a ShareMode in the AST, and used it in the channel attributes (rather than Bool) 2009-03-22 22:29:39 +00:00
Neil Brown
03f1b2d115 Added a few more mobile things (DEFINED keyword, an intrinsic) 2009-03-20 20:53:51 +00:00
Neil Brown
86f0218899 Changed the occam parser to understand the MOBILE and CLONE keywords 2009-03-20 15:17:43 +00:00
Neil Brown
81959bd76b Added quick preliminary support for the PERMITALIASES pragma 2009-02-10 01:01:23 +00:00
Neil Brown
46394b8c34 Fixed the occam and Rain parsers to work with the new system for array literals 2009-02-01 21:54:02 +00:00
Neil Brown
8a28d765e7 Implemented recursive procs
This works fine in the C++ backend, not tested with the C backend yet
2009-01-29 00:43:24 +00:00
Neil Brown
7722e95dfd Added support for recursive functions (not procs, yet)
At the moment, the information is only needed in the parser, which must define recursive names before parsing the body of the function.  But in future, we should keep the information when the function becomes a proc, and then the C/C++ backends may need to use it (for example, when calculating stack space usage)
2009-01-29 00:27:11 +00:00
Neil Brown
6d7f456791 Changed the occam parser to accept STEP in replicators 2009-01-28 23:47:00 +00:00
Neil Brown
49ea4f053e Fixed the occam parser to allow comments after pragmas on the same line
One of the more recent cgtests has a comment after a pragma
2009-01-28 23:40:14 +00:00
Neil Brown
6ff8e3b163 Fixed a bug where records were being recorded with the wrong name type in the occam parser 2009-01-28 22:11:23 +00:00
Neil Brown
4d692c8897 Fixed the occam and Rain parsers to work with the new channel-ends
For now, I have fixed the occam parser so that it allows 1 or more direction specifiers after channel names.  So c?? is valid, and should end up being equivalent to c?, but this may need altering later.
2009-01-20 17:28:57 +00:00
Neil Brown
8a36f6e96f Added support for parsing pragmas, for now just handling the SHARED pragma 2009-01-19 15:11:09 +00:00
Neil Brown
0e7a6c5b98 Added a NameSource field for NameDef that indicates where a name comes from 2008-11-25 17:36:42 +00:00
Neil Brown
0d486f108f Added a value to indicate what type a warning is (to support future configurability) and streamlined the warning functions 2008-11-13 15:36:22 +00:00
Adam Sampson
f102d8e7ef Make "PORT" work for "PORT OF". 2008-06-11 13:18:54 +00:00
Adam Sampson
638a3f3c22 Allow a directed channel array to be sliced.
This lets you write things like "[cs! FOR 5]", which is horrible; I
would prefer "[cs FOR 5]!", since then that doesn't imply that you can
do things like "cs![0] ! 0".

However, Tock now compiles and passes cgtest87 -- the first occam-pi
cgtest we've handled. :)
2008-06-09 21:42:34 +00:00
Adam Sampson
62a0873d3d Implement channel direction decorators.
This is mostly straightforward: modify the parser to allow direction
decorators in the right places, and extend the type checker to match.
There's some slight awkwardness in that some of the Types functions
have to perform the same checks as the type checker (e.g. directing a
non-channel), so I've tidied up their error messages a bit.

At the backend, I've just added a little pass to strip out all the
DirectedVariables, since the other backend passes don't handle them
gracefully. From the occam/C point of view this is fine, but I'm not
sure if it's going to cause problems for C++.
2008-06-09 21:35:20 +00:00
Adam Sampson
ab416326ad Make Token a real data type.
Previously it was a tuple, which meant it couldn't have sensible
custom instances. Token and TokenType now have Show instances, so we
get more useful output when parsing fails.
2008-06-05 09:46:52 +00:00
Neil Brown
41ff60cb78 Removed the Rep constructor from Structured and instead added a Rep constructor to SpecType
This way, all replicators are declared like other names, and their scope is considered replicated.  This simplifies the code a little.

Fixes #55
2008-06-04 17:00:43 +00:00
Adam Sampson
6ee21f76c9 Initial work on supporting INITIAL and RESULT abbreviations.
This fixes the AST, parser and typechecker, and adds a pass to
transform Result back into Abbrev, but doesn't transform Initial yet.
(It actually works for trivial stuff anyway, but it won't do the right
thing for complex types or PROC parameters.)

It appears (to me) to make sense to support INITIAL/RESULT reshaping
and retyping too, so this does.

Refs #42.
2008-06-02 20:41:37 +00:00
Adam Sampson
36e7353ee7 Take NameType out of NameDef.
NameType is only really needed in the parser, so this takes it out of
NameDef, meaning that later passes defining names no longer need to
set an arbitrary NameType for them. The parser gets slightly more
complicated (because some productions now have to return a SpecType
and a NameType too), but lots of other code gets simpler.

The code that removed free names was the only thing outside the parser
using NameType, and it now makes a more sensible decision based on the
SpecType. Since unscoped names previously didn't have a SpecType at
all, I've added an Unscoped constructor to it and arranged matters
such that unscoped names now get a proper entry in csNames.

Fixes #61.
2008-06-02 10:13:14 +00:00
Adam Sampson
9749d58f09 Remove an obsolete comment. 2008-05-30 12:24:46 +00:00