Skip to content

Commit 4be4b68

Browse files
committed
factor Function Definition
1 parent f707057 commit 4be4b68

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

syntax-analysis.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ int line_input_pos;
2020
FILE * in_fp;
2121

2222
/* Function Declarations */
23+
void addChar();
24+
void getChar();
25+
void getNonBlank();
26+
int lex();
27+
28+
void factor();
29+
void z();
30+
void x();
2331

2432
/* Character Classes */
2533
#define LETTER 0
@@ -123,6 +131,37 @@ int lex()
123131
return nextToken;
124132
}
125133

134+
void factor()
135+
{
136+
if (nextToken == IDENT || nextToken == INT_LIT)
137+
/* Return nextToken */
138+
lex();
139+
else
140+
{
141+
if (nextToken == LEFT_PAREN)
142+
{
143+
lex();
144+
x();
145+
if (nextToken == RIGHT_PAREN)
146+
lex();
147+
else
148+
error("Expected )");
149+
}
150+
else
151+
error("Expected id, integer literal, or (");
152+
}
153+
}
154+
155+
void z()
156+
{
157+
158+
}
159+
160+
void x()
161+
{
162+
163+
}
164+
126165
/* Main Driver */
127166
main () {
128167

0 commit comments

Comments
 (0)