T.I.M | Toolchain Documentation
|
Contains all functions relating to parsing the source code into IR data structure. More...
#include "asm.h"
Functions | |
asm_lex_token * | asm_parse_call_jump (asm_statement *statement, asm_lex_token *token, int *errors) |
Responsible for parsing Jump and call instructions. More... | |
asm_lex_token * | asm_parse_three_register_operands (asm_statement *statement, asm_lex_token *token, int *errors) |
Responsible for parsing instructions with three register operands. More... | |
asm_lex_token * | asm_parse_two_register_one_immediate (asm_statement *statement, asm_lex_token *token, int *errors) |
Responsible for parsing instructions with two register operands and one immediate operand. More... | |
asm_lex_token * | asm_parse_three_operand (asm_statement *statement, asm_lex_token *token, int *errors) |
Responsible for parsing instructions with three operands.. More... | |
asm_lex_token * | asm_parse_two_operand (asm_statement *statement, asm_lex_token *token, int *errors) |
Parses instructions that take two operands. NOT, TEST, MOV. More... | |
asm_lex_token * | asm_parse_data (asm_statement *statement, asm_lex_token *token, int *errors) |
Responsible for parsing DATA elements. More... | |
asm_lex_token * | asm_parse_sleep (asm_statement *statement, asm_lex_token *token, int *errors) |
Responsible for parsing SLEEP instructions. More... | |
asm_lex_token * | asm_parse_nop (asm_statement *statement, asm_lex_token *token, int *errors) |
Responsible for parsing NOP instructions. More... | |
asm_lex_token * | asm_parse_push_pop (asm_statement *statement, asm_lex_token *token, int *errors) |
Responsible for parsing PUSH and POP instructions. More... | |
asm_lex_token * | asm_parse_opcode (asm_statement *statement, asm_lex_token *token, int *errors) |
Responsible for selecting which function should parse the next few tokens.:w. More... | |
asm_lex_token * | asm_parse_label_declaration (asm_lex_token *token, asm_hash_table *labels, int *errors, asm_statement *statement) |
Responsible for adding a label declaration and associated statement to the symbol table. More... | |
asm_statement * | asm_parse_token_stream (asm_lex_token *tokens, asm_hash_table *labels, int *errors) |
Top function to trigger the parsing of an input source file. More... | |
Contains all functions relating to parsing the source code into IR data structure.
asm_lex_token* asm_parse_call_jump | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Responsible for parsing Jump and call instructions.
[in,out] | statement | - Resulting statment to set members of. |
[in] | token | - The token which to parse into a statement. Several subsequent tokens may also be eaten. |
errors | - Error counter pointer. |
References CALLI, CALLR, error, IMMEDIATE, JUMPI, JUMPR, LABEL, LEX_CALL, LEX_JUMP, opcode, REGISTER, size, and TRUE.
Referenced by asm_parse_opcode().
asm_lex_token* asm_parse_data | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Responsible for parsing DATA elements.
[in,out] | statement | - Resulting statment to set members of. |
[in] | token | - The token which to parse into a statement. Several subsequent tokens may also be eaten. |
errors | - Error counter pointer. |
References error, FALSE, IMMEDIATE, LABEL, NOT_EMITTED, opcode, size, and TRUE.
Referenced by asm_parse_opcode().
asm_lex_token* asm_parse_label_declaration | ( | asm_lex_token * | token, |
asm_hash_table * | labels, | ||
int * | errors, | ||
asm_statement * | statement | ||
) |
Responsible for adding a label declaration and associated statement to the symbol table.
token | - The token containing the label value |
labels | - The symbol table. |
errors | - Pointer to an error counter. |
References asm_hash_table_insert(), and LABEL.
Referenced by asm_parse_token_stream().
asm_lex_token* asm_parse_nop | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Responsible for parsing NOP instructions.
NOP is actually a pseudo instruction which assembles into ANDR $R0 $R0 $R0
[in,out] | statement | - Resulting statment to set members of. |
[in] | token | - The token which to parse into a statement. Several subsequent tokens may also be eaten. |
errors | - Error counter pointer. |
References ANDR, opcode, R0, and size.
Referenced by asm_parse_opcode().
asm_lex_token* asm_parse_opcode | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Responsible for selecting which function should parse the next few tokens.:w.
token | - The token containing the label value |
statement | - The statement to parse the tokens into. |
errors | - Pointer to an error counter. |
References asm_parse_call_jump(), asm_parse_data(), asm_parse_nop(), asm_parse_push_pop(), asm_parse_sleep(), asm_parse_three_operand(), asm_parse_two_operand(), error, HALT, LEX_AND, LEX_CALL, LEX_DATA, LEX_ERROR, LEX_FADD, LEX_FASR, LEX_FDIV, LEX_FMUL, LEX_FSUB, LEX_HALT, LEX_IADD, LEX_IASR, LEX_IDIV, LEX_IMUL, LEX_ISUB, LEX_JUMP, LEX_LOAD, LEX_LSL, LEX_LSR, LEX_MOV, LEX_NAND, LEX_NOP, LEX_NOR, LEX_NOT, LEX_OR, LEX_POP, LEX_PUSH, LEX_RETURN, LEX_SLEEP, LEX_STORE, LEX_TEST, LEX_XOR, OPCODE, opcode, RETURN, size, and warning.
Referenced by asm_parse_token_stream().
asm_lex_token* asm_parse_push_pop | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Responsible for parsing PUSH and POP instructions.
[in,out] | statement | - Resulting statment to set members of. |
[in] | token | - The token which to parse into a statement. Several subsequent tokens may also be eaten. |
errors | - Error counter pointer. |
References error, LEX_POP, LEX_PUSH, opcode, POP, PUSH, and size.
Referenced by asm_parse_opcode().
asm_lex_token* asm_parse_sleep | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Responsible for parsing SLEEP instructions.
[in,out] | statement | - Resulting statment to set members of. |
[in] | token | - The token which to parse into a statement. Several subsequent tokens may also be eaten. |
errors | - Error counter pointer. |
References opcode, size, and SLEEP.
Referenced by asm_parse_opcode().
asm_lex_token* asm_parse_three_operand | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Responsible for parsing instructions with three operands..
[in,out] | statement | - Resulting statment to set members of. |
[in] | token | - The token which to parse into a statement. Several subsequent tokens may also be eaten. |
errors | - Error counter pointer. |
References asm_parse_three_register_operands(), asm_parse_two_register_one_immediate(), error, IMMEDIATE, opcode, and REGISTER.
Referenced by asm_parse_opcode().
asm_lex_token* asm_parse_three_register_operands | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Responsible for parsing instructions with three register operands.
[in,out] | statement | - Resulting statment to set members of. |
[in] | token | - The token which to parse into a statement. Several subsequent tokens may also be eaten. |
errors | - Error counter pointer. |
References ANDR, error, FADDR, FASRR, FDIVR, FMULR, FSUBR, IADDR, IASRR, IDIVR, IMULR, ISUBR, LEX_AND, LEX_ERROR, LEX_FADD, LEX_FASR, LEX_FDIV, LEX_FMUL, LEX_FSUB, LEX_IADD, LEX_IASR, LEX_IDIV, LEX_IMUL, LEX_ISUB, LEX_LOAD, LEX_LSL, LEX_LSR, LEX_NAND, LEX_NOR, LEX_OR, LEX_STORE, LEX_XOR, LOADR, LSLR, LSRR, NANDR, NORR, OPCODE, opcode, ORR, REGISTER, size, STORR, and XORR.
Referenced by asm_parse_three_operand().
asm_statement* asm_parse_token_stream | ( | asm_lex_token * | tokens, |
asm_hash_table * | labels, | ||
int * | errors | ||
) |
Top function to trigger the parsing of an input source file.
Takes an opened for reading text file and parses it into a series of asm statements, filling out their arguments and parameters as it goes. It also populates the hash-table of labels used for calculating jump target addresses.
[in,out] | labels | - Hashtable which is apopulated with any encountered labels. |
[in,out] | errors | - Pointer to a error counter. If the counter has the same value before |
tokens | - Linked list of tokens to parse into a program IR. and after being called, all of the parsing was a success. |
References ALWAYS, asm_parse_label_declaration(), asm_parse_opcode(), CONDITION, error, LABEL, and OPCODE.
Referenced by main().
asm_lex_token* asm_parse_two_operand | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Parses instructions that take two operands. NOT, TEST, MOV.
[in,out] | statement | - Resulting statment to set members of. |
[in] | token | - The token which to parse into a statement. Several subsequent tokens may also be eaten. |
errors | - Error counter pointer. |
References error, IMMEDIATE, LEX_MOV, LEX_NOT, LEX_TEST, MOVR, NOTR, opcode, size, and TEST.
Referenced by asm_parse_opcode().
asm_lex_token* asm_parse_two_register_one_immediate | ( | asm_statement * | statement, |
asm_lex_token * | token, | ||
int * | errors | ||
) |
Responsible for parsing instructions with two register operands and one immediate operand.
[in,out] | statement | - Resulting statment to set members of. |
[in] | token | - The token which to parse into a statement. Several subsequent tokens may also be eaten. |
errors | - Error counter pointer. |
References ANDI, error, FADDI, FASRI, FDIVI, FMULI, FSUBI, IADDI, IASRI, IDIVI, IMMEDIATE, IMULI, ISUBI, LEX_AND, LEX_ERROR, LEX_FADD, LEX_FASR, LEX_FDIV, LEX_FMUL, LEX_FSUB, LEX_IADD, LEX_IASR, LEX_IDIV, LEX_IMUL, LEX_ISUB, LEX_LOAD, LEX_LSL, LEX_LSR, LEX_NAND, LEX_NOR, LEX_OR, LEX_STORE, LEX_XOR, LOADI, LSLI, LSRI, NANDI, NORI, OPCODE, opcode, ORI, REGISTER, size, STORI, and XORI.
Referenced by asm_parse_three_operand().