This is a lightning talk I gave at an internal event called Techquilla in ThoughtWorks Pune office.
More details: http://www.wikyblog.com/AmanKing/Multimethods
This is a lightning talk I gave at an internal event called Techquilla in ThoughtWorks Pune office.
More details: http://www.wikyblog.com/AmanKing/Multimethods
This presentation describes key concepts in Java. I call it The Java Quicky.
This is part of a series of presentations to cover the Java programming language and its new offerings and versions in depth.
This is my attempt to compose a brief and cursory introduction to concepts in Java programming language. I call it Java Quicky.
I plan to extend and enhance it over time.
JavaScript for Unleashed a game about a robbery in London and its pretty long i do not know why you would want it but here have it :P also this is not pro its just for school because i am a loner like that and i have nothing better to do
Since the release of Java 1.4.2 most of the developers thought the language designed by Sun was a blast for object-oriented programming and through the years a lot of so-called Java-design-patterns infected object-thinking and development process showing us tedious language syntax and dark magics. Then, 15 years later, a language by JetBrains tries to simplify the things: Kotlin, what is it? What does it try to simplify? Let's see at least 7 inconvenient Java aspects fixed in Kotlin
Java 8 helps use write better looking code. Checked exceptions, however, do not. What can we do to overcome these issues?
Lambdas and streams help us write clear and concise code, but can we do better? Javaslang helps out a bit.
Want more? Maybe turn to Scala.
This presentation describes key concepts in Java. I call it The Java Quicky.
This is part of a series of presentations to cover the Java programming language and its new offerings and versions in depth.
This is my attempt to compose a brief and cursory introduction to concepts in Java programming language. I call it Java Quicky.
I plan to extend and enhance it over time.
JavaScript for Unleashed a game about a robbery in London and its pretty long i do not know why you would want it but here have it :P also this is not pro its just for school because i am a loner like that and i have nothing better to do
Since the release of Java 1.4.2 most of the developers thought the language designed by Sun was a blast for object-oriented programming and through the years a lot of so-called Java-design-patterns infected object-thinking and development process showing us tedious language syntax and dark magics. Then, 15 years later, a language by JetBrains tries to simplify the things: Kotlin, what is it? What does it try to simplify? Let's see at least 7 inconvenient Java aspects fixed in Kotlin
Java 8 helps use write better looking code. Checked exceptions, however, do not. What can we do to overcome these issues?
Lambdas and streams help us write clear and concise code, but can we do better? Javaslang helps out a bit.
Want more? Maybe turn to Scala.
Que son los celos?
Los celos son una respuesta emocional compleja que puede ser altamente perturbadora, surge cuando una las personas percibe una amenaza hacia algo que considera de su propiedad. Comúnmente se denomina así a la sospecha o inquietud ante la posibilidad de que la persona amada nos reste atención en favor de otra. También se conoce así, al sentimiento de envidia hacia el éxito o posesión de otra persona. Los celos son una emoción que surge por querer poseer en exclusiva a la persona amada. El miedo a la pérdida, real o no, se planea como una amenaza
Java Programming Below are the lexer token and shank file.pdfabdulkadar1977
Java Programming: Below are the lexer, token, and shank files with the shank.txt. Fix any error in
the files but make sure the shank.txt is being printed out in the terminal of eclipse. Show the full
code for all three files along with the screenshot of shank.txt being read in the terminal. Attached is
the rubric.
Lexer.java
package mypack;
import java.util.ArrayList;
import java.util.List;
import mypack.Token.TokenType;
import java .util.HashMap;
public class Lexer {
private static final int INTEGER_STATE = 1;
private static final int DECIMAL_STATE = 2;
private static final int IDENTIFIER_STATE = 3;
private static final int ERROR_STATE = 4;
private static final int SYMBOL_STATE = 5;
private static final int STRING_STATE = 6;
private static final int CHAR_STATE = 7;
private static final int COMMENT_STATE = 8;
private static final char EOF = (char) -1;
private static String input;
private static int index;
private static char currentChar;
private static int lineNumber = 1;
private static int indentLevel = 0;
private static int lastIndentLevel = 0;
private static HashMap<String, TokenType> keywords = new HashMap<String, TokenType>() {{
put("while", TokenType.WHILE);
put("if", TokenType.IF);
put("else", TokenType.ELSE);
put("print", TokenType.PRINT);
}};
private static HashMap<Character, TokenType> symbols = new HashMap<Character,
TokenType>() {{
put('+', TokenType.PLUS);
put('-', TokenType.MINUS);
put('*', TokenType.MULTIPLY);
put('/', TokenType.DIVIDE);
put('=', TokenType.EQUALS);
put(':', TokenType.COLON);
put(';', TokenType.SEMICOLON);
put('(', TokenType.LEFT_PAREN);
put(')', TokenType.RIGHT_PAREN);
put('{', TokenType.LEFT_BRACE);
put('}', TokenType.RIGHT_BRACE);
put('<', TokenType.LESS_THAN);
put('>', TokenType.GREATER_THAN);
}};
public Lexer(String input) {
Lexer.input = input;
index = 0;
currentChar = input.charAt(index);
}
private void nextChar() {
index++;
if (index >= input.length()) {
currentChar = EOF;
} else {
currentChar = input.charAt(index);
}
}
private void skipWhiteSpace() {
while (Character.isWhitespace(currentChar)) {
nextChar();
}
}
private int getIndentLevel() {
int level = 0;
int i = index;
char c = input.charAt(i);
while (c == ' ' || c == 't') {
if (c == 't') {
level += 1;
} else if (c == ' ') {
level += 1;
}
i++;
if (i >= input.length()) {
break;
}
c = input.charAt(i);
}
return level;
}
public List<Token> lex(String inputString) throws Exception {
input = inputString;
index = 0;
currentChar = input.charAt(index);
List<Token> tokens = new ArrayList<Token>();
while (currentChar != EOF) {
switch (currentState()) {
case INTEGER_STATE:
integerState(tokens);
break;
case DECIMAL_STATE:
decimalState(tokens);
break;
case IDENTIFIER_STATE:
identifierState(tokens);
break;
case ERROR_STATE:
errorState(tokens);
break;
case SYMBOL_STATE:
symbolState(tokens);
break;
case STRING_STATE:
stringState(tokens);
break;
case CHAR_STATE:
charState(tokens);
break;
case COMMENT_STATE:
commentState(tokens);
break;
default:
break;
}
}
return tokens.
Java Programming Below are the lexer token and shank file.pdfadinathassociates
Java Programming: Below are the lexer, token, and shank files with the shank.txt. Shank.java is
the main method file. The main goal is to make sure the shank.txt is being printed out in the
terminal of eclipse. Make sure there are no errors in the code at all. Show the screenshot of
shank.txt being read in the terminal. Attached is the rubric.
Lexer.java
package mypack;
import java.util.ArrayList;
import java.util.List;
import mypack.Token.TokenType;
import java .util.HashMap;
public class Lexer {
private static final int INTEGER_STATE = 1;
private static final int DECIMAL_STATE = 2;
private static final int IDENTIFIER_STATE = 3;
private static final int ERROR_STATE = 4;
private static final int SYMBOL_STATE = 5;
private static final int STRING_STATE = 6;
private static final int CHAR_STATE = 7;
private static final int COMMENT_STATE = 8;
private static final char EOF = (char) -1;
private static String input;
private static int index;
private static char currentChar;
private static int lineNumber = 1;
private static int indentLevel = 0;
private static int lastIndentLevel = 0;
private static HashMap<String, TokenType> keywords = new HashMap<String, TokenType>() {{
put("while", TokenType.WHILE);
put("if", TokenType.IF);
put("else", TokenType.ELSE);
put("print", TokenType.PRINT);
}};
private static HashMap<Character, TokenType> symbols = new HashMap<Character,
TokenType>() {{
put('+', TokenType.PLUS);
put('-', TokenType.MINUS);
put('*', TokenType.MULTIPLY);
put('/', TokenType.DIVIDE);
put('=', TokenType.EQUALS);
put(':', TokenType.COLON);
put(';', TokenType.SEMICOLON);
put('(', TokenType.LEFT_PAREN);
put(')', TokenType.RIGHT_PAREN);
put('{', TokenType.LEFT_BRACE);
put('}', TokenType.RIGHT_BRACE);
put('<', TokenType.LESS_THAN);
put('>', TokenType.GREATER_THAN);
}};
public Lexer(String input) {
Lexer.input = input;
index = 0;
currentChar = input.charAt(index);
}
private void nextChar() {
index++;
if (index >= input.length()) {
currentChar = EOF;
} else {
currentChar = input.charAt(index);
}
}
private void skipWhiteSpace() {
while (Character.isWhitespace(currentChar)) {
nextChar();
}
}
private int getIndentLevel() {
int level = 0;
int i = index;
char c = input.charAt(i);
while (c == ' ' || c == 't') {
if (c == 't') {
level += 1;
} else if (c == ' ') {
level += 1;
}
i++;
if (i >= input.length()) {
break;
}
c = input.charAt(i);
}
return level;
}
public List<Token> lex(String inputString) throws Exception {
input = inputString;
index = 0;
currentChar = input.charAt(index);
List<Token> tokens = new ArrayList<Token>();
while (currentChar != EOF) {
switch (currentState()) {
case INTEGER_STATE:
integerState(tokens);
break;
case DECIMAL_STATE:
decimalState(tokens);
break;
case IDENTIFIER_STATE:
identifierState(tokens);
break;
case ERROR_STATE:
errorState(tokens);
break;
case SYMBOL_STATE:
symbolState(tokens);
break;
case STRING_STATE:
stringState(tokens);
break;
case CHAR_STATE:
charState(tokens);
break;
case COMMENT_STATE:
commentState(tokens);
break;
def.
Java Programming Below are the lexerjava tokenjava and .pdfadinathassociates
Java Programming: Below are the lexer.java, token.java, and shank.java. Shank.java is the main
method file. The goal is to make sure to read the shank.txt file as a series of tokens & show the
screenshot of shank.txt printed in console of eclipse. Make sure the lexer has all the state
machines. Attached is rubric where all the required components a lexer must have. Attached is
images of the errors the lexer has so make sure to fix those errors as well. Attached is image of
how the output must be printed out as after all the errors are fixed.
Lexer.java
package mypack;
import java.util.ArrayList;
import java.util.List;
import mypack.Token.TokenType;
import java .util.HashMap;
public class Lexer {
private static final int INTEGER_STATE = 1;
private static final int DECIMAL_STATE = 2;
private static final int IDENTIFIER_STATE = 3;
private static final int ERROR_STATE = 4;
private static final int SYMBOL_STATE = 5;
private static final int STRING_STATE = 6;
private static final int CHAR_STATE = 7;
private static final int COMMENT_STATE = 8;
private static final char EOF = (char) -1;
private static String input;
private static int index;
private static char currentChar;
private static int lineNumber = 1;
private static int indentLevel = 0;
private static int lastIndentLevel = 0;
private static HashMap<String, TokenType> keywords = new HashMap<String, TokenType>() {{
put("while", TokenType.WHILE);
put("if", TokenType.IF);
put("else", TokenType.ELSE);
put("print", TokenType.PRINT);
}};
private static HashMap<Character, TokenType> symbols = new HashMap<Character,
TokenType>() {{
put('+', TokenType.PLUS);
put('-', TokenType.MINUS);
put('*', TokenType.MULTIPLY);
put('/', TokenType.DIVIDE);
put('=', TokenType.EQUALS);
put(':', TokenType.COLON);
put(';', TokenType.SEMICOLON);
put('(', TokenType.LEFT_PAREN);
put(')', TokenType.RIGHT_PAREN);
put('{', TokenType.LEFT_BRACE);
put('}', TokenType.RIGHT_BRACE);
put('<', TokenType.LESS_THAN);
put('>', TokenType.GREATER_THAN);
}};
public Lexer(String input) {
Lexer.input = input;
index = 0;
currentChar = input.charAt(index);
}
private void nextChar() {
index++;
if (index >= input.length()) {
currentChar = EOF;
} else {
currentChar = input.charAt(index);
}
}
private void skipWhiteSpace() {
while (Character.isWhitespace(currentChar)) {
nextChar();
}
}
private int getIndentLevel() {
int level = 0;
int i = index;
char c = input.charAt(i);
while (c == ' ' || c == 't') {
if (c == 't') {
level += 1;
} else if (c == ' ') {
level += 1;
}
i++;
if (i >= input.length()) {
break;
}
c = input.charAt(i);
}
return level;
}
public List<Token> lex(String inputString) throws Exception {
input = inputString;
index = 0;
currentChar = input.charAt(index);
List<Token> tokens = new ArrayList<Token>();
while (currentChar != EOF) {
switch (currentState()) {
case INTEGER_STATE:
integerState(tokens);
break;
case DECIMAL_STATE:
decimalState(tokens);
break;
case IDENTIFIER_STATE:
identifierState(tokens);
break;
case ERROR_STATE:
errorState(tok.
Implement threads and a GUI interface using advanced Java Swing clas.pdfamrishinda
Implement threads and a GUI interface using advanced Java Swing classes.
Required data structure - the advanced data structure uses implementation of a multi-tree with
the following levels: Cave - level 0 Party - Level 1 Creature - Level 2 Artifacts - Level 3
Treasures - Level 3 Jobs
Use the Swing class JTree effectively to display the contents of the data file. Implement a JTable
to also show the contents of the data file.
Threads: Implement a thread for each job representing a task that creature will perform. Use the
synchronize directive to avoid race conditions and insure that a creature is performing only one
job at a time. The thread for each job should be started as the job is read in from the data file.
Only one job should be progressing for each creature at any moment. Use delays to show the
creature doing the task.
Use a JProgressBar for each creature to show the creature performing the task. Use JButton\'s on
the Job panel to allow the task to be suspended and cancelled. The GUI elements should be
distinct from the other classes in the program.
Solution
Please find the code below for the above problem :
import java.util.ArrayList;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Random;
import java.io.File;
import java.io.FileNotFoundException;
import javax.swing.JProgressBar;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Cave2 {
ArrayList parties = new ArrayList (); // the parties
ArrayList loners = new ArrayList (); // creatures not in parties
ArrayList drops = new ArrayList (); // Treasures not carried
ArrayList magics = new ArrayList (); // Artifacts not carried
ArrayList jobs = new ArrayList (); // Jobs to be performed
JFrame jf = new JFrame ();
JPanel jrun = new JPanel ();
JTextArea jta = new JTextArea (10, 10);
// hashmap of everything by index
HashMap hmElements = new HashMap ();
public Cave2 () {
Scanner sf = null;
String fileName = \"dataC.txt\";
try {
// sf = new Scanner (new File (fileName));
// getResourceAsStream is the way to access a data file in a jar package file
// this works in general, so leave it here as is.
sf = new Scanner (getClass().getResourceAsStream (fileName));
}
catch (Exception e) {
System.out.println (e + \"\ File bummer: \" + fileName);
} // end open file try/catch block
if (sf == null)
return;
readFile (sf);
jta.setText (toString ());
jf.setTitle (\"Cave2\");
jf.add (jrun, BorderLayout.PAGE_END);
jrun.setLayout (new GridLayout (0, 5, 2, 5));
jf.add (new JScrollPane (jta), BorderLayout.CENTER);
jta.setFont (new Font (\"Monospaced\", 0, 12));
jf.pack ();
jf.setVisible (true);
jf.setLocationRelativeTo (null);
} // end no-parameter constru.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* The Token set as an Enum type. This is just "binds" each token to its list of
* valid lexemes.
*
*
*/
public enum TOKEN {
ARTICLE("a", "the"), // a list of articles
NOUN("dog", "cat", "rat"), // a list of nouns
VERB("loves", "hates", "eats"), // a list of verbs
UNKNOWN(); // keep our lexemes "type-safe"!
//
// The lexemes under this token
private List<String> lexemeList;
// Construct the token with the list of lexems
private TOKEN(String... tokenStrings) {
lexemeList = new ArrayList<>(tokenStrings.length);
lexemeList.addAll(Arrays.asList(tokenStrings));
}
// Gets a token from a lexeme
public static TOKEN fromLexeme(String str) {
// Search through the lexemes looking for a match.
for (TOKEN t : TOKEN.values()) {
if (t.lexemeList.contains(str)) {
return t;
}
}
// If nothing matches then return UNKNOWN.
return UNKNOWN;
}
}
/**
* Programming Languages: Implementation and Design.
*
* A Simple Compiler Adapted from Sebesta (2010) by Josh Dehlinger further modified by Adam Conover
* (2012-2015)
*
* A simple compiler used for the simple English grammar in Section 2.2 of Adam Brooks Weber's
* "Modern Programming Languages" book. Parts of this code was adapted from Robert Sebesta's
* "Concepts of Programming Languages".
*
* This compiler assumes that the source file containing the sentences to parse is provided as the
* first runtime argument. Within the source file, the compiler assumes that each sentence to parse
* is provided on its own line.
*
* NOTE: A "real" compiler would more likely treat an entire file as a single stream of input,
* rather than each line being an independent input stream.
*/
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Compiler {
/**
* It is assumed that the first argument provided is the name of the source file that is to be
* "compiled".
*/
public static void main(String[] args) throws IOException {
//args = new String[]{"<some hard coded path for testing>"};
//args = new String[]{"D:\\Version_Controlled\\_SVN_\\Newton\\COS420\\Java\\ParserSample\\input.txt"};
if (args.length < 1) {
System.out.println("Need a filename!");
} else {
// Java 7 "try-with-resource" to create the file input buffer.
try (BufferedReader br = new BufferedReader(new FileReader(args[0]))) {
// Create the new lexer.
LexicalAnalyzer lexer = new LexicalAnalyzer();
// Start lexing and parsing.
processFile(lexer, br);
}
}
}
/**
* Reads each line of the input file and invokes th.
Given an expression string exp, write a java class ExpressionCheccke.pdfinfo382133
Given an expression string exp, write a java class ExpressionCheccker whose main method gets
exp in the input line of terminal and examines whether the pairs and the orders of ”(“,”)”,”[“,”]”
are correct in exp. For example, the program should print true for exp =“[()][()()]()” and false for
exp = “[(])”. ( Use stack)
Ans:
Algorithm:
1) Declare a character stack S.
2) Now traverse the expression string exp.
a) If the current character is a starting bracket (‘(‘ or ‘{‘ or ‘[‘) then push it to stack.
b) If the current character is a closing bracket (‘)’ or ‘}’ or ‘]’) then pop from stack and if the
popped character is the matching starting bracket then fine else parenthesis are not balanced.
3) After complete traversal, if there is some starting bracket left in stack then “not balanced”
Program:
#include
#include
#define bool int
/* structure of a stack node */
struct sNode
{
char data;
struct sNode *next;
};
/* Function to push an item to stack*/
void push(struct sNode** top_ref, int new_data);
/* Function to pop an item from stack*/
int pop(struct sNode** top_ref);
/* Returns 1 if character1 and character2 are matching left
and right Parenthesis */
bool isMatchingPair(char character1, char character2)
{
if (character1 == \'(\' && character2 == \')\')
return 1;
else if (character1 == \'{\' && character2 == \'}\')
return 1;
else if (character1 == \'[\' && character2 == \']\')
return 1;
else
return 0;
}
/*Return 1 if expression has balanced Parenthesis */
bool areParenthesisBalanced(char exp[])
{
int i = 0;
/* Declare an empty character stack */
struct sNode *stack = NULL;
/* Traverse the given expression to check matching parenthesis */
while (exp[i])
{
/*If the exp[i] is a starting parenthesis then push it*/
if (exp[i] == \'{\' || exp[i] == \'(\' || exp[i] == \'[\')
push(&stack, exp[i]);
/* If exp[i] is a ending parenthesis then pop from stack and
check if the popped parenthesis is a matching pair*/
if (exp[i] == \'}\' || exp[i] == \')\' || exp[i] == \']\')
{
/*If we see an ending parenthesis without a pair then return false*/
if (stack == NULL)
return 0;
/* Pop the top element from stack, if it is not a pair
parenthesis of character then there is a mismatch.
This happens for expressions like {(}) */
else if ( !isMatchingPair(pop(&stack), exp[i]) )
return 0;
}
i++;
}
/* If there is something left in expression then there is a starting
parenthesis without a closing parenthesis */
if (stack == NULL)
return 1; /*balanced*/
else
return 0; /*not balanced*/
}
/* UTILITY FUNCTIONS */
/*driver program to test above functions*/
int main()
{
char exp[100] = \"{()}[]\";
if (areParenthesisBalanced(exp))
printf(\"\ Balanced \");
else
printf(\"\ Not Balanced \");
return 0;
}
/* Function to push an item to stack*/
void push(struct sNode** top_ref, int new_data)
{
/* allocate node */
struct sNode* new_node =
(struct sNode*) malloc(sizeof(struct sNode));
if (new_node == NULL)
{
printf(\"Stack overflow \ \");
getchar();
exit(0);
}
/* put in the data */
new_node.
Java Code The traditional way to deal with these in Parsers is the .pdfstopgolook
Java Code: The traditional way to deal with these in Parsers is the Expression-Term-Factor
pattern:
Expression: TERM {+|- TERM}
Term: FACTOR {*|/ FACTOR}
Factor: number | ( EXPRESSION )
A couple of notation comments:
| means "or" - either + or -, either * or /
{} means an optional repeat. That's what allows this to parse 1+2+3+4
Think of these as functions. Every CAPTIALIZED word is a function call.
Consider our meme expression above: 6/2*(1+2)
We will start by looking at expression. Expression starts with a TERM. We can't do anything
until we resolve TERM, so let's go there.
A term starts with FACTOR. Again, we can't do anything until we deal with that.
A factor is a number or a (EXPRESSION). Now we can look at our token (hint:
MatchAndRemove). We see a number. OK - our factor is a number. We "return" that.
Remember that we got to factor from term. Let's substitute our number in:
TERM: FACTOR(6) {*|/ FACTOR}
Now we deal with our optional pattern. Is the next character * or /? Yes! Now is the next thing a
factor?
It turns out that it is. Let's substitute that in:
TERM: FACTOR(6) / FACTOR(2)
But remember that our pattern is a REPEATING pattern (hint: loop):
TERM: FACTOR(6) / FACTOR(2) {*|/ FACTOR}
We see the * and call factor. But this time, the factor is not a number but a parenthetical
expression.
Factor: number | ( EXPRESSION )
Factor calls expression.
Expression calls term, term calls factor, factor returns the number 1. Term doesn't see a * or / so
it passes the 1 up. Expression sees the + and calls term. Term calls factor which returns the 2.
Expression doesn't see a +|- value so ends the loop and returns 1+2.
So, remember that we were here:
TERM: FACTOR(6) / FACTOR(2) * FACTOR
Our factor is (1+2). That can't be broken down. That math HAS to be done before can multiply
or divide. That's what enforces order of operations.
In code, this looks like something like this (pseudo-code):
Node Factor()
num = matchAndRemove(NUMBER)
if (num.isPresent) return num
if (matchAndRemove(LPAREN).isPresent)
exp = Expression()
if (exp == null) throw new Exception()
if (matchAndRemove(RPAREN).isEmpty)
throw new Exception()
Node Term()
left = Factor()
do
op = MatchAndRemove(TIMES)
if (op.isEmpty) op=MatchAndRemove(DIVIDE)
if (op.isEmpty) return left
right = Factor()
left = MathOpNode(left, op, right)
while (true)
Node Expression()
left = Term()
do
op = MatchAndRemove(PLUS)
if (op.isEmpty) op=MatchAndRemove(MINUS)
if (op.isEmpty) return left
right = Term()
left = MathOpNode(left, op, right)
while (true)
What is this "MathOpNode"? It's "just" a new node type that holds two other nodes (left and
right) and an operation type: *, /, +, -. Notice that the loops use the result of one operation as the
left side of the next operation. This is called left associative - the left most part is done first.
Right associativity is the opposite - the rightmost part is done first, then we work our way left.
Generally, notice the pattern here - we call a function that is the lo.
META-INF/MANIFEST.MF
Manifest-Version: 1.0
.classpath
PriorityQueue.classpublicsynchronizedclass PriorityQueue {
Heap q;
public void PriorityQueue(int, java.util.Comparator);
public Object peek();
public Object remove();
void add(Object);
boolean isEmpty();
public int size();
}
PriorityQueue.javaPriorityQueue.javaimport java.util.Comparator;
publicclassPriorityQueue<E>{
Heap q;
/**
*PriorityQueue initializes the queue.
*
* @param initialCapacity an int that is the heaps initial size.
* @param comparator the priority of various imputs.
*/
publicPriorityQueue(int initialCapacity,Comparator<?super E> comparator){
q=newHeap(initialCapacity,comparator);
}
/**
* Peek, returns the next item in the queue without removing it.
*
* If it is empty then null is returned.
* @return the next item in the queue.
*/
public E peek(){
if(q.size()==0){
returnnull;
}
return(E) q.findMax();
}
/**
* This removes the first item from the queue.
*
* It returns null if the queue is empty.
* @return the first item in the queue.
*/
public E remove(){
if(q.size()==0){
returnnull;
}
return(E) q.removeMax();
}
/**
* This adds item to the queue
* @param item that is added to the queue.
*/
void add(E item){
q.insert(item);
}
/**
* isEmpty returns if the queue is empty or not.
*
* @return boolean if the queue is empty or not.
*/
boolean isEmpty(){
if(q.size()!=0){
returnfalse;
}
returntrue;
}
/**
* size returns the size of the queue.
*
* @return int the size of the queue.
*/
publicint size(){
return q.size();
}
}
ArithmeticExpression.classpublicsynchronizedclass ArithmeticExpression {
BinaryTree t;
java.util.ArrayList list;
String equation;
void ArithmeticExpression(String) throws java.text.ParseException;
public String toString(BinaryTree);
public String toPostfixString(BinaryTree);
void setVariable(String, int) throws java.rmi.NotBoundException;
public int evaluate(BinaryTree);
}
ArithmeticExpression.javaArithmeticExpression.javaimport java.rmi.NotBoundException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Stack;
/**
* ArithmeticExpression takes equations in the form of strings creates a binary
* tree, and can return either the regular or postfix equation. It also allows
* them to be calculated.
*
*
* Extra Credit:
* ** it can handle spaces or no spaces in the string inputted. ** it can return
* regular or postfix notation
*
* @author tai-lanhirabayashi
*
*/
publicclassArithmeticExpression{
BinaryTree t;
ArrayList list;
String equation;
/**
* ArithmeticExpression is the construction which takes in a space
* delimitated equation containing "*,/,+,-" symbols and converts it into a
* binary tree.
*
* If the expression is not valid it will throw a ParseException. This is ...
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
// Function: void parse(char *line, char **argv)
// Purpose : This function takes in a null terminated string pointed to by
// <line>. It also takes in an array of pointers to char <argv>.
// When the function returns, the string pointed to by the
// pointer <line> has ALL of its whitespace characters (space,
// tab, and newline) turned into null characters ('\0'). The
// array of pointers to chars will be modified so that the zeroth
// slot will point to the first non-null character in the string
// pointed to by <line>, the oneth slot will point to the second
// non-null character in the string pointed to by <line>, and so
// on. In other words, each subsequent pointer in argv will point
// to each subsequent "token" (characters separated by white space)
// IN the block of memory stored at the pointer <line>. Since all
// the white space is replaced by '\0', every one of these "tokens"
// pointed to by subsequent entires of argv will be a valid string
// The "last" entry in the argv array will be set to NULL. This
// will mark the end of the tokens in the string.
//
void parse(char *line, char **argv)
{
// We will assume that the input string is NULL terminated. If it
// is not, this code WILL break. The rewriting of whitespace characters
// and the updating of pointers in argv are interleaved. Basically
// we do a while loop that will go until we run out of characters in
// the string (the outer while loop that goes until '\0'). Inside
// that loop, we interleave between rewriting white space (space, tab,
// and newline) with nulls ('\0') AND just skipping over non-whitespace.
// Note that whenever we encounter a non-whitespace character, we record
// that address in the array of address at argv and increment it. When
// we run out of tokens in the string, we make the last entry in the array
// at argv NULL. This marks the end of pointers to tokens. Easy, right?
while (*line != '\0') // outer loop. keep going until the whole string is read
{ // keep moving forward the pointer into the input string until
// we encounter a non-whitespace character. While we're at it,
// turn all those whitespace characters we're seeing into null chars.
while (*line == ' ' || *line == '\t' || *line == '\n' || *line == '\r')
{ *line = '\0';
line++;
}
// If I got this far, I MUST be looking at a non-whitespace character,
// or, the beginning of a token. So, let's record the address of this
// beginning of token to the address I'm pointing at now. (Put it in *argv)
.
Programing with java for begniers .pptxadityaraj7711
Java is a high-level, object-oriented programming language developed by Sun Microsystems in the mid-1990s (now owned by Oracle Corporation). It is widely used for building a variety of applications, including desktop, web, mobile, and enterprise software. Java's design emphasizes portability, simplicity, and security, making it one of the most popular programming languages in the world.
### Importance of Java:
1. **Platform Independence**:
- Java programs can run on any device or operating system that supports the Java Virtual Machine (JVM).
- This "write once, run anywhere" (WORA) capability makes Java applications highly portable.
2. **Object-Oriented Programming (OOP)**:
- Java supports key OOP principles such as inheritance, encapsulation, polymorphism, and abstraction.
- These principles enable developers to create modular and reusable code.
3. **Rich Ecosystem and Libraries**:
- Java has a vast ecosystem of libraries, frameworks, and tools that facilitate development across various domains.
- Popular frameworks like Spring, Hibernate, and Apache Struts streamline development in enterprise environments.
4. **Robustness and Reliability**:
- Java has strong exception handling and type-checking mechanisms that contribute to the robustness and reliability of applications.
5. **Community and Support**:
- Java has a large and active developer community, providing support and resources for learning and troubleshooting.
- Java's extensive documentation and community forums are valuable resources for developers.
6. **Performance**:
- Java's just-in-time (JIT) compilation allows for optimized execution, improving performance.
- Java can handle large-scale applications and complex computations efficiently.
7. **Security**:
- Java's architecture includes features such as runtime security checks and a security manager for safe execution.
- This makes it a preferred choice for developing secure applications.
8. **Enterprise Applications**:
- Java is a dominant language in enterprise development due to its scalability, stability, and compatibility with existing systems.
- Many businesses rely on Java for mission-critical applications.
9. **Career Opportunities**:
- Proficiency in Java opens up many career opportunities, particularly in enterprise development, finance, healthcare, and telecommunications.
10. **Future-Proofing**:
- Java's continuous updates and compatibility with emerging technologies ensure that it remains relevant and future-proof.
Overall, Java's versatility, reliability, and widespread adoption make it an essential language for developers across various industries
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() {
}
}