Commit graph

18 commits

Author SHA1 Message Date
Payton Turnage
e99a0428f3 Implement defines using the htab structure.
The htab_structure has been modified in two ways, which should not break
compatability with any of its uses.

It includes a void pointer, which is in this commit used to point to a
string for defines, and will in the future be used to point to the address
space for words, bytes, and double words.

It now includes a function htab_add_str specifically for storing strings.
It calls htab_add so as not to be redundant, but makes the node's value
their index for the lexer to fetch using htab_find, and assigns their
void pointer.

The lexer will now use htab_find on all tokens to see if they are a define
string, and if so, substitute them with the appropriate token.

The defines htab is destroyed after lexing, because that memory is done.
2014-01-13 10:20:21 -05:00
Payton Turnage
ed12ce05db Remove all traces of the tvm_tree structure.
It is to be replaced with a htab hash table.
2014-01-13 09:45:27 -05:00
Payton Turnage
b208237960 Allow the preprocessor to abort.
If the preprocessor encounters a problem, such as failing to load a source
file or an improperly formatted define, it should be able to abort running
the program.
2014-01-12 21:56:54 -05:00
Payton Turnage
d152751cf8 Free the defines memory earlier.
There is no need to keep this memory for the life of the program.
2014-01-12 21:49:17 -05:00
Payton Turnage
c80d6974cb Substitute defines with their strings.
Before allocating space for a token, the lexer will first check to see
if that token is a defined name. If it is, it will allocate space for
the defined string instead.

A test file is included in programs/tinyvm/preprocessor to demonstrate
the behavior. When functioning, the program will print the fibonacci
sequence.
2014-01-12 21:43:57 -05:00
Payton Turnage
23e72a8ca7 Implement preprocessor defines.
This commit adds behavior to the preprocessor which fills a tree with
defines and their replacements. In future commits, the parser will
substitute instances of the defines with their replacements in the
source code.
2014-01-12 21:11:31 -05:00
Joseph Kogut
21198a8282 Added preprocessor 2013-02-08 13:51:01 -07:00
Joseph Kogut
eac3bc4291 *Split parsing functions into their own source files
*Removed unused Makefile variables
2013-02-07 10:54:22 -07:00
Joseph Kogut
cc39eadc9e Fixed typo in tvm_program.c 2013-02-07 10:13:15 -07:00
Joseph Kogut
25cc724b33 *Updated variable declarations and definitions to C99 standard
*Removed some excessive conditional nesting
2013-02-06 11:47:13 -07:00
Joseph Kogut
ed3acfd515 Made naming conventions more consistent. 2013-01-23 11:15:07 -07:00
Joseph Kogut
d270cc5706 Made pointer syntax consistent 2013-01-23 11:06:19 -07:00
Joseph Kogut
19a48f04ee Moved memory allocation for new instructions into tvm_program.c, parse_instructions() 2011-09-26 03:09:15 -07:00
Bl0ckeduser
d9e3f942f5 Safety-check free()s in destroy_program 2011-09-25 15:35:03 -04:00
Joseph Kogut
6fb039da4a Refactored parsing of register tokens 2011-09-08 09:43:45 -07:00
Joseph Kogut
7a128d41ec Added break and step to tdb 2011-09-02 02:05:17 -07:00
Joseph Kogut
baf6df7c00 Added eight more general purpose registers (r08 - r15) 2011-08-27 13:00:01 -07:00
Joseph Kogut
15019d041f * Moved TVM code to an independent library
* Moved interpreter code to tvmi.c
2011-08-26 15:30:24 -07:00
Renamed from tvm_program.c (Browse further)