C to Capua ASM compiler#34
Conversation
|
Mind adding an example C file to examples to show off all the features? |
|
Currently looking at this. A C implementation of LoneBall could be a cool thing for testing and validation. |
| currentMethod = "" # String containing the current method being evaluated | ||
| expectFlag = 0 # Used to control what input we expect next | ||
| mathFormula = "" # Will contain our fully assembled math expressions for variable assignments | ||
| memoryLocation = 0x40000000 # Memory location for local variables. |
There was a problem hiding this comment.
I feel this address should be in a constant somewhere.
There was a problem hiding this comment.
The memory location isn't a constant in this context. It increases every new variable assignment. Perhaps I could have it as a constant, and have another global variable take its initial value?
There was a problem hiding this comment.
I do feel it would be better.
| :return: | ||
| """ | ||
|
|
||
| if self.state == 0: |
There was a problem hiding this comment.
The various states should be defined in constants with appropriate naming. This would make code easier to read.
There was a problem hiding this comment.
Will do
| mathFormula = "" # Will contain our fully assembled math expressions for variable assignments | ||
| memoryLocation = 0x40000000 # Memory location for local variables. | ||
| varList = [] # Contains a list of variable names | ||
| varLocation = {} # Contains the memory location for all variables |
There was a problem hiding this comment.
Although I am not done looking/testing this code, I do feel like a relatively large number of these variables don't have to be global to a given object.
| """ | ||
| Here we expect to read the method's name. Once we reach a space or an opening parentheses, we add the method | ||
| to the methodlist along with its data type. | ||
| TODO: figure out a way to have the main method printed first in the .casm file |
There was a problem hiding this comment.
A tree structure starting from main would work ;)
It would also deal with the issue of dead code (in the case a full function is not called)
There was a problem hiding this comment.
Obviously something would also need to be worked out for libraries in that case.
|
Just read the example C file. Looks like this is really shaping up! Great work Chris LeBlanc (@kommisar5150) |
First draft of a compiler that converts C code to .casm. Functionality is documented in the CompilerInfo.md file. Makes use of infix/postfix parsing for math expressions, and a pseudo FSM model to determine expected input.