T.I.M | Toolchain Documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
asm_lex.h File Reference

Header file for data types and functions used by the asm code lexer. More...

Go to the source code of this file.

Data Structures

struct  asm_lex_token
 Typedef for the asm lexer token structure. More...
 
union  asm_lex_token_value
 Union to hold the correct value of an instruction. More...
 
#define lex_tok_LOAD   "LOAD"
 
#define lex_tok_STORE   "STORE"
 
#define lex_tok_PUSH   "PUSH"
 
#define lex_tok_POP   "POP"
 
#define lex_tok_MOV   "MOV"
 
#define lex_tok_JUMP   "JUMP"
 
#define lex_tok_CALL   "CALL"
 
#define lex_tok_RETURN   "RETURN"
 
#define lex_tok_TEST   "TEST"
 
#define lex_tok_HALT   "HALT"
 
#define lex_tok_AND   "AND"
 
#define lex_tok_NAND   "NAND"
 
#define lex_tok_OR   "OR"
 
#define lex_tok_NOR   "NOR"
 
#define lex_tok_XOR   "XOR"
 
#define lex_tok_LSL   "LSL"
 
#define lex_tok_LSR   "LSR"
 
#define lex_tok_NOT   "NOT"
 
#define lex_tok_IADD   "IADD"
 
#define lex_tok_ISUB   "ISUB"
 
#define lex_tok_IMUL   "IMUL"
 
#define lex_tok_IDIV   "IDIV"
 
#define lex_tok_IASR   "IASR"
 
#define lex_tok_FADD   "FADD"
 
#define lex_tok_FSUB   "FSUB"
 
#define lex_tok_FMUL   "FMUL"
 
#define lex_tok_FDIV   "FDIV"
 
#define lex_tok_FASR   "FASR"
 
#define lex_tok_NOP   "NOP"
 
#define lex_tok_SLEEP   "SLEEP"
 
#define lex_tok_DATA   "DATA"
 
enum  asm_lex_opcode {
  LEX_LOAD = 1, LEX_STORE = 2, LEX_PUSH = 3, LEX_POP = 4,
  LEX_MOV = 5, LEX_JUMP = 6, LEX_CALL = 7, LEX_RETURN = 8,
  LEX_TEST = 9, LEX_HALT = 10, LEX_AND = 11, LEX_NAND = 12,
  LEX_OR = 13, LEX_NOR = 14, LEX_XOR = 15, LEX_LSL = 16,
  LEX_LSR = 17, LEX_NOT = 18, LEX_IADD = 19, LEX_ISUB = 20,
  LEX_IMUL = 21, LEX_IDIV = 22, LEX_IASR = 23, LEX_FADD = 24,
  LEX_FSUB = 25, LEX_FMUL = 26, LEX_FDIV = 27, LEX_FASR = 28,
  LEX_NOP = 29, LEX_SLEEP = 30, LEX_DATA = 31, LEX_ERROR = 32
}
 
enum  asm_lex_token_type {
  OPCODE, LABEL, REGISTER, IMMEDIATE,
  CONDITION
}
 The type of token that a lexer token can be. More...
 
typedef char asm_lex_label
 Type mask for a character array. More...
 
asm_lex_token * asm_lex_input_file (FILE *input, int *errors)
 Parses an entire input file into a single lexical token stream. More...
 

Detailed Description

Header file for data types and functions used by the asm code lexer.

Macro Definition Documentation

#define lex_tok_AND   "AND"

Referenced by asm_lex_instruction().

#define lex_tok_CALL   "CALL"

Referenced by asm_lex_instruction().

#define lex_tok_DATA   "DATA"

Referenced by asm_lex_instruction().

#define lex_tok_FADD   "FADD"

Referenced by asm_lex_instruction().

#define lex_tok_FASR   "FASR"

Referenced by asm_lex_instruction().

#define lex_tok_FDIV   "FDIV"

Referenced by asm_lex_instruction().

#define lex_tok_FMUL   "FMUL"

Referenced by asm_lex_instruction().

#define lex_tok_FSUB   "FSUB"

Referenced by asm_lex_instruction().

#define lex_tok_HALT   "HALT"

Referenced by asm_lex_instruction().

#define lex_tok_IADD   "IADD"

Referenced by asm_lex_instruction().

#define lex_tok_IASR   "IASR"

Referenced by asm_lex_instruction().

#define lex_tok_IDIV   "IDIV"

Referenced by asm_lex_instruction().

#define lex_tok_IMUL   "IMUL"

Referenced by asm_lex_instruction().

#define lex_tok_ISUB   "ISUB"

Referenced by asm_lex_instruction().

#define lex_tok_JUMP   "JUMP"

Referenced by asm_lex_instruction().

#define lex_tok_LOAD   "LOAD"

Referenced by asm_lex_instruction().

#define lex_tok_LSL   "LSL"

Referenced by asm_lex_instruction().

#define lex_tok_LSR   "LSR"

Referenced by asm_lex_instruction().

#define lex_tok_MOV   "MOV"

Referenced by asm_lex_instruction().

#define lex_tok_NAND   "NAND"

Referenced by asm_lex_instruction().

#define lex_tok_NOP   "NOP"

Referenced by asm_lex_instruction().

#define lex_tok_NOR   "NOR"

Referenced by asm_lex_instruction().

#define lex_tok_NOT   "NOT"

Referenced by asm_lex_instruction().

#define lex_tok_OR   "OR"

Referenced by asm_lex_instruction().

#define lex_tok_POP   "POP"

Referenced by asm_lex_instruction().

#define lex_tok_PUSH   "PUSH"

Referenced by asm_lex_instruction().

#define lex_tok_RETURN   "RETURN"

Referenced by asm_lex_instruction().

#define lex_tok_SLEEP   "SLEEP"

Referenced by asm_lex_instruction().

#define lex_tok_STORE   "STORE"

Referenced by asm_lex_instruction().

#define lex_tok_TEST   "TEST"

Referenced by asm_lex_instruction().

#define lex_tok_XOR   "XOR"

Referenced by asm_lex_instruction().

Typedef Documentation

typedef char asm_lex_label

Type mask for a character array.

Enumeration Type Documentation

Enumerator
LEX_LOAD 
LEX_STORE 
LEX_PUSH 
LEX_POP 
LEX_MOV 
LEX_JUMP 
LEX_CALL 
LEX_RETURN 
LEX_TEST 
LEX_HALT 
LEX_AND 
LEX_NAND 
LEX_OR 
LEX_NOR 
LEX_XOR 
LEX_LSL 
LEX_LSR 
LEX_NOT 
LEX_IADD 
LEX_ISUB 
LEX_IMUL 
LEX_IDIV 
LEX_IASR 
LEX_FADD 
LEX_FSUB 
LEX_FMUL 
LEX_FDIV 
LEX_FASR 
LEX_NOP 
LEX_SLEEP 
LEX_DATA 
LEX_ERROR 

The type of token that a lexer token can be.

Enumerator
OPCODE 
LABEL 
REGISTER 
IMMEDIATE 
CONDITION 

Function Documentation

asm_lex_token* asm_lex_input_file ( FILE *  input,
int *  errors 
)

Parses an entire input file into a single lexical token stream.

Parameters
input- The input file with the seeker at the beginning of the file.
errors- pointer to an error counter.
Returns
The head of a linked list of lexer tokens representing the parsed file.

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().