#include <CalcLexer.h>
Public Member Functions | |
CalcLexer () | |
Constructs a new Calculator Lexer object. | |
int | yylex () |
The lexical analzyer function. | |
int | getPosition () const |
Returns the character position of the next token. | |
int | getColumn () const |
Returns the column number of the next token. | |
CalcYYLocType & | getLocation () |
Returns the location of the current token. | |
CalcTokenValue & | getValue () |
Returns the semantic value of the current token. | |
void | LexerError (const char *msg) |
Reports a fatal error message by throwing a CalcAssemblerException. | |
Protected Member Functions | |
void | updateLocation () |
Updates the location of the current token. | |
int | hex (char ch) |
string | hex2string (const char *buf, uint buflen) |
Protected Attributes | |
int | yycolno |
The column number of the next token. | |
int | yylineno |
The line number of the next token. | |
int | yypos |
The character position (starting from 0) of the next token. | |
CalcTokenValue | yylval |
The sematic value of the current token. | |
CalcYYLocType | yyloc |
The location of the current token. |
The class is automatically generated by flex from CalcLexer.lpp.
Definition at line 89 of file CalcLexer.h.
CalcLexer::CalcLexer | ( | ) | [inline, explicit] |
int CalcLexer::yylex | ( | ) |
The lexical analzyer function.
It scans the input stream, consuming tokens, until a rule's action returns a value
Referenced by CalcYYlex().
int CalcLexer::getPosition | ( | ) | const [inline] |
Returns the character position of the next token.
Definition at line 102 of file CalcLexer.h.
00102 { return yypos; }
int CalcLexer::getColumn | ( | ) | const [inline] |
Returns the column number of the next token.
Definition at line 104 of file CalcLexer.h.
00104 { return yycolno; }
CalcYYLocType& CalcLexer::getLocation | ( | ) | [inline] |
Returns the location of the current token.
Definition at line 106 of file CalcLexer.h.
Referenced by CalcAssembler::assemble(), CalcAssembler::bindLiteralDone(), CalcYYlex(), CalcAssembler::getRegister(), hex(), hex2string(), and LexerError().
00106 { return yyloc; }
CalcTokenValue& CalcLexer::getValue | ( | ) | [inline] |
Returns the semantic value of the current token.
Definition at line 108 of file CalcLexer.h.
Referenced by CalcYYlex().
00108 { return yylval; }
void CalcLexer::LexerError | ( | const char * | msg | ) |
Reports a fatal error message by throwing a CalcAssemblerException.
Definition at line 4558 of file CalcLexer.cpp.
References getLocation().
04559 { 04560 throw CalcAssemblerException(msg, getLocation()); 04561 }
void CalcLexer::updateLocation | ( | ) | [protected] |
Updates the location of the current token.
The location of the current token is calculated prior to every matched rule's action as part of the YY_USER_ACTION macro.
Definition at line 4543 of file CalcLexer.cpp.
References CalcYYLocType::first_column, CalcYYLocType::first_line, CalcYYLocType::first_pos, CalcYYLocType::last_column, CalcYYLocType::last_line, CalcYYLocType::last_pos, yycolno, yyleng, yylineno, yyloc, and yypos.
04544 { 04545 /* 04546 * This function does not handle tokens that span multiple lines. 04547 */ 04548 yyloc.first_line = yylineno; 04549 yyloc.first_column = yycolno; 04550 yyloc.first_pos = yypos; 04551 yycolno += yyleng; 04552 yypos += yyleng; 04553 yyloc.last_line = yylineno; 04554 yyloc.last_column = yycolno-1; 04555 yyloc.last_pos = yypos-1; 04556 }
int CalcLexer::hex | ( | char | ch | ) | [protected] |
Definition at line 4563 of file CalcLexer.cpp.
References getLocation().
Referenced by hex2string().
04564 { 04565 if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10); 04566 else if ((ch >= '0') && (ch <= '9')) return (ch-'0'); 04567 else if ((ch >= 'A') && (ch <= 'F')) return (ch-'A'+10); 04568 else throw CalcAssemblerException("Invalid hex character", getLocation()); 04569 }
string CalcLexer::hex2string | ( | const char * | buf, | |
uint | buflen | |||
) | [protected] |
Definition at line 4572 of file CalcLexer.cpp.
References count(), getLocation(), and hex().
04573 { 04574 int i, count; 04575 unsigned char ch; 04576 04577 assert(buf != NULL); 04578 if ((buflen % 2) != 0) { 04579 throw CalcAssemblerException("Invalid hex encoded string", getLocation()); 04580 } 04581 04582 count = buflen/2; 04583 04584 string str(count, 0); 04585 04586 for (i=0; i<count; i++) { 04587 ch = hex(*buf++) << 4; 04588 ch = ch + hex(*buf++); 04589 str[i] = ch; 04590 } 04591 return str; 04592 }
int CalcLexer::yycolno [protected] |
The column number of the next token.
Definition at line 123 of file CalcLexer.h.
Referenced by updateLocation().
int CalcLexer::yylineno [protected] |
The line number of the next token.
Definition at line 125 of file CalcLexer.h.
Referenced by updateLocation().
int CalcLexer::yypos [protected] |
The character position (starting from 0) of the next token.
Definition at line 127 of file CalcLexer.h.
Referenced by updateLocation().
CalcTokenValue CalcLexer::yylval [protected] |
CalcYYLocType CalcLexer::yyloc [protected] |
The location of the current token.
Definition at line 131 of file CalcLexer.h.
Referenced by updateLocation().