Commit graph

132 commits

Author SHA1 Message Date
zik.saleeba e5fa7017f0 Better checks on pointers.
Pointer offsets are now honoured.


git-svn-id: http://picoc.googlecode.com/svn/trunk@259 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-04-22 07:23:26 +00:00
zik.saleeba 096def8f55 Pointer arithmetic and NULL pointer support added
git-svn-id: http://picoc.googlecode.com/svn/trunk@255 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-04-19 11:49:01 +00:00
zik.saleeba 2e22614595 Final problems with the new expression system fixed
git-svn-id: http://picoc.googlecode.com/svn/trunk@248 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-04-15 10:47:51 +00:00
zik.saleeba 16922d2e73 library struct example for Howard
git-svn-id: http://picoc.googlecode.com/svn/trunk@219 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-04-07 10:48:46 +00:00
zik.saleeba ccbf149212 Fixed a problem with interactive mode error handling.
Will need some extra work for Surveyor... tomorrow.


git-svn-id: http://picoc.googlecode.com/svn/trunk@215 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-31 11:08:29 +00:00
zik.saleeba 79c7619dab New expression system now handles simple numeric values
git-svn-id: http://picoc.googlecode.com/svn/trunk@214 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-30 11:16:40 +00:00
zik.saleeba 45a378231b More work on expressions
git-svn-id: http://picoc.googlecode.com/svn/trunk@213 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-29 11:08:03 +00:00
zik.saleeba 1ab28fcfb7 Took a first stab at implementing new/delete. Needs a bit more thought on how to handle dangling references to deallocated storage.
git-svn-id: http://picoc.googlecode.com/svn/trunk@211 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-16 04:25:58 +00:00
zik.saleeba ce80c66e8f Added new "delete" keyword, used for undefining variables or functions
in interactive mode.


git-svn-id: http://picoc.googlecode.com/svn/trunk@206 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-15 10:44:56 +00:00
zik.saleeba a414de85e5 getchar()/gets() implemented
git-svn-id: http://picoc.googlecode.com/svn/trunk@205 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-15 09:57:19 +00:00
zik.saleeba 207549bf17 Reorganised platform/library stuff for better separation between
platforms.
Removed unnecessary union in pointers.


git-svn-id: http://picoc.googlecode.com/svn/trunk@203 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-15 07:07:21 +00:00
zik.saleeba 48a6472c68 All allocations are now cleaned up neatly on exit. This is probably unnecessary given that we run our own heap but gives confidence that there are no internal memory leaks.
git-svn-id: http://picoc.googlecode.com/svn/trunk@199 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-11 23:49:10 +00:00
zik.saleeba 0523bd570d String literal array values are now shared and deallocated cleanly
git-svn-id: http://picoc.googlecode.com/svn/trunk@197 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-11 22:28:42 +00:00
zik.saleeba 6f7daf0145 Now cleaning up types too
git-svn-id: http://picoc.googlecode.com/svn/trunk@195 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-11 10:17:46 +00:00
zik.saleeba 028c98d665 Now cleaning up more stuff
git-svn-id: http://picoc.googlecode.com/svn/trunk@194 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-11 10:01:32 +00:00
zik.saleeba a22c243c06 Doing some work on cleaning up more nicely on exit.
Also allowing the use of the native heap allocator as an option.

git-svn-id: http://picoc.googlecode.com/svn/trunk@192 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-11 02:19:18 +00:00
zik.saleeba 23bce9d38a enums implemented
git-svn-id: http://picoc.googlecode.com/svn/trunk@180 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-09 22:36:01 +00:00
zik.saleeba dc04ba8dd0 Split parsing across two files parse.c and the new expression.c
git-svn-id: http://picoc.googlecode.com/svn/trunk@170 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-08 07:56:28 +00:00
zik.saleeba 46c4bad533 Interactive mode now works.
git-svn-id: http://picoc.googlecode.com/svn/trunk@167 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-08 04:26:28 +00:00
zik.saleeba 05d377e49d First stab at interactive mode needs debug.
git-svn-id: http://picoc.googlecode.com/svn/trunk@164 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-07 11:23:42 +00:00
zik.saleeba f5fac3fdf2 First stab at making lists of tokens from interactive input. Not ready yet.
git-svn-id: http://picoc.googlecode.com/svn/trunk@162 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-07 07:49:17 +00:00
zik.saleeba 8a5ed05fd2 Now copying function tokens so when we're in interactive mode we can free the original tokens without
losing the box and dice.


git-svn-id: http://picoc.googlecode.com/svn/trunk@161 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-07 06:17:11 +00:00
zik.saleeba 86bb48b158 #define now works for simple unparameterised expression macros
git-svn-id: http://picoc.googlecode.com/svn/trunk@159 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-06 07:27:45 +00:00
zik.saleeba 3bdbb51d5c Now allowing multiple declarations in one statement
git-svn-id: http://picoc.googlecode.com/svn/trunk@157 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-06 06:00:51 +00:00
zik.saleeba 8020a9ca57 Expression fiddling
git-svn-id: http://picoc.googlecode.com/svn/trunk@151 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-04 10:09:56 +00:00
zik.saleeba a3ab81ca23 Starting to code the new expression system
git-svn-id: http://picoc.googlecode.com/svn/trunk@148 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-03 10:53:45 +00:00
zik.saleeba 676c937a7b Fixed bug in stdarg handling of non-stack values
git-svn-id: http://picoc.googlecode.com/svn/trunk@142 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-03-02 22:13:47 +00:00
zik.saleeba 7003b55ead Library functions now get Parser as a parameter
git-svn-id: http://picoc.googlecode.com/svn/trunk@134 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-28 22:14:55 +00:00
zik.saleeba d98c55d5e5 Platform-shared global variables implemented
git-svn-id: http://picoc.googlecode.com/svn/trunk@130 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-28 20:46:02 +00:00
zik.saleeba b6b75396dd Added all remaining operators with a view to completing expression evaluation
git-svn-id: http://picoc.googlecode.com/svn/trunk@124 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-28 19:30:48 +00:00
zik.saleeba 6ce1662475 Platform-dependent exit() function for Surveyor
git-svn-id: http://picoc.googlecode.com/svn/trunk@121 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-28 05:43:28 +00:00
zik.saleeba 73d91b6202 Change to add extra lvalue information to values
git-svn-id: http://picoc.googlecode.com/svn/trunk@117 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-26 09:56:22 +00:00
zik.saleeba 3558506261 Fiddling with pointers
git-svn-id: http://picoc.googlecode.com/svn/trunk@115 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-25 11:14:46 +00:00
zik.saleeba 20fb2407ef Big reorganisation to make it easier to port to different targets
git-svn-id: http://picoc.googlecode.com/svn/trunk@110 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-24 11:16:37 +00:00
zik.saleeba e94767ba98 New NO_FP compile option allows removal of all floating point support
git-svn-id: http://picoc.googlecode.com/svn/trunk@101 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-24 00:21:17 +00:00
zik.saleeba 4b11999dea stdarg parameter type checking bug sorted
git-svn-id: http://picoc.googlecode.com/svn/trunk@99 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-21 23:38:07 +00:00
zik.saleeba 7f6503d1e0 printf() now works!
Fixed a bug in pointer sizing.


git-svn-id: http://picoc.googlecode.com/svn/trunk@98 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-21 12:02:15 +00:00
zik.saleeba 4821d689ad Big changes to string constants.
Got rid of str.c.
First attempt at stdarg params in printf()


git-svn-id: http://picoc.googlecode.com/svn/trunk@97 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-21 02:35:52 +00:00
zik.saleeba 2ac131247b Fixed a lexer bug in memory allocation
git-svn-id: http://picoc.googlecode.com/svn/trunk@96 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-20 09:46:46 +00:00
zik.saleeba 89e5c66189 Implemented ellipsis for stdargs and stdarg stack handling
git-svn-id: http://picoc.googlecode.com/svn/trunk@95 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-20 09:04:45 +00:00
zik.saleeba ebc32dc1f0 Removed unnecessary ResultOnHeap parameters - they just added code for no reason.
Arguments are now stored fully on the stack to fix a bug with nested function calls.

git-svn-id: http://picoc.googlecode.com/svn/trunk@91 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-19 23:29:35 +00:00
zik.saleeba fdad9f8d30 Changes to help with implementing switch/case/break/continue/return
git-svn-id: http://picoc.googlecode.com/svn/trunk@82 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-18 08:19:06 +00:00
zik.saleeba d94b70212b Syntax of "switch" is now handled. Not semantics though.
git-svn-id: http://picoc.googlecode.com/svn/trunk@81 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-17 23:36:09 +00:00
zik.saleeba 2e545deb6a Arrays debugged and working
git-svn-id: http://picoc.googlecode.com/svn/trunk@80 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-15 07:39:41 +00:00
zik.saleeba b073f187f8 Revamped the way lvalues work. Now both structs and '.' should work.
git-svn-id: http://picoc.googlecode.com/svn/trunk@77 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-15 05:52:03 +00:00
zik.saleeba bd5fe4b73c Made a cleaner interface to creating shared values
git-svn-id: http://picoc.googlecode.com/svn/trunk@74 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-11 06:47:36 +00:00
zik.saleeba e348021c51 Fixed some egregious bugs
git-svn-id: http://picoc.googlecode.com/svn/trunk@72 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-10 22:25:20 +00:00
zik.saleeba a8b4b08d93 Implemented the '.' operator for struct/union member access
git-svn-id: http://picoc.googlecode.com/svn/trunk@66 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-09 11:40:56 +00:00
zik.saleeba 943aa9cf97 Added some heap debug
git-svn-id: http://picoc.googlecode.com/svn/trunk@61 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-03 06:27:34 +00:00
zik.saleeba 0547bcaff0 Increased heap size to 8k
git-svn-id: http://picoc.googlecode.com/svn/trunk@55 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-02 22:35:59 +00:00
zik.saleeba 1389084b36 Fixed some egrerious bugs
git-svn-id: http://picoc.googlecode.com/svn/trunk@49 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-02 11:50:55 +00:00
zik.saleeba 956efab67f Parser is now updated to work with the new lexer and string system.
System now compiles - needs debug.


git-svn-id: http://picoc.googlecode.com/svn/trunk@48 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-02 11:08:36 +00:00
zik.saleeba f8216bb79f Type system now works with the new lexer.
git-svn-id: http://picoc.googlecode.com/svn/trunk@47 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-02 05:27:15 +00:00
zik.saleeba 0c0ac9b332 Lexer now supports interactive input.
Lexer now pre-scans the source and returns a buffer of tokens.
Heap can provide unallocated memory for a temporary buffer.

git-svn-id: http://picoc.googlecode.com/svn/trunk@46 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-02 04:53:45 +00:00
zik.saleeba 8bd1c18d24 Converting to use shared strings
git-svn-id: http://picoc.googlecode.com/svn/trunk@45 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-02 03:27:05 +00:00
zik.saleeba 86af5318da Bulko lexer change for more efficient pre-scanned tokens.
Removed Str type - replaced with standard C strings.
Added hashed string tables for efficient string storage.


git-svn-id: http://picoc.googlecode.com/svn/trunk@43 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-02-01 11:31:18 +00:00
zik.saleeba 2d7b467b96 Changed from a linear probing hash table to a hash chain method since we now have better storage allocation. This is more space efficient and removes the static limits on local variable table sizes.
git-svn-id: http://picoc.googlecode.com/svn/trunk@41 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-29 22:26:04 +00:00
zik.saleeba b2396d3eda Now stack frames appear on our new stack as they should. The old static
limits are gone.


git-svn-id: http://picoc.googlecode.com/svn/trunk@40 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-29 11:10:46 +00:00
zik.saleeba 75e45704e8 Bulk changes to accomodate the new storage model.
The system now compiles again (probably doesn't run though).


git-svn-id: http://picoc.googlecode.com/svn/trunk@38 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-26 08:57:32 +00:00
zik.saleeba 4524270e50 Changing everything to handled heap-allocated values
git-svn-id: http://picoc.googlecode.com/svn/trunk@37 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-25 02:09:44 +00:00
zik.saleeba b9e1086cbb Moving towards a working new type system
git-svn-id: http://picoc.googlecode.com/svn/trunk@36 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-24 03:15:02 +00:00
zik.saleeba fad5c6db69 Big changes and progress towards the new type system. Doesn't compile right now. Maybe tomorrow.
git-svn-id: http://picoc.googlecode.com/svn/trunk@35 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-23 11:34:12 +00:00
zik.saleeba a59be13de3 Now compiles with some of the new structure in place
git-svn-id: http://picoc.googlecode.com/svn/trunk@34 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-21 09:02:05 +00:00
zik.saleeba 626c29a639 Working on the heap and the new type system. Doesn't compile right now.
git-svn-id: http://picoc.googlecode.com/svn/trunk@33 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-21 00:52:42 +00:00
zik.saleeba 93a6dffee4 #define macros implemented
git-svn-id: http://picoc.googlecode.com/svn/trunk@27 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-05 04:28:54 +00:00
zik.saleeba 995266ce9c Added test framework.
Implemented preprocessor-style directives (not finished yet).


git-svn-id: http://picoc.googlecode.com/svn/trunk@26 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-01-04 04:08:49 +00:00
zik.saleeba 939c68cd4d Intrinsic functions implemented
git-svn-id: http://picoc.googlecode.com/svn/trunk@25 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-27 04:36:45 +00:00
zik.saleeba bf0fe101e5 Support for floating point output added
git-svn-id: http://picoc.googlecode.com/svn/trunk@24 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-27 03:04:58 +00:00
zik.saleeba 704f20e1c4 Added floating point support
git-svn-id: http://picoc.googlecode.com/svn/trunk@22 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-27 02:25:49 +00:00
zik.saleeba 69113a26c6 Function calls added
git-svn-id: http://picoc.googlecode.com/svn/trunk@20 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-24 02:30:29 +00:00
zik.saleeba 252e1339d6 Type and parameter parsing - working toward function handling.
"plain token" lexical analysis for brevity.


git-svn-id: http://picoc.googlecode.com/svn/trunk@19 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-22 11:52:31 +00:00
zik.saleeba e5920c041c Local variables implemented
git-svn-id: http://picoc.googlecode.com/svn/trunk@18 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-22 02:29:19 +00:00
zik.saleeba ebf601bfb9 Removed unused path in TableSet()
git-svn-id: http://picoc.googlecode.com/svn/trunk@16 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-21 03:13:25 +00:00
zik.saleeba eba1492fcb Function definitions implemented.
Lexer changed to not carry values in LexState.


git-svn-id: http://picoc.googlecode.com/svn/trunk@15 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-21 01:36:09 +00:00
zik.saleeba 19fbe151ff Fixed a number lexing bug.
Fixed an assignment bug.
Beginnings of function handling.
Now can run a simple program for the first time.


git-svn-id: http://picoc.googlecode.com/svn/trunk@14 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-20 11:46:21 +00:00
zik.saleeba 42c28c78c7 Neatened calling and error handling.
Parser now handles assignment.


git-svn-id: http://picoc.googlecode.com/svn/trunk@13 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-20 10:24:34 +00:00
zik.saleeba a41ac67b50 Now compiles
git-svn-id: http://picoc.googlecode.com/svn/trunk@10 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-12-19 00:22:52 +00:00
zik.saleeba 8cfd9c6013 Wrote much of the parser
git-svn-id: http://picoc.googlecode.com/svn/trunk@9 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-11-22 02:56:08 +00:00
zik.saleeba d89cc62990 More lexiness
git-svn-id: http://picoc.googlecode.com/svn/trunk@6 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-10-14 11:46:42 +00:00
zik.saleeba 96674aad41 Now uses internal printf
git-svn-id: http://picoc.googlecode.com/svn/trunk@5 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-10-14 11:18:43 +00:00
zik.saleeba b5f685e744 Now compiles cleanly
git-svn-id: http://picoc.googlecode.com/svn/trunk@3 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-10-13 10:53:25 +00:00
zik.saleeba 7bfc2c0be5 Initial checkin of picoc. Not working yet.
git-svn-id: http://picoc.googlecode.com/svn/trunk@2 21eae674-98b7-11dd-bd71-f92a316d2d60
2008-10-13 00:53:28 +00:00