Updated link in README file.
[Hack-Assembler.git] / parse.h
blob054cf5af65abcfedbf6e304320afe5fcb64836fd
1 #define MAXCOMMAND 100
2 #define MAXINBUFF 250000
3 #define MAXSYMBOL 256
5 #define pInBuff *(InBuff+i)
7 /*
8 * A_COMMAND: @value
9 * value is either a non-negative decimal numer of a symbol referring to such a number
11 * C_COMMAND: dest = comp; jump
12 * either of the dest or jump fields may be empty
13 * if dest is empty, the "=" is omitted
14 * if jump is emprty, the ";" is omitted
16 #define A_COMMAND 0
17 #define C_COMMAND 1
18 #define L_COMMAND 2
20 void dump_buffer();
23 * Resets command pointer to beginning of input buffer.
25 void reset_buffer();
27 void init_parser(char *FilenameBuff);
30 * Finds current line number of source file.
31 * This is done for the convenience of the user.
33 int find_line_num();
36 * Search current command for term.
37 * Ignores whitespace. Looks for one char only.
39 int search_command(const char *current_command, const char term);
42 * Print chars of current command to stdout.
44 void print_current_command();
47 * Confirms the existance of more commands in the input
49 int has_more_commands();
52 * Read next command from input and makes it the current command
53 * Should be called only if has_more_commands() is true
54 * Initialy there is no current command
56 void advance();
59 * Returns type of current command
60 * See Commands comment for more info
62 int command_type();
65 * Returns symbol or decimal of current command
66 * Should be called only when command_type() is A_COMMAND or L_COMMAND
68 int symbol();
71 * Reads command and finds symbol chars. Loads into hash
73 int symbol_load();
76 * Returns the dest mnemonic in the current C_COMMAND
77 * Should be called only when command_type() is C_COMMAND
79 int dest(char dest[]);
82 * Returns comp mnemonic in the current C_COMMAND
83 * Called only when command_type() is C_COMMAND
85 int comp(char comp[]);
88 * Returns the jump mnemonic in the current C_COMMAND
89 * Called only when command_type() is C_COMMAND
91 int jump(char jump[]);