getNextCharacter
This commit is contained in:
+19
-2
@@ -9,8 +9,11 @@ int start(char* src) {
|
|||||||
return _STOP_; // stopping the state machine in any other case
|
return _STOP_; // stopping the state machine in any other case
|
||||||
}
|
}
|
||||||
|
|
||||||
int getNextCharacter(char* src) {
|
int getNextCharacter(char* pos) {
|
||||||
return _STOP_; // placeholder
|
if (isLetter(*pos)) {
|
||||||
|
return _READ_IDENTIFIER_; // continues to read the identifier
|
||||||
|
}
|
||||||
|
return _STOP_; // stopping the state machine in any other case
|
||||||
}
|
}
|
||||||
|
|
||||||
int readIdentifier(char* src) {
|
int readIdentifier(char* src) {
|
||||||
@@ -28,3 +31,17 @@ int readOperator(char* src) {
|
|||||||
int readPunctuation(char* src) {
|
int readPunctuation(char* src) {
|
||||||
return _STOP_; // placeholder
|
return _STOP_; // placeholder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int isLetter(char in) {
|
||||||
|
if (in >= 'A') { // capital letters
|
||||||
|
if (in <= 'Z') {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (in >= 'a') { // non-capital letters
|
||||||
|
if (in <= 'z') {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0; // returning 0 if it's no letter
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,3 +24,4 @@ int readNumLit(char*);
|
|||||||
int readOperator(char*);
|
int readOperator(char*);
|
||||||
int readPunctuation(char*);
|
int readPunctuation(char*);
|
||||||
int main();
|
int main();
|
||||||
|
int isLetter(char);
|
||||||
|
|||||||
Reference in New Issue
Block a user