Skip to content
Snippets Groups Projects
Commit a90cb6dc authored by Jan Travnicek's avatar Jan Travnicek
Browse files

operators Lexing redesign

parent df8c979e
No related branches found
No related tags found
1 merge request!117Merge jt
......@@ -33,13 +33,13 @@ q0: if ( m_source.getCharacter ( ) == EOF ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::LESS_SIGN;
return res;
goto q10;
}
if ( m_source.getCharacter ( ) == '>' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::MORE_SIGN;
return res;
goto q11;
}
if ( m_source.getCharacter ( ) == '(' ) {
res.m_raw += m_source.getCharacter ( );
......@@ -93,13 +93,13 @@ q0: if ( m_source.getCharacter ( ) == EOF ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::AMPERSAND_SIGN;
return res;
goto q8;
}
if ( m_source.getCharacter ( ) == '|' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::PIPE_SIGN;
return res;
goto q9;
}
if ( m_source.getCharacter ( ) == '^' ) {
res.m_raw += m_source.getCharacter ( );
......@@ -122,8 +122,8 @@ q0: if ( m_source.getCharacter ( ) == EOF ) {
if ( m_source.getCharacter ( ) == '=' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::EQUAL_SIGN;
return res;
res.m_type = TokenType::ASSIGN_OPERATOR;
goto q12;
}
if ( m_source.getCharacter ( ) == '#' ) {
res.m_raw += m_source.getCharacter ( );
......@@ -147,7 +147,7 @@ q0: if ( m_source.getCharacter ( ) == EOF ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::PLUS_SIGN;
return res;
goto q7;
}
if ( m_source.getCharacter ( ) == '/' ) {
res.m_raw += m_source.getCharacter ( );
......@@ -171,7 +171,7 @@ q0: if ( m_source.getCharacter ( ) == EOF ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::EXCLAMATION_SIGN;
return res;
goto q13;
}
if ( m_source.getCharacter ( ) == '%' ) {
res.m_raw += m_source.getCharacter ( );
......@@ -230,12 +230,18 @@ q1: if ( m_source.getCharacter ( ) == '\0' ) {
res.m_type = TokenType::INTEGER;
return res;
}
q2: if ( m_source.getCharacter ( ) == '\0' ) {
q2:
if ( m_source.getCharacter ( ) == '\0' ) {
res.m_value = "";
res.m_type = TokenType::MINUS_SIGN;
return res;
}
if ( m_source.getCharacter ( ) == '-' ) {
res.m_raw += m_source.getCharacter ( );
res.m_value += m_source.getCharacter ( );
m_source.advance ( readNextLine );
goto q2Prime;
}
if ( ( m_source.getCharacter ( ) >= '0' && m_source.getCharacter ( ) <= '9' ) ) {
res.m_raw += m_source.getCharacter ( );
res.m_value += m_source.getCharacter ( );
......@@ -260,6 +266,36 @@ q2: if ( m_source.getCharacter ( ) == '\0' ) {
res.m_type = TokenType::MINUS_SIGN;
return res;
 
q2Prime:
if ( m_source.getCharacter ( ) == '\0' ) {
res.m_value = "";
res.m_type = TokenType::DEC_OPERATOR;
return res;
}
if ( ( m_source.getCharacter ( ) >= '0' && m_source.getCharacter ( ) <= '9' ) ) {
res.m_raw += m_source.getCharacter ( );
res.m_value += m_source.getCharacter ( );
m_source.advance ( readNextLine );
goto q1;
}
if ( ( m_source.getCharacter ( ) >= 'a' && m_source.getCharacter ( ) <= 'z' )
|| ( m_source.getCharacter ( ) >= 'A' && m_source.getCharacter ( ) <= 'Z' )
|| ( m_source.getCharacter ( ) == ':' ) ) {
res.m_raw += m_source.getCharacter ( );
res.m_value += m_source.getCharacter ( );
m_source.advance ( readNextLine );
goto q3;
} else if ( m_source.getCharacter ( ) == '\\' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( true );
goto q3Escape;
}
res.m_value = "";
res.m_type = TokenType::DEC_OPERATOR;
return res;
q3: if ( m_source.getCharacter ( ) == '\0' ) {
res.m_type = is_kw ( res.m_value );
return res;
......@@ -350,6 +386,108 @@ q6: if ( m_source.getCharacter ( ) == '\0' ) {
return res;
}
 
q7: if ( m_source.getCharacter ( ) == EOF ) {
return res;
}
if ( m_source.getCharacter ( ) == '\0' ) {
return res;
}
if ( m_source.getCharacter ( ) == '+' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::INC_OPERATOR;
} else {
return res;
}
q8: if ( m_source.getCharacter ( ) == EOF ) {
return res;
}
if ( m_source.getCharacter ( ) == '\0' ) {
return res;
}
if ( m_source.getCharacter ( ) == '&' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::AND_OPERATOR;
} else {
return res;
}
q9: if ( m_source.getCharacter ( ) == EOF ) {
return res;
}
if ( m_source.getCharacter ( ) == '\0' ) {
return res;
}
if ( m_source.getCharacter ( ) == '|' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::OR_OPERATOR;
} else {
return res;
}
q10:
if ( m_source.getCharacter ( ) == EOF ) {
return res;
}
if ( m_source.getCharacter ( ) == '\0' ) {
return res;
}
if ( m_source.getCharacter ( ) == '=' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::LESS_OR_EQUAL_OPERATOR;
} else {
return res;
}
q11:
if ( m_source.getCharacter ( ) == EOF ) {
return res;
}
if ( m_source.getCharacter ( ) == '\0' ) {
return res;
}
if ( m_source.getCharacter ( ) == '=' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::MORE_OR_EQUAL_OPERATOR;
} else {
return res;
}
q12:
if ( m_source.getCharacter ( ) == EOF ) {
return res;
}
if ( m_source.getCharacter ( ) == '\0' ) {
return res;
}
if ( m_source.getCharacter ( ) == '=' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::EQUAL_OPERATOR;
} else {
return res;
}
q13:
if ( m_source.getCharacter ( ) == EOF ) {
return res;
}
if ( m_source.getCharacter ( ) == '\0' ) {
return res;
}
if ( m_source.getCharacter ( ) == '=' ) {
res.m_raw += m_source.getCharacter ( );
m_source.advance ( readNextLine );
res.m_type = TokenType::NOT_EQUAL_OPERATOR;
} else {
return res;
}
qFile:
if ( m_source.getCharacter ( ) == EOF ) {
res.m_type = TokenType::EOT;
......
......@@ -31,7 +31,9 @@ public:
INTEGER,
STRING,
LESS_SIGN,
LESS_OR_EQUAL_OPERATOR,
MORE_SIGN,
MORE_OR_EQUAL_OPERATOR,
LEFT_PAREN,
RIGHT_PAREN,
LEFT_BRACE,
......@@ -41,18 +43,24 @@ public:
DOLAR_SIGN,
AT_SIGN,
AMPERSAND_SIGN,
AND_OPERATOR,
PIPE_SIGN,
OR_OPERATOR,
CARET_SIGN,
COLON_SIGN,
SEMICOLON_SIGN,
MINUS_SIGN,
DEC_OPERATOR,
PLUS_SIGN,
INC_OPERATOR,
SLASH_SIGN,
STAR_SIGN,
TYLDE_SIGN,
EXCLAMATION_SIGN,
PERCENTAGE_SIGN,
EQUAL_SIGN,
ASSIGN_OPERATOR,
EQUAL_OPERATOR,
NOT_EQUAL_OPERATOR,
HASH_SIGN,
COMMA,
DOT,
......@@ -76,9 +84,13 @@ public:
case TokenType::STRING :
return "string";
case TokenType::LESS_SIGN :
return "in_redirect";
return "less_sign";
case TokenType::LESS_OR_EQUAL_OPERATOR :
return "less_or_equal_operator";
case TokenType::MORE_SIGN :
return "out_redirect";
return "more_sign";
case TokenType::MORE_OR_EQUAL_OPERATOR :
return "more_or_equal_operator";
case TokenType::LEFT_PAREN :
return "left_paren";
case TokenType::RIGHT_PAREN :
......@@ -97,8 +109,12 @@ public:
return "dolar_sign";
case TokenType::AMPERSAND_SIGN :
return "ampersand_sign";
case TokenType::AND_OPERATOR :
return "and_operator";
case TokenType::PIPE_SIGN :
return "pipe_sign";
case TokenType::OR_OPERATOR :
return "or_operator";
case TokenType::CARET_SIGN :
return "caret_sign";
case TokenType::COLON_SIGN :
......@@ -107,8 +123,12 @@ public:
return "semicolon_sign";
case TokenType::MINUS_SIGN :
return "minus_sign";
case TokenType::DEC_OPERATOR :
return "dec_operator";
case TokenType::PLUS_SIGN :
return "plus_sign";
case TokenType::INC_OPERATOR :
return "inc_operator";
case TokenType::SLASH_SIGN :
return "slash_sign";
case TokenType::STAR_SIGN :
......@@ -119,8 +139,12 @@ public:
return "exclemation_sign";
case TokenType::PERCENTAGE_SIGN :
return "percentage_sign";
case TokenType::EQUAL_SIGN :
return "equal_sign";
case TokenType::ASSIGN_OPERATOR :
return "assign_operator";
case TokenType::EQUAL_OPERATOR :
return "equal_operator";
case TokenType::NOT_EQUAL_OPERATOR :
return "not_equal_operator";
case TokenType::HASH_SIGN :
return "hash_sign";
case TokenType::COMMA :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment