T.I.M | Toolchain Documentation
|
Contains all functions for turning an input text file into a token stream. More...
Functions | |
char * | asm_lex_file_readline (FILE *source) |
reads and returns the rest of the current line in the file from the current cursor position. More... | |
tim_register | asm_lex_register (char *str, int *errors, unsigned int line_number) |
Takes a three letter string and returns either an assembly register code or NO_REG if the character code is invalid. More... | |
tim_immediate | asm_lex_immediate (char *immediate, int *errors, int line_num) |
Parses a character array into an asm_immediate and returns it as a 32 bit integer. More... | |
asm_lex_opcode | asm_lex_instruction (char *instruction, int *errors, int line_num) |
parses a string instruction into its token typed declaration. More... | |
asm_lex_token * | asm_lex_input_file (FILE *input, int *errors) |
Parses an entire input file into a single lexical token stream. More... | |
Contains all functions for turning an input text file into a token stream.
char* asm_lex_file_readline | ( | FILE * | source | ) |
reads and returns the rest of the current line in the file from the current cursor position.
[in] | source | - The opened source code file. |
Referenced by asm_lex_input_file().
tim_immediate asm_lex_immediate | ( | char * | immediate, |
int * | errors, | ||
int | line_num | ||
) |
Parses a character array into an asm_immediate and returns it as a 32 bit integer.
[in] | immediate | - The character representation of the immediate value. |
[in,out] | errors | - pointer to an error counter for syntax errors. |
[in] | line_num | - The line number of the instruction, used for error reporting. |
References error.
Referenced by asm_lex_input_file().
asm_lex_token* asm_lex_input_file | ( | FILE * | input, |
int * | errors | ||
) |
Parses an entire input file into a single lexical token stream.
input | - The input file with the seeker at the beginning of the file. |
errors | - pointer to an error counter. |
References ALWAYS, asm_lex_file_readline(), asm_lex_immediate(), asm_lex_instruction(), asm_lex_register(), CONDITION, error, IFFALSE, IFTRUE, IFZERO, IMMEDIATE, LABEL, LEX_ERROR, OPCODE, and REGISTER.
Referenced by main().
asm_lex_opcode asm_lex_instruction | ( | char * | instruction, |
int * | errors, | ||
int | line_num | ||
) |
parses a string instruction into its token typed declaration.
instruction | - head of the string containing the token |
errors | - Pointer to an error counter. |
line_num | - The line number of the token being parsed. Helps with error reporting. |
References 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_tok_AND, lex_tok_CALL, lex_tok_DATA, lex_tok_FADD, lex_tok_FASR, lex_tok_FDIV, lex_tok_FMUL, lex_tok_FSUB, lex_tok_HALT, lex_tok_IADD, lex_tok_IASR, lex_tok_IDIV, lex_tok_IMUL, lex_tok_ISUB, lex_tok_JUMP, lex_tok_LOAD, lex_tok_LSL, lex_tok_LSR, lex_tok_MOV, lex_tok_NAND, lex_tok_NOP, lex_tok_NOR, lex_tok_NOT, lex_tok_OR, lex_tok_POP, lex_tok_PUSH, lex_tok_RETURN, lex_tok_SLEEP, lex_tok_STORE, lex_tok_TEST, lex_tok_XOR, and LEX_XOR.
Referenced by asm_lex_input_file().
tim_register asm_lex_register | ( | char * | str, |
int * | errors, | ||
unsigned int | line_number | ||
) |
Takes a three letter string and returns either an assembly register code or NO_REG if the character code is invalid.
str | - Pointer to the head of a string to check. |
References error, IR, IS, LR, PC, R0, R1, R10, R11, R12, R13, R14, R15, R2, R3, R4, R5, R6, R7, R8, R9, REG_ERROR, SP, SR, T0, T1, T2, T3, T4, T5, T6, T7, and TR.
Referenced by asm_lex_input_file().