-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathid.cpp
More file actions
executable file
·46 lines (41 loc) · 711 Bytes
/
id.cpp
File metadata and controls
executable file
·46 lines (41 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* id.cpp
* Benjamin Ferid Issa
* February 8th 2017
*
* Based on files provided by Dr. Frank Jones, Computer Science Department, Brigham Young University
*/
#include "id.h"
bool id::input(char Character)
{
bool stillValid = false;
if(isalpha(Character))
{
stillValid = true;
m_token->addCharacter(Character);
nextState(new inid(m_contextManager, m_token));
}
else
{
reject();
}
/*THIS MUST HAPPEN LAST!!!*/
delete this;
return stillValid;
}
bool inid::input(char Character)
{
bool stillValid = false;
if(isalnum(Character))
{
stillValid = true;
m_token->addCharacter(Character);
return stillValid;
}
else
{
m_token->setType(ID);
delete this;
return stillValid;
}
}