SlideShare a Scribd company logo
1 of 13
/* Assignment.java */
/* Generated By:JavaCC: Do not edit this line. Assignment.java */
// This is to begin our parser
public class Assignment implements AssignmentConstants {
public static void main(String[] args) {
try {
// We will try to complete the following, moving on to "catch" if any
error is found
Assignment parser = new
Assignment(System.in);
// We create a new instance of our assignment parser
String s = parser.Input();
// We test the parser for the input, and obtain the tag-free string if
the file parses correctly
System.out.println("YES");
// We then print YES if file parses
System.out.println(s);
// And print the subsequent tag-free String
}
catch (ParseException e) { // We now catch all
parse errors
System.out.println("NO");
if((e.currentToken.next.kind ==
SBLOCK) && (e.currentToken.beginColumn == 0)) { // If we begin with
spaces, we define this error
System.err.println("Space(s)
at start of input");
}
else if((e.currentToken.kind ==
SBLOCK) && (e.currentToken.next.kind == EOF)) { // If we end with
spaces
System.err.println("Space(s)
at end of input");
}
else if(((e.currentToken.kind ==
UBLOCK) || (e.currentToken.kind == UCHARACTER)) &&
(e.currentToken.next.kind == EOF)) { // If we end with block of
capital letters and cause an error, we must be in 2L mode
System.err.println("Must close
2L tag");
}
else if(((e.currentToken.kind ==
LBLOCK) || (e.currentToken.kind == LCHARACTER)) &&
(e.currentToken.next.kind == EOF)) { // If we end with block of
lowercase letters and cause an error, we must be in 2U mode
System.err.println("Must close
2U tag");
}
else if(((e.currentToken.kind ==
SBLOCK) || (e.currentToken.kind == SPACE)) &&
(e.currentToken.next.kind == UTAGCLOSE)) { // If
we end tag block with spaces, we define this error
System.err.println("Cannot
have spaces at end of 2U tag input");
}
else if(((e.currentToken.kind ==
SBLOCK) || (e.currentToken.kind == SPACE)) &&
(e.currentToken.next.kind == LTAGCLOSE)) { // If we end
tag block with spaces, we define this error
System.err.println("Cannot
have spaces at end of 2L tag input");
}
else if(((e.currentToken.next.kind ==
SBLOCK) || (e.currentToken.next.kind == SPACE)) &&
(e.currentToken.kind == UTAGOPEN)) { // If we start tag
block with spaces, we define this error
System.err.println("Cannot
have spaces at start of 2U tag input");
}
else if(((e.currentToken.next.kind ==
SBLOCK) || (e.currentToken.next.kind == SPACE)) &&
(e.currentToken.kind == LTAGOPEN)) { // If we start tag
block with spaces, we define this error
System.err.println("Cannot
have spaces at start of 2L tag input");
}
else if((e.currentToken.next.kind ==
SBLOCK) || (e.currentToken.next.kind == SPACE)) {
// If we have an odd space to our space block, then we have a space
parity error
System.err.println("Incorrect
space parity");
}
else if(((e.currentToken.next.kind ==
UCHARACTER) || (e.currentToken.next.kind == UBLOCK)) &&
((e.currentToken.kind == LCHARACTER) || (e.currentToken.kind ==
LBLOCK) || (e.currentToken.kind == UTAGOPEN))) { // If we find a
capital letter amongst a correct lowercase input, we define this error
System.err.println("Capital
letter in lowercase input");
}
else if((e.currentToken.next.kind ==
LCHARACTER) || (e.currentToken.next.kind == LBLOCK) &&
((e.currentToken.kind == UCHARACTER) || (e.currentToken.kind ==
UBLOCK) || (e.currentToken.kind == LTAGOPEN))) { // If we find a
lowercase letter amongst a correct uppercase input, we define this
error
System.err.println("Lowercase
letter in upper case input");
}
else if((e.currentToken.next.kind ==
UCHARACTER) || (e.currentToken.next.kind == UBLOCK)) {
// If we have an odd capital letter to our valid uppercase block, we
have an uppercase block parity error
System.err.println("Invalid
parity of upper case block");
}
else if((e.currentToken.next.kind ==
LCHARACTER) || (e.currentToken.next.kind == LBLOCK)) {
// If we have an odd lowercase letter to our valid lowercase block, we
have an lowercase block parity error
System.err.println("Invalid
parity of lowercase block");
}
else if((e.currentToken.next.kind ==
UTAGCLOSE) && (e.currentToken.kind == UTAGOPEN)) {
// We need at least one block in any input between tags, so if we have
two tags together, we define this error
System.err.println("Must enter
input between 2U tags");
}
else if(e.currentToken.next.kind ==
UTAGCLOSE) {
// If the error is caused by a close tag, then we must not have
defined an open tag
System.err.println("2U close
tag with no 2U open tag");
}
else if((e.currentToken.next.kind ==
LTAGCLOSE) && (e.currentToken.kind == LTAGOPEN)) {
// We need at least one block in any input between tags, so if we have
two tags together, we define this error
System.err.println("Must enter
input between 2L tags");
}
else if(e.currentToken.next.kind ==
LTAGCLOSE) {
// If the error is caused by a close tag, then we must not have
defined an open tag
System.err.println("2L close
tag with no 2L open tag");
}
else if((e.currentToken.next.kind ==
UTAGOPEN) && (e.currentToken.kind == UTAGOPEN)) {
// We cannot have two open tags of the same type right next to each
other, so define this error
System.err.println("Cannot
nest 2U open tags");
}
else if((e.currentToken.next.kind ==
LTAGOPEN) && (e.currentToken.kind == LTAGOPEN)) {
// We cannot have two open tags of the same type right next to each
other, so define this error
System.err.println("Cannot
nest 2L open tags");
}
else if(e.currentToken.next.kind ==
UTAGOPEN) {
// If we have an error caused by the open tag, we know it must be
amongst the incorrect type of block
System.err.println("2U open
tags cannot be placed amongst lowercase input");
}
else if(e.currentToken.next.kind ==
LTAGOPEN) {
// If we have an error caused by the open tag, we know it must be
amongst the incorrect type of block
System.err.println("2L open
tags cannot be placed amongst upper case input");
}
else if(e.currentToken.next.kind ==
EOF) {
// If we have hit the end of file and that is causing the error, then
it must be the only token found and hence define this error
System.err.println("Must have
at least one block in file");
}
}
catch(TokenMgrError e) {
// This is to catch the error that arises when a non-tokenisable
character is found in our input
System.out.println("NO");
System.err.println("Invalid character
in input");
}
}
static final public String Input() throws ParseException {String s;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case UBLOCK:
case UTAGOPEN:{
s = LODD(0);
break;
}
case LBLOCK:
case LTAGOPEN:{
s = LEVEN(0);
break;
}
default:
jj_la1[0] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
jj_consume_token(0);
{if ("" != null) return s;}
throw new Error("Missing return statement in function");
}
static final public String LEVEN(int k) throws ParseException {Token
t; Token t2; String s = ""; String s2 = ""; String s3 = ""; String tmp
= ""; String tmp2 = ""; int i = 0;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LBLOCK:{
t = jj_consume_token(LBLOCK);
if(k == 0) { s = t.toString(); }
// if we are in the mode, such that the call has come from input or
LEVEN, we define the string as it is
else { tmp2 = t.toString();
// if we are in the mode, such that the call has come from LODD, we
convert the string by the language rules
while(i < tmp2.length()) {
// for each character in our string
if(i == 0) {
// for the first character, we know we have a lowercase letter and so
convert the character to uppercase and add it on twice
s = s +
Character.toUpperCase(tmp2.charAt(i)) +
Character.toUpperCase(tmp2.charAt(i));
i++;
}
else if((tmp2.charAt(i
- 1) == ' ') && (tmp2.charAt(i) != ' ')) {
// if we are moving from a space to a letter, we are on the first
letter of the block and so convert to uppercase and add it twice
s = s +
Character.toUpperCase(tmp2.charAt(i)) +
Character.toUpperCase(tmp2.charAt(i));
i++;
}
else if(tmp2.charAt(i)
== ' ') { // if we have a space, we add
the space to the String unchanged
s = s + " ";
i++;
}
else {
// if we have character amongst a block, we simply make it uppercase
and add it to our String
s = s +
Character.toUpperCase(tmp2.charAt(i));
i++;
}
}
i = 0;
// We reset i once we have traversed the String
}
break;
}
case LTAGOPEN:{
jj_consume_token(LTAGOPEN);
tmp = LODD(1);
jj_consume_token(LTAGCLOSE);
if(k == 0) { s = tmp; }
// If we are in the mode, such that the call has come from the input
or LEVEN, we define the string as it is
else {
// If we are in the mode, such that the call came from LODD, we
convert the string by the language rules
while(i < tmp.length()) {
// for each character in our string
if(i == 0) {
// for the first character, we know we have a lowercase letter and so
convert the character to uppercase and add it on twice
s = s +
Character.toUpperCase(tmp.charAt(i)) +
Character.toUpperCase(tmp.charAt(i));
i++;
}
else if((tmp.charAt(i
- 1) == ' ') && (tmp.charAt(i) != ' ')) {
// if we are moving from a space to a letter, we are on the first
letter of the block and so convert to uppercase and add it twice
s = s +
Character.toUpperCase(tmp.charAt(i)) +
Character.toUpperCase(tmp.charAt(i));
i++;
}
else if(tmp.charAt(i)
== ' ') { // if we have a space, we
add the space to the String unchanged
s = s + " ";
i++;
}
else {
// if we have character amongst a block, we simply make it uppercase
and add it to our String
s = s +
Character.toUpperCase(tmp.charAt(i));
i++;
}
}
i = 0;
// We reset i once we have traversed the String
}
break;
}
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SBLOCK:{
t2 = jj_consume_token(SBLOCK);
s2 = t2.toString();
// We then define LEVEN to be made up of any spaceblock, which
we take the String of
s3 = LEVEN(k);
break;
}
default:
jj_la1[2] = jj_gen;
;
}
{if ("" != null) return (s + s2 + s3);}
throw new Error("Missing return statement in function");
}
// We return the concatenation of the three found strings
static final public
String LODD(int k) throws ParseException {Token t; Token t2; String s
= ""; String s2 = ""; String s3 = ""; String tmp = ""; String tmp2 =
""; int i = 0;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case UBLOCK:{
t = jj_consume_token(UBLOCK);
if(k == 0) { s = t.toString(); }
// If we are in the mode, such that the call has come from the input
or LODD, we define the string as it is
else { tmp2 = t.toString();
// If we are in the mode, such that the call came from LEVEN, we
convert the string by the language rules
while(i < tmp2.length()) {
// for each character in our string
if(i == 0) {
// for the first character, we know we have a capital letter and so
ignore the character
i++;
}
else if((tmp2.charAt(i
- 1) == ' ') && (tmp2.charAt(i) != ' ')) {
// if we are moving from a space to a letter, we are on the first
letter of the block and so ignore the character
i++;
}
else if(tmp2.charAt(i)
== ' ') { // if we have a space, we add
the space to the String unchanged
s = s + " ";
i++;
}
else {
// if we have character amongst a block, we simply make it lowercase
and add it to our String
s = s +
Character.toLowerCase(tmp2.charAt(i));
i++;
}
}
i = 0;
// We reset i once we have traversed the String
}
break;
}
case UTAGOPEN:{
jj_consume_token(UTAGOPEN);
tmp = LEVEN(1);
jj_consume_token(UTAGCLOSE);
if(k == 0) {s = tmp;}
// If we are in the mode, such that the call has come from the input
or LODD, we define the string as it is
else {
// If we are in the mode, such that the call came from LEVEN, we
convert the string by the language rules
while(i < tmp.length()) {
// for each character in our string
if(i == 0) {
// for the first character, we know we have a capital letter and so
ignore the character
i++;
}
else if((tmp.charAt(i
- 1) == ' ') && (tmp.charAt(i) != ' ')) {
// if we are moving from a space to a letter, we are on the first
letter of the block and so ignore the character
i++;
}
else if(tmp.charAt(i)
== ' ') { // if we have a space, we
add the space to the String unchanged
s = s + " ";
i++;
}
else {
// if we have character amongst a block, we simply make it lowercase
and add it to our String
s = s +
Character.toLowerCase(tmp.charAt(i));
i++;
}
}
i = 0;
// We reset i once we have traversed the String
}
break;
}
default:
jj_la1[3] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SBLOCK:{
t2 = jj_consume_token(SBLOCK);
s2 = t2.toString();
// We then define LODD to be made up of any spaceblock, which we
take the String of
s3 = LODD(k);
break;
}
default:
jj_la1[4] = jj_gen;
;
}
{if ("" != null) return (s + s2 + s3);}
throw new Error("Missing return statement in function");
}
static private boolean jj_initialized_once = false;
/** Generated Token Manager. */
static public AssignmentTokenManager token_source;
static SimpleCharStream jj_input_stream;
/** Current token. */
static public Token token;
/** Next token. */
static public Token jj_nt;
static private int jj_ntk;
static private int jj_gen;
static final private int[] jj_la1 = new int[5];
static private int[] jj_la1_0;
static {
jj_la1_init_0();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x286,0x204,0x8,0x82,0x8,};
}
/** Constructor with InputStream. */
public Assignment(java.io.InputStream stream) {
this(stream, null);
}
/** Constructor with InputStream and supplied encoding */
public Assignment(java.io.InputStream stream, String encoding) {
if (jj_initialized_once) {
System.out.println("ERROR: Second call to constructor of static
parser. ");
System.out.println(" You must either use ReInit() or set
the JavaCC option STATIC to false");
System.out.println(" during parser generation.");
throw new Error();
}
jj_initialized_once = true;
try { jj_input_stream = new SimpleCharStream(stream, encoding, 1,
1); } catch(java.io.UnsupportedEncodingException e) { throw new
RuntimeException(e); }
token_source = new AssignmentTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
static public void ReInit(java.io.InputStream stream) {
ReInit(stream, null);
}
/** Reinitialise. */
static public void ReInit(java.io.InputStream stream, String
encoding) {
try { jj_input_stream.ReInit(stream, encoding, 1, 1); }
catch(java.io.UnsupportedEncodingException e) { throw new
RuntimeException(e); }
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
/** Constructor. */
public Assignment(java.io.Reader stream) {
if (jj_initialized_once) {
System.out.println("ERROR: Second call to constructor of static
parser. ");
System.out.println(" You must either use ReInit() or set
the JavaCC option STATIC to false");
System.out.println(" during parser generation.");
throw new Error();
}
jj_initialized_once = true;
jj_input_stream = new SimpleCharStream(stream, 1, 1);
token_source = new AssignmentTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
static public void ReInit(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
/** Constructor with generated Token Manager. */
public Assignment(AssignmentTokenManager tm) {
if (jj_initialized_once) {
System.out.println("ERROR: Second call to constructor of static
parser. ");
System.out.println(" You must either use ReInit() or set
the JavaCC option STATIC to false");
System.out.println(" during parser generation.");
throw new Error();
}
jj_initialized_once = true;
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
public void ReInit(AssignmentTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
static private Token jj_consume_token(int kind) throws
ParseException {
Token oldToken;
if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
if (token.kind == kind) {
jj_gen++;
return token;
}
token = oldToken;
jj_kind = kind;
throw generateParseException();
}
/** Get the next Token. */
static final public Token getNextToken() {
if (token.next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
jj_gen++;
return token;
}
/** Get the specific Token. */
static final public Token getToken(int index) {
Token t = token;
for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken();
}
return t;
}
static private int jj_ntk_f() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
return (jj_ntk = jj_nt.kind);
}
static private java.util.List<int[]> jj_expentries = new
java.util.ArrayList<int[]>();
static private int[] jj_expentry;
static private int jj_kind = -1;
/** Generate ParseException. */
static public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[11];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 5; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
la1tokens[j] = true;
}
}
}
}
for (int i = 0; i < 11; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.add(jj_expentry);
}
}
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
/** Enable tracing. */
static final public void enable_tracing() {
}
/** Disable tracing. */
static final public void disable_tracing() {
}
}

More Related Content

What's hot

3 kotlin vs. java- what kotlin has that java does not
3  kotlin vs. java- what kotlin has that java does not3  kotlin vs. java- what kotlin has that java does not
3 kotlin vs. java- what kotlin has that java does notSergey Bandysik
 
Akka cluster overview at 010dev
Akka cluster overview at 010devAkka cluster overview at 010dev
Akka cluster overview at 010devRoland Kuhn
 
2 kotlin vs. java: what java has that kotlin does not
2  kotlin vs. java: what java has that kotlin does not2  kotlin vs. java: what java has that kotlin does not
2 kotlin vs. java: what java has that kotlin does notSergey Bandysik
 
JAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICESJAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICESNikunj Parekh
 
Exception Handling1
Exception Handling1Exception Handling1
Exception Handling1guest739536
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)HamletDRC
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascriptReece Carlson
 
Effective Java - Generics
Effective Java - GenericsEffective Java - Generics
Effective Java - GenericsRoshan Deniyage
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokusHamletDRC
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
AnyObject – 自分が見落としていた、基本の話
AnyObject – 自分が見落としていた、基本の話AnyObject – 自分が見落としていた、基本の話
AnyObject – 自分が見落としていた、基本の話Tomohiro Kumagai
 
Unit Testing in Angular(7/8/9) Using Jasmine and Karma Part-2
Unit Testing in Angular(7/8/9) Using Jasmine and Karma Part-2Unit Testing in Angular(7/8/9) Using Jasmine and Karma Part-2
Unit Testing in Angular(7/8/9) Using Jasmine and Karma Part-2Katy Slemon
 
7 Sins of Java fixed in Kotlin
7 Sins of Java fixed in Kotlin7 Sins of Java fixed in Kotlin
7 Sins of Java fixed in KotlinLuca Guadagnini
 
AST Transformations
AST TransformationsAST Transformations
AST TransformationsHamletDRC
 
String and string buffer
String and string bufferString and string buffer
String and string bufferkamal kotecha
 
Writing beautiful code with Java 8
Writing beautiful code with Java 8Writing beautiful code with Java 8
Writing beautiful code with Java 8Sergiu Mircea Indrie
 
The Ring programming language version 1.9 book - Part 124 of 210
The Ring programming language version 1.9 book - Part 124 of 210The Ring programming language version 1.9 book - Part 124 of 210
The Ring programming language version 1.9 book - Part 124 of 210Mahmoud Samir Fayed
 

What's hot (20)

3 kotlin vs. java- what kotlin has that java does not
3  kotlin vs. java- what kotlin has that java does not3  kotlin vs. java- what kotlin has that java does not
3 kotlin vs. java- what kotlin has that java does not
 
Akka cluster overview at 010dev
Akka cluster overview at 010devAkka cluster overview at 010dev
Akka cluster overview at 010dev
 
2 kotlin vs. java: what java has that kotlin does not
2  kotlin vs. java: what java has that kotlin does not2  kotlin vs. java: what java has that kotlin does not
2 kotlin vs. java: what java has that kotlin does not
 
JAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICESJAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICES
 
Jist of Java
Jist of JavaJist of Java
Jist of Java
 
Exception Handling1
Exception Handling1Exception Handling1
Exception Handling1
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascript
 
smtlecture.9
smtlecture.9smtlecture.9
smtlecture.9
 
Effective Java - Generics
Effective Java - GenericsEffective Java - Generics
Effective Java - Generics
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
AnyObject – 自分が見落としていた、基本の話
AnyObject – 自分が見落としていた、基本の話AnyObject – 自分が見落としていた、基本の話
AnyObject – 自分が見落としていた、基本の話
 
Unit Testing in Angular(7/8/9) Using Jasmine and Karma Part-2
Unit Testing in Angular(7/8/9) Using Jasmine and Karma Part-2Unit Testing in Angular(7/8/9) Using Jasmine and Karma Part-2
Unit Testing in Angular(7/8/9) Using Jasmine and Karma Part-2
 
7 Sins of Java fixed in Kotlin
7 Sins of Java fixed in Kotlin7 Sins of Java fixed in Kotlin
7 Sins of Java fixed in Kotlin
 
AST Transformations
AST TransformationsAST Transformations
AST Transformations
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Writing beautiful code with Java 8
Writing beautiful code with Java 8Writing beautiful code with Java 8
Writing beautiful code with Java 8
 
Swift Introduction
Swift IntroductionSwift Introduction
Swift Introduction
 
The Ring programming language version 1.9 book - Part 124 of 210
The Ring programming language version 1.9 book - Part 124 of 210The Ring programming language version 1.9 book - Part 124 of 210
The Ring programming language version 1.9 book - Part 124 of 210
 

Viewers also liked

Trabajo final catedra univeristaria cindy gonzales grupo 108
Trabajo final catedra univeristaria cindy gonzales  grupo 108Trabajo final catedra univeristaria cindy gonzales  grupo 108
Trabajo final catedra univeristaria cindy gonzales grupo 108cindyrosa2020
 
Alex e as formigas navegadoras
Alex e as formigas navegadorasAlex e as formigas navegadoras
Alex e as formigas navegadorasJoão Silva
 
Referencias tecnológicas
Referencias tecnológicasReferencias tecnológicas
Referencias tecnológicasIvanKart
 
Peristiwa 10 november
Peristiwa 10 novemberPeristiwa 10 november
Peristiwa 10 novemberadi darma
 
س و ج مراجعة نهائية دراسات اجتماعية الصف السادس الابتدائي ترم أول
س و ج مراجعة نهائية دراسات اجتماعية الصف السادس الابتدائي ترم أولس و ج مراجعة نهائية دراسات اجتماعية الصف السادس الابتدائي ترم أول
س و ج مراجعة نهائية دراسات اجتماعية الصف السادس الابتدائي ترم أولAbdallah Omar
 
Loza aligerada
Loza aligeradaLoza aligerada
Loza aligeradaFidel199
 
Học tối ưu thuế phải nộp ở đâu tốt nhất
Học tối ưu thuế phải nộp ở đâu tốt nhấtHọc tối ưu thuế phải nộp ở đâu tốt nhất
Học tối ưu thuế phải nộp ở đâu tốt nhấtcogangabc
 
PARIS, FRANÇA 26/6 A 9/7/2006
PARIS, FRANÇA 26/6 A 9/7/2006PARIS, FRANÇA 26/6 A 9/7/2006
PARIS, FRANÇA 26/6 A 9/7/2006Isaura Miike
 

Viewers also liked (13)

Trabajo final catedra univeristaria cindy gonzales grupo 108
Trabajo final catedra univeristaria cindy gonzales  grupo 108Trabajo final catedra univeristaria cindy gonzales  grupo 108
Trabajo final catedra univeristaria cindy gonzales grupo 108
 
Title slide Synergistic Connection
Title slide Synergistic ConnectionTitle slide Synergistic Connection
Title slide Synergistic Connection
 
Alex e as formigas navegadoras
Alex e as formigas navegadorasAlex e as formigas navegadoras
Alex e as formigas navegadoras
 
Referencias tecnológicas
Referencias tecnológicasReferencias tecnológicas
Referencias tecnológicas
 
¿Que son los celos?
¿Que son los celos?¿Que son los celos?
¿Que son los celos?
 
Robin Hood
Robin HoodRobin Hood
Robin Hood
 
Peristiwa 10 november
Peristiwa 10 novemberPeristiwa 10 november
Peristiwa 10 november
 
س و ج مراجعة نهائية دراسات اجتماعية الصف السادس الابتدائي ترم أول
س و ج مراجعة نهائية دراسات اجتماعية الصف السادس الابتدائي ترم أولس و ج مراجعة نهائية دراسات اجتماعية الصف السادس الابتدائي ترم أول
س و ج مراجعة نهائية دراسات اجتماعية الصف السادس الابتدائي ترم أول
 
Superdog
SuperdogSuperdog
Superdog
 
Loza aligerada
Loza aligeradaLoza aligerada
Loza aligerada
 
Diapositiva
DiapositivaDiapositiva
Diapositiva
 
Học tối ưu thuế phải nộp ở đâu tốt nhất
Học tối ưu thuế phải nộp ở đâu tốt nhấtHọc tối ưu thuế phải nộp ở đâu tốt nhất
Học tối ưu thuế phải nộp ở đâu tốt nhất
 
PARIS, FRANÇA 26/6 A 9/7/2006
PARIS, FRANÇA 26/6 A 9/7/2006PARIS, FRANÇA 26/6 A 9/7/2006
PARIS, FRANÇA 26/6 A 9/7/2006
 

Similar to Assignment

Java Programming Below are the lexer token and shank file.pdf
Java Programming Below are the lexer token and shank file.pdfJava Programming Below are the lexer token and shank file.pdf
Java Programming Below are the lexer token and shank file.pdfabdulkadar1977
 
4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладкаDEVTYPE
 
Java Programming Below are the lexer token and shank file.pdf
Java Programming Below are the lexer token and shank file.pdfJava Programming Below are the lexer token and shank file.pdf
Java Programming Below are the lexer token and shank file.pdfadinathassociates
 
Java Programming Below are the lexerjava tokenjava and .pdf
Java Programming Below are the lexerjava tokenjava and .pdfJava Programming Below are the lexerjava tokenjava and .pdf
Java Programming Below are the lexerjava tokenjava and .pdfadinathassociates
 
Implement threads and a GUI interface using advanced Java Swing clas.pdf
Implement threads and a GUI interface using advanced Java Swing clas.pdfImplement threads and a GUI interface using advanced Java Swing clas.pdf
Implement threads and a GUI interface using advanced Java Swing clas.pdfamrishinda
 
import java.util.ArrayList;import java.util.Arrays;import ja.docx
import java.util.ArrayList;import java.util.Arrays;import ja.docximport java.util.ArrayList;import java.util.Arrays;import ja.docx
import java.util.ArrayList;import java.util.Arrays;import ja.docxwilcockiris
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)ujihisa
 
Refactoring Jdbc Programming
Refactoring Jdbc ProgrammingRefactoring Jdbc Programming
Refactoring Jdbc Programmingchanwook Park
 
Given an expression string exp, write a java class ExpressionCheccke.pdf
Given an expression string exp, write a java class ExpressionCheccke.pdfGiven an expression string exp, write a java class ExpressionCheccke.pdf
Given an expression string exp, write a java class ExpressionCheccke.pdfinfo382133
 
Java Code The traditional way to deal with these in Parsers is the .pdf
Java Code The traditional way to deal with these in Parsers is the .pdfJava Code The traditional way to deal with these in Parsers is the .pdf
Java Code The traditional way to deal with these in Parsers is the .pdfstopgolook
 
Xml generation and extraction using XMLDB
Xml generation and extraction using XMLDBXml generation and extraction using XMLDB
Xml generation and extraction using XMLDBpallavi kasibhotla
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecLoïc Descotte
 
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docxMETA-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docxandreecapon
 
#include string.h#include stdlib.h#include systypes.h.docx
#include string.h#include stdlib.h#include systypes.h.docx#include string.h#include stdlib.h#include systypes.h.docx
#include string.h#include stdlib.h#include systypes.h.docxAASTHA76
 
Java input Scanner
Java input Scanner Java input Scanner
Java input Scanner Huda Alameen
 
Programing with java for begniers .pptx
Programing with java for begniers  .pptxPrograming with java for begniers  .pptx
Programing with java for begniers .pptxadityaraj7711
 

Similar to Assignment (20)

Java Programming Below are the lexer token and shank file.pdf
Java Programming Below are the lexer token and shank file.pdfJava Programming Below are the lexer token and shank file.pdf
Java Programming Below are the lexer token and shank file.pdf
 
4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка
 
Java Programming Below are the lexer token and shank file.pdf
Java Programming Below are the lexer token and shank file.pdfJava Programming Below are the lexer token and shank file.pdf
Java Programming Below are the lexer token and shank file.pdf
 
Java Programming Below are the lexerjava tokenjava and .pdf
Java Programming Below are the lexerjava tokenjava and .pdfJava Programming Below are the lexerjava tokenjava and .pdf
Java Programming Below are the lexerjava tokenjava and .pdf
 
Templates
TemplatesTemplates
Templates
 
Implement threads and a GUI interface using advanced Java Swing clas.pdf
Implement threads and a GUI interface using advanced Java Swing clas.pdfImplement threads and a GUI interface using advanced Java Swing clas.pdf
Implement threads and a GUI interface using advanced Java Swing clas.pdf
 
import java.util.ArrayList;import java.util.Arrays;import ja.docx
import java.util.ArrayList;import java.util.Arrays;import ja.docximport java.util.ArrayList;import java.util.Arrays;import ja.docx
import java.util.ArrayList;import java.util.Arrays;import ja.docx
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)
 
7 stacksqueues
7 stacksqueues7 stacksqueues
7 stacksqueues
 
Refactoring Jdbc Programming
Refactoring Jdbc ProgrammingRefactoring Jdbc Programming
Refactoring Jdbc Programming
 
Given an expression string exp, write a java class ExpressionCheccke.pdf
Given an expression string exp, write a java class ExpressionCheccke.pdfGiven an expression string exp, write a java class ExpressionCheccke.pdf
Given an expression string exp, write a java class ExpressionCheccke.pdf
 
string tokenization
string tokenizationstring tokenization
string tokenization
 
Java Code The traditional way to deal with these in Parsers is the .pdf
Java Code The traditional way to deal with these in Parsers is the .pdfJava Code The traditional way to deal with these in Parsers is the .pdf
Java Code The traditional way to deal with these in Parsers is the .pdf
 
Xml generation and extraction using XMLDB
Xml generation and extraction using XMLDBXml generation and extraction using XMLDB
Xml generation and extraction using XMLDB
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
 
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docxMETA-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
 
#include string.h#include stdlib.h#include systypes.h.docx
#include string.h#include stdlib.h#include systypes.h.docx#include string.h#include stdlib.h#include systypes.h.docx
#include string.h#include stdlib.h#include systypes.h.docx
 
Java input Scanner
Java input Scanner Java input Scanner
Java input Scanner
 
Programing with java for begniers .pptx
Programing with java for begniers  .pptxPrograming with java for begniers  .pptx
Programing with java for begniers .pptx
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
 

Assignment

  • 1. /* Assignment.java */ /* Generated By:JavaCC: Do not edit this line. Assignment.java */ // This is to begin our parser public class Assignment implements AssignmentConstants { public static void main(String[] args) { try { // We will try to complete the following, moving on to "catch" if any error is found Assignment parser = new Assignment(System.in); // We create a new instance of our assignment parser String s = parser.Input(); // We test the parser for the input, and obtain the tag-free string if the file parses correctly System.out.println("YES"); // We then print YES if file parses System.out.println(s); // And print the subsequent tag-free String } catch (ParseException e) { // We now catch all parse errors System.out.println("NO"); if((e.currentToken.next.kind == SBLOCK) && (e.currentToken.beginColumn == 0)) { // If we begin with spaces, we define this error System.err.println("Space(s) at start of input"); } else if((e.currentToken.kind == SBLOCK) && (e.currentToken.next.kind == EOF)) { // If we end with spaces System.err.println("Space(s) at end of input"); } else if(((e.currentToken.kind == UBLOCK) || (e.currentToken.kind == UCHARACTER)) && (e.currentToken.next.kind == EOF)) { // If we end with block of capital letters and cause an error, we must be in 2L mode System.err.println("Must close 2L tag"); } else if(((e.currentToken.kind == LBLOCK) || (e.currentToken.kind == LCHARACTER)) && (e.currentToken.next.kind == EOF)) { // If we end with block of lowercase letters and cause an error, we must be in 2U mode System.err.println("Must close 2U tag"); } else if(((e.currentToken.kind == SBLOCK) || (e.currentToken.kind == SPACE)) &&
  • 2. (e.currentToken.next.kind == UTAGCLOSE)) { // If we end tag block with spaces, we define this error System.err.println("Cannot have spaces at end of 2U tag input"); } else if(((e.currentToken.kind == SBLOCK) || (e.currentToken.kind == SPACE)) && (e.currentToken.next.kind == LTAGCLOSE)) { // If we end tag block with spaces, we define this error System.err.println("Cannot have spaces at end of 2L tag input"); } else if(((e.currentToken.next.kind == SBLOCK) || (e.currentToken.next.kind == SPACE)) && (e.currentToken.kind == UTAGOPEN)) { // If we start tag block with spaces, we define this error System.err.println("Cannot have spaces at start of 2U tag input"); } else if(((e.currentToken.next.kind == SBLOCK) || (e.currentToken.next.kind == SPACE)) && (e.currentToken.kind == LTAGOPEN)) { // If we start tag block with spaces, we define this error System.err.println("Cannot have spaces at start of 2L tag input"); } else if((e.currentToken.next.kind == SBLOCK) || (e.currentToken.next.kind == SPACE)) { // If we have an odd space to our space block, then we have a space parity error System.err.println("Incorrect space parity"); } else if(((e.currentToken.next.kind == UCHARACTER) || (e.currentToken.next.kind == UBLOCK)) && ((e.currentToken.kind == LCHARACTER) || (e.currentToken.kind == LBLOCK) || (e.currentToken.kind == UTAGOPEN))) { // If we find a capital letter amongst a correct lowercase input, we define this error System.err.println("Capital letter in lowercase input"); } else if((e.currentToken.next.kind == LCHARACTER) || (e.currentToken.next.kind == LBLOCK) && ((e.currentToken.kind == UCHARACTER) || (e.currentToken.kind == UBLOCK) || (e.currentToken.kind == LTAGOPEN))) { // If we find a lowercase letter amongst a correct uppercase input, we define this error System.err.println("Lowercase letter in upper case input"); } else if((e.currentToken.next.kind == UCHARACTER) || (e.currentToken.next.kind == UBLOCK)) {
  • 3. // If we have an odd capital letter to our valid uppercase block, we have an uppercase block parity error System.err.println("Invalid parity of upper case block"); } else if((e.currentToken.next.kind == LCHARACTER) || (e.currentToken.next.kind == LBLOCK)) { // If we have an odd lowercase letter to our valid lowercase block, we have an lowercase block parity error System.err.println("Invalid parity of lowercase block"); } else if((e.currentToken.next.kind == UTAGCLOSE) && (e.currentToken.kind == UTAGOPEN)) { // We need at least one block in any input between tags, so if we have two tags together, we define this error System.err.println("Must enter input between 2U tags"); } else if(e.currentToken.next.kind == UTAGCLOSE) { // If the error is caused by a close tag, then we must not have defined an open tag System.err.println("2U close tag with no 2U open tag"); } else if((e.currentToken.next.kind == LTAGCLOSE) && (e.currentToken.kind == LTAGOPEN)) { // We need at least one block in any input between tags, so if we have two tags together, we define this error System.err.println("Must enter input between 2L tags"); } else if(e.currentToken.next.kind == LTAGCLOSE) { // If the error is caused by a close tag, then we must not have defined an open tag System.err.println("2L close tag with no 2L open tag"); } else if((e.currentToken.next.kind == UTAGOPEN) && (e.currentToken.kind == UTAGOPEN)) { // We cannot have two open tags of the same type right next to each other, so define this error System.err.println("Cannot nest 2U open tags"); } else if((e.currentToken.next.kind == LTAGOPEN) && (e.currentToken.kind == LTAGOPEN)) { // We cannot have two open tags of the same type right next to each other, so define this error
  • 4. System.err.println("Cannot nest 2L open tags"); } else if(e.currentToken.next.kind == UTAGOPEN) { // If we have an error caused by the open tag, we know it must be amongst the incorrect type of block System.err.println("2U open tags cannot be placed amongst lowercase input"); } else if(e.currentToken.next.kind == LTAGOPEN) { // If we have an error caused by the open tag, we know it must be amongst the incorrect type of block System.err.println("2L open tags cannot be placed amongst upper case input"); } else if(e.currentToken.next.kind == EOF) { // If we have hit the end of file and that is causing the error, then it must be the only token found and hence define this error System.err.println("Must have at least one block in file"); } } catch(TokenMgrError e) { // This is to catch the error that arises when a non-tokenisable character is found in our input System.out.println("NO"); System.err.println("Invalid character in input"); } } static final public String Input() throws ParseException {String s; switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case UBLOCK: case UTAGOPEN:{ s = LODD(0); break; } case LBLOCK: case LTAGOPEN:{ s = LEVEN(0); break; } default: jj_la1[0] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jj_consume_token(0);
  • 5. {if ("" != null) return s;} throw new Error("Missing return statement in function"); } static final public String LEVEN(int k) throws ParseException {Token t; Token t2; String s = ""; String s2 = ""; String s3 = ""; String tmp = ""; String tmp2 = ""; int i = 0; switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case LBLOCK:{ t = jj_consume_token(LBLOCK); if(k == 0) { s = t.toString(); } // if we are in the mode, such that the call has come from input or LEVEN, we define the string as it is else { tmp2 = t.toString(); // if we are in the mode, such that the call has come from LODD, we convert the string by the language rules while(i < tmp2.length()) { // for each character in our string if(i == 0) { // for the first character, we know we have a lowercase letter and so convert the character to uppercase and add it on twice s = s + Character.toUpperCase(tmp2.charAt(i)) + Character.toUpperCase(tmp2.charAt(i)); i++; } else if((tmp2.charAt(i - 1) == ' ') && (tmp2.charAt(i) != ' ')) { // if we are moving from a space to a letter, we are on the first letter of the block and so convert to uppercase and add it twice s = s + Character.toUpperCase(tmp2.charAt(i)) + Character.toUpperCase(tmp2.charAt(i)); i++; } else if(tmp2.charAt(i) == ' ') { // if we have a space, we add the space to the String unchanged s = s + " "; i++; } else { // if we have character amongst a block, we simply make it uppercase and add it to our String s = s + Character.toUpperCase(tmp2.charAt(i)); i++; } } i = 0; // We reset i once we have traversed the String }
  • 6. break; } case LTAGOPEN:{ jj_consume_token(LTAGOPEN); tmp = LODD(1); jj_consume_token(LTAGCLOSE); if(k == 0) { s = tmp; } // If we are in the mode, such that the call has come from the input or LEVEN, we define the string as it is else { // If we are in the mode, such that the call came from LODD, we convert the string by the language rules while(i < tmp.length()) { // for each character in our string if(i == 0) { // for the first character, we know we have a lowercase letter and so convert the character to uppercase and add it on twice s = s + Character.toUpperCase(tmp.charAt(i)) + Character.toUpperCase(tmp.charAt(i)); i++; } else if((tmp.charAt(i - 1) == ' ') && (tmp.charAt(i) != ' ')) { // if we are moving from a space to a letter, we are on the first letter of the block and so convert to uppercase and add it twice s = s + Character.toUpperCase(tmp.charAt(i)) + Character.toUpperCase(tmp.charAt(i)); i++; } else if(tmp.charAt(i) == ' ') { // if we have a space, we add the space to the String unchanged s = s + " "; i++; } else { // if we have character amongst a block, we simply make it uppercase and add it to our String s = s + Character.toUpperCase(tmp.charAt(i)); i++; } } i = 0; // We reset i once we have traversed the String } break; } default: jj_la1[1] = jj_gen;
  • 7. jj_consume_token(-1); throw new ParseException(); } switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SBLOCK:{ t2 = jj_consume_token(SBLOCK); s2 = t2.toString(); // We then define LEVEN to be made up of any spaceblock, which we take the String of s3 = LEVEN(k); break; } default: jj_la1[2] = jj_gen; ; } {if ("" != null) return (s + s2 + s3);} throw new Error("Missing return statement in function"); } // We return the concatenation of the three found strings static final public String LODD(int k) throws ParseException {Token t; Token t2; String s = ""; String s2 = ""; String s3 = ""; String tmp = ""; String tmp2 = ""; int i = 0; switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case UBLOCK:{ t = jj_consume_token(UBLOCK); if(k == 0) { s = t.toString(); } // If we are in the mode, such that the call has come from the input or LODD, we define the string as it is else { tmp2 = t.toString(); // If we are in the mode, such that the call came from LEVEN, we convert the string by the language rules while(i < tmp2.length()) { // for each character in our string if(i == 0) { // for the first character, we know we have a capital letter and so ignore the character i++; } else if((tmp2.charAt(i - 1) == ' ') && (tmp2.charAt(i) != ' ')) { // if we are moving from a space to a letter, we are on the first letter of the block and so ignore the character i++; } else if(tmp2.charAt(i) == ' ') { // if we have a space, we add the space to the String unchanged s = s + " "; i++;
  • 8. } else { // if we have character amongst a block, we simply make it lowercase and add it to our String s = s + Character.toLowerCase(tmp2.charAt(i)); i++; } } i = 0; // We reset i once we have traversed the String } break; } case UTAGOPEN:{ jj_consume_token(UTAGOPEN); tmp = LEVEN(1); jj_consume_token(UTAGCLOSE); if(k == 0) {s = tmp;} // If we are in the mode, such that the call has come from the input or LODD, we define the string as it is else { // If we are in the mode, such that the call came from LEVEN, we convert the string by the language rules while(i < tmp.length()) { // for each character in our string if(i == 0) { // for the first character, we know we have a capital letter and so ignore the character i++; } else if((tmp.charAt(i - 1) == ' ') && (tmp.charAt(i) != ' ')) { // if we are moving from a space to a letter, we are on the first letter of the block and so ignore the character i++; } else if(tmp.charAt(i) == ' ') { // if we have a space, we add the space to the String unchanged s = s + " "; i++; } else { // if we have character amongst a block, we simply make it lowercase and add it to our String s = s + Character.toLowerCase(tmp.charAt(i)); i++; } }
  • 9. i = 0; // We reset i once we have traversed the String } break; } default: jj_la1[3] = jj_gen; jj_consume_token(-1); throw new ParseException(); } switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case SBLOCK:{ t2 = jj_consume_token(SBLOCK); s2 = t2.toString(); // We then define LODD to be made up of any spaceblock, which we take the String of s3 = LODD(k); break; } default: jj_la1[4] = jj_gen; ; } {if ("" != null) return (s + s2 + s3);} throw new Error("Missing return statement in function"); } static private boolean jj_initialized_once = false; /** Generated Token Manager. */ static public AssignmentTokenManager token_source; static SimpleCharStream jj_input_stream; /** Current token. */ static public Token token; /** Next token. */ static public Token jj_nt; static private int jj_ntk; static private int jj_gen; static final private int[] jj_la1 = new int[5]; static private int[] jj_la1_0; static { jj_la1_init_0(); } private static void jj_la1_init_0() { jj_la1_0 = new int[] {0x286,0x204,0x8,0x82,0x8,}; } /** Constructor with InputStream. */ public Assignment(java.io.InputStream stream) { this(stream, null); } /** Constructor with InputStream and supplied encoding */ public Assignment(java.io.InputStream stream, String encoding) {
  • 10. if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. "); System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new AssignmentTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 5; i++) jj_la1[i] = -1; } /** Reinitialise. */ static public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } /** Reinitialise. */ static public void ReInit(java.io.InputStream stream, String encoding) { try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 5; i++) jj_la1[i] = -1; } /** Constructor. */ public Assignment(java.io.Reader stream) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. "); System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new AssignmentTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0;
  • 11. for (int i = 0; i < 5; i++) jj_la1[i] = -1; } /** Reinitialise. */ static public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 5; i++) jj_la1[i] = -1; } /** Constructor with generated Token Manager. */ public Assignment(AssignmentTokenManager tm) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. "); System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 5; i++) jj_la1[i] = -1; } /** Reinitialise. */ public void ReInit(AssignmentTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 5; i++) jj_la1[i] = -1; } static private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; if (token.kind == kind) { jj_gen++; return token; } token = oldToken; jj_kind = kind;
  • 12. throw generateParseException(); } /** Get the next Token. */ static final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; jj_gen++; return token; } /** Get the specific Token. */ static final public Token getToken(int index) { Token t = token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); } return t; } static private int jj_ntk_f() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } static private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); static private int[] jj_expentry; static private int jj_kind = -1; /** Generate ParseException. */ static public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[11]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 5; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } } } }
  • 13. for (int i = 0; i < 11; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.add(jj_expentry); } } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = jj_expentries.get(i); } return new ParseException(token, exptokseq, tokenImage); } /** Enable tracing. */ static final public void enable_tracing() { } /** Disable tracing. */ static final public void disable_tracing() { } }