-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractGenerate.java
More file actions
68 lines (52 loc) · 1.59 KB
/
Copy pathAbstractGenerate.java
File metadata and controls
68 lines (52 loc) · 1.59 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
*
* Abstract Generate methods for 312 exercise. This class provides an interface for arbitrary code generators to accept syntax from the rest of the system.
*
* This class has been provided to students
*
* @Author: Roger Garside, John Mariani, John Vidler, Paul Rayson
*
*
**/
public abstract class AbstractGenerate
{
/**
*
* insertTerminal
*
**/
public void insertTerminal( Token token ) {
String tt = Token.getName( token.symbol );
if( (token.symbol == Token.identifier) || (token.symbol == Token.numberConstant) || (token.symbol == Token.stringConstant) )
tt += " '" + token.text + "'";
tt += " on line " + token.lineNumber;
System.out.println( "312TOKEN " + tt );
} // end of method insertTerminal
/**
*
* commenceNonterminal
*
**/
public void commenceNonterminal( String name ) {
System.out.println( "312BEGIN " + name );
} // end of method commenceNonterminal
/**
*
* finishNonterminal
*
**/
public void finishNonterminal( String name ) {
System.out.println( "312END " + name );
} // end of method finishNonterminal
/**
*
* reportSuccess
*
**/
public void reportSuccess()
{
System.out.println( "312SUCCESS" );
} // end of method reportSuccess
/** Report an error to the user. */
public abstract void reportError( Token token, String explanatoryMessage ) throws CompilationException;
} // end of class "AbstractGenerate"