SlideShare a Scribd company logo
Java Programming: Below is the ProgramNode extends Node.java file. There are errors in the
code so please fix those errors. There must be no errors at all. Attached is the rubric that is
circled in black all the components the ProgramNode extends Node.java file must have.
public class ProgramNode extends Node {
private Map<String, FunctionNode> functions;
public ProgramNode(Map<String, FunctionNode> functions) {
this.functions = functions;
}
public Map<String, FunctionNode> getFunctions() {
return functions;
}
public void setFunctions(Map<String, FunctionNode> functions) {
this.functions = functions;
}
public String toString() {
return "ProgramNode [functions=" + functions + "]";
}
public FunctionNode function() {
if(checkToken("define")) {
nextToken();
String name = getToken(TokenType.IDENTIFIER);
nextToken();
if(checkToken("(")) {
nextToken();
List<VariableNode> parameters = parameterDeclarations();
if(checkToken(")")) {
nextToken();
if(checkToken(TokenType.END_OF_LINE)) {
nextToken();
List<VariableNode> constants = constantDeclarations();
List<VariableNode> variables = variableDeclarations();
if(checkToken(TokenType.INDENT)) {
nextToken();
List<StatementNode> statements = new ArrayList<StatementNode>();
while(true) {
StatementNode statement = expression();
if(statement == null) {
break;
} else {
statements.add(statement);
}
}
if(checkToken(TokenType.DEDENT)) {
nextToken();
return new FunctionNode(name, parameters, constants, variables, statements);
}
}
}
}
}
}
return null;
}
public List<VariableNode> parameterDeclarations() {
List<VariableNode> parameters = new ArrayList<VariableNode>();
while(true) {
if(checkToken("var")) {
nextToken();
boolean changeable = true;
} else {
boolean changeable = false;
}
String name = getToken(TokenType.IDENTIFIER);
nextToken();
Node type = factor();
if(type == null) {
break;
}
VariableNode variable = new VariableNode(name, changeable, type);
parameters.add(variable);
if(checkToken(",")) {
nextToken();
} else {
break;
}
}
return parameters;
}
public List<VariableNode> constantDeclarations() {
List<VariableNode> constants = new ArrayList<VariableNode>();
while(true) {
if(checkToken("const")) {
nextToken();
}
String name = getToken(TokenType.IDENTIFIER);
nextToken();
Node type = factor();
if(type == null) {
break;
}
VariableNode constant = new VariableNode(name, false, type);
constants.add(constant);
if(checkToken(",")) {
nextToken();
} else {
break;
}
}
return constants;
}
public List<VariableNode> variableDeclarations() {
List<VariableNode> variables = new ArrayList<VariableNode>();
while(true) {
if(checkToken("var")) {
nextToken();
}
String name = getToken(TokenType.IDENTIFIER);
nextToken();
Node type = factor();
if(type == null) {
break;
}
VariableNode variable = new VariableNode(name, true, type);
variables.add(variable);
if(checkToken(",")) {
nextToken();
} else {
break;
}
}
return variables;
}
public ProgramNode parse() {
Map<String, FunctionNode> functions = new HashMap<String, FunctionNode>();
while(true) {
FunctionNode function = function();
if(function == null) {
break;
} else {
functions.put(function.getName(), function);
}
}
return new ProgramNode(functions);
}
public static void main(String[] args) {
ProgramNode program = parse();
for(FunctionNode function : program.getFunctions().values()) {
System.out.println(function);
}
}
}

More Related Content

Similar to Java Programming- Below is the ProgramNode extends Node-java file- The (1).pdf

jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
Guy Royse
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS Applications
FITC
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
leminhvuong
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
phanleson
 
Hadoop - Introduction to mapreduce
Hadoop -  Introduction to mapreduceHadoop -  Introduction to mapreduce
Hadoop - Introduction to mapreduce
Vibrant Technologies & Computers
 
Refactoring
RefactoringRefactoring
Refactoring
Amir Barylko
 
JDBC Connecticity.ppt
JDBC Connecticity.pptJDBC Connecticity.ppt
JDBC Connecticity.ppt
Swapnil Kale
 
Array Cont
Array ContArray Cont
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdf
aromalcom
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
Laurent_VB
 
Hadoop_Pennonsoft
Hadoop_PennonsoftHadoop_Pennonsoft
Hadoop_Pennonsoft
PennonSoft
 
Quick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using JasmineQuick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using Jasmine
Gil Fink
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
Clinton Dreisbach
 
Database programming
Database programmingDatabase programming
Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)
Anis Bouhachem Djer
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and Monoids
Hugo Gävert
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
Olexandra Dmytrenko
 
Lambda Functions in Java 8
Lambda Functions in Java 8Lambda Functions in Java 8
Lambda Functions in Java 8
Ganesh Samarthyam
 
Jdbc
JdbcJdbc
Java performance
Java performanceJava performance
Java performance
Sergey D
 

Similar to Java Programming- Below is the ProgramNode extends Node-java file- The (1).pdf (20)

jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS Applications
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
 
Hadoop - Introduction to mapreduce
Hadoop -  Introduction to mapreduceHadoop -  Introduction to mapreduce
Hadoop - Introduction to mapreduce
 
Refactoring
RefactoringRefactoring
Refactoring
 
JDBC Connecticity.ppt
JDBC Connecticity.pptJDBC Connecticity.ppt
JDBC Connecticity.ppt
 
Array Cont
Array ContArray Cont
Array Cont
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdf
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
 
Hadoop_Pennonsoft
Hadoop_PennonsoftHadoop_Pennonsoft
Hadoop_Pennonsoft
 
Quick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using JasmineQuick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using Jasmine
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Database programming
Database programmingDatabase programming
Database programming
 
Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and Monoids
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
Lambda Functions in Java 8
Lambda Functions in Java 8Lambda Functions in Java 8
Lambda Functions in Java 8
 
Jdbc
JdbcJdbc
Jdbc
 
Java performance
Java performanceJava performance
Java performance
 

More from aanyajoshi90

Jamal has red hair- Since the gene for red hair is recessive- Jamal mu.pdf
Jamal has red hair- Since the gene for red hair is recessive- Jamal mu.pdfJamal has red hair- Since the gene for red hair is recessive- Jamal mu.pdf
Jamal has red hair- Since the gene for red hair is recessive- Jamal mu.pdf
aanyajoshi90
 
Jake stole a suspension of Bacillus anthracis with a known concentrati.pdf
Jake stole a suspension of Bacillus anthracis with a known concentrati.pdfJake stole a suspension of Bacillus anthracis with a known concentrati.pdf
Jake stole a suspension of Bacillus anthracis with a known concentrati.pdf
aanyajoshi90
 
Ivanhoe arovides shutile service between 4 hotels near a medical cente.pdf
Ivanhoe arovides shutile service between 4 hotels near a medical cente.pdfIvanhoe arovides shutile service between 4 hotels near a medical cente.pdf
Ivanhoe arovides shutile service between 4 hotels near a medical cente.pdf
aanyajoshi90
 
its about the economic systems of Haiti XI- Economic Policies and Refo.pdf
its about the economic systems of Haiti XI- Economic Policies and Refo.pdfits about the economic systems of Haiti XI- Economic Policies and Refo.pdf
its about the economic systems of Haiti XI- Economic Policies and Refo.pdf
aanyajoshi90
 
IV- The EXT3 file system of Linux uses a multiple index structure- If (1).pdf
IV- The EXT3 file system of Linux uses a multiple index structure- If (1).pdfIV- The EXT3 file system of Linux uses a multiple index structure- If (1).pdf
IV- The EXT3 file system of Linux uses a multiple index structure- If (1).pdf
aanyajoshi90
 
its about the economic systems of Haiti IX- Post-Duvalier (1986-Presen.pdf
its about the economic systems of Haiti IX- Post-Duvalier (1986-Presen.pdfits about the economic systems of Haiti IX- Post-Duvalier (1986-Presen.pdf
its about the economic systems of Haiti IX- Post-Duvalier (1986-Presen.pdf
aanyajoshi90
 
Its in C++ and do not use int pls Given a string- return a new string.pdf
Its in C++ and do not use int pls Given a string- return a new string.pdfIts in C++ and do not use int pls Given a string- return a new string.pdf
Its in C++ and do not use int pls Given a string- return a new string.pdf
aanyajoshi90
 
it were the total dividends paid for 2022-Maniplo Cnorce 57-84 milion.pdf
it were the total dividends paid for 2022-Maniplo Cnorce 57-84 milion.pdfit were the total dividends paid for 2022-Maniplo Cnorce 57-84 milion.pdf
it were the total dividends paid for 2022-Maniplo Cnorce 57-84 milion.pdf
aanyajoshi90
 
j-51119ji-01274i- mplify the sum.pdf
j-51119ji-01274i- mplify the sum.pdfj-51119ji-01274i- mplify the sum.pdf
j-51119ji-01274i- mplify the sum.pdf
aanyajoshi90
 
Ivanhoe Inc- wishes to accumulate $1-612-000 by December 31- 2035- to.pdf
Ivanhoe Inc- wishes to accumulate $1-612-000 by December 31- 2035- to.pdfIvanhoe Inc- wishes to accumulate $1-612-000 by December 31- 2035- to.pdf
Ivanhoe Inc- wishes to accumulate $1-612-000 by December 31- 2035- to.pdf
aanyajoshi90
 
Jocelyn Rivers is a 68-year-old admitted for acute pulmonary edema- He.pdf
Jocelyn Rivers is a 68-year-old admitted for acute pulmonary edema- He.pdfJocelyn Rivers is a 68-year-old admitted for acute pulmonary edema- He.pdf
Jocelyn Rivers is a 68-year-old admitted for acute pulmonary edema- He.pdf
aanyajoshi90
 
Joe Newbie completed a test to inspect a sample of sales invoices to v.pdf
Joe Newbie completed a test to inspect a sample of sales invoices to v.pdfJoe Newbie completed a test to inspect a sample of sales invoices to v.pdf
Joe Newbie completed a test to inspect a sample of sales invoices to v.pdf
aanyajoshi90
 
Joan owns a citrus tree farm near Mesa- Arizona- Joan and her family h.pdf
Joan owns a citrus tree farm near Mesa- Arizona- Joan and her family h.pdfJoan owns a citrus tree farm near Mesa- Arizona- Joan and her family h.pdf
Joan owns a citrus tree farm near Mesa- Arizona- Joan and her family h.pdf
aanyajoshi90
 
ITN 298- Capstone Project 1- Describing WAN technologies- including VP.pdf
ITN 298- Capstone Project 1- Describing WAN technologies- including VP.pdfITN 298- Capstone Project 1- Describing WAN technologies- including VP.pdf
ITN 298- Capstone Project 1- Describing WAN technologies- including VP.pdf
aanyajoshi90
 
Ivanhoe Ltd- had the following account balances at December 31- 2024-P.pdf
Ivanhoe Ltd- had the following account balances at December 31- 2024-P.pdfIvanhoe Ltd- had the following account balances at December 31- 2024-P.pdf
Ivanhoe Ltd- had the following account balances at December 31- 2024-P.pdf
aanyajoshi90
 
Jennifer is an older Aboriginal client- She has lived in the city all.pdf
Jennifer is an older Aboriginal client- She has lived in the city all.pdfJennifer is an older Aboriginal client- She has lived in the city all.pdf
Jennifer is an older Aboriginal client- She has lived in the city all.pdf
aanyajoshi90
 
Jeff is trying very hard to change his flat tire- He struggles to lift.pdf
Jeff is trying very hard to change his flat tire- He struggles to lift.pdfJeff is trying very hard to change his flat tire- He struggles to lift.pdf
Jeff is trying very hard to change his flat tire- He struggles to lift.pdf
aanyajoshi90
 
JCL Inc- is a major chip manufacturing firm that sells its products to.pdf
JCL Inc- is a major chip manufacturing firm that sells its products to.pdfJCL Inc- is a major chip manufacturing firm that sells its products to.pdf
JCL Inc- is a major chip manufacturing firm that sells its products to.pdf
aanyajoshi90
 
Jenna is a flight attendant for an international carrier- In the summe.pdf
Jenna is a flight attendant for an international carrier- In the summe.pdfJenna is a flight attendant for an international carrier- In the summe.pdf
Jenna is a flight attendant for an international carrier- In the summe.pdf
aanyajoshi90
 
JBL Lab 9 (Applying Best Practices for Security Logging and Monitoring.pdf
JBL Lab 9 (Applying Best Practices for Security Logging and Monitoring.pdfJBL Lab 9 (Applying Best Practices for Security Logging and Monitoring.pdf
JBL Lab 9 (Applying Best Practices for Security Logging and Monitoring.pdf
aanyajoshi90
 

More from aanyajoshi90 (20)

Jamal has red hair- Since the gene for red hair is recessive- Jamal mu.pdf
Jamal has red hair- Since the gene for red hair is recessive- Jamal mu.pdfJamal has red hair- Since the gene for red hair is recessive- Jamal mu.pdf
Jamal has red hair- Since the gene for red hair is recessive- Jamal mu.pdf
 
Jake stole a suspension of Bacillus anthracis with a known concentrati.pdf
Jake stole a suspension of Bacillus anthracis with a known concentrati.pdfJake stole a suspension of Bacillus anthracis with a known concentrati.pdf
Jake stole a suspension of Bacillus anthracis with a known concentrati.pdf
 
Ivanhoe arovides shutile service between 4 hotels near a medical cente.pdf
Ivanhoe arovides shutile service between 4 hotels near a medical cente.pdfIvanhoe arovides shutile service between 4 hotels near a medical cente.pdf
Ivanhoe arovides shutile service between 4 hotels near a medical cente.pdf
 
its about the economic systems of Haiti XI- Economic Policies and Refo.pdf
its about the economic systems of Haiti XI- Economic Policies and Refo.pdfits about the economic systems of Haiti XI- Economic Policies and Refo.pdf
its about the economic systems of Haiti XI- Economic Policies and Refo.pdf
 
IV- The EXT3 file system of Linux uses a multiple index structure- If (1).pdf
IV- The EXT3 file system of Linux uses a multiple index structure- If (1).pdfIV- The EXT3 file system of Linux uses a multiple index structure- If (1).pdf
IV- The EXT3 file system of Linux uses a multiple index structure- If (1).pdf
 
its about the economic systems of Haiti IX- Post-Duvalier (1986-Presen.pdf
its about the economic systems of Haiti IX- Post-Duvalier (1986-Presen.pdfits about the economic systems of Haiti IX- Post-Duvalier (1986-Presen.pdf
its about the economic systems of Haiti IX- Post-Duvalier (1986-Presen.pdf
 
Its in C++ and do not use int pls Given a string- return a new string.pdf
Its in C++ and do not use int pls Given a string- return a new string.pdfIts in C++ and do not use int pls Given a string- return a new string.pdf
Its in C++ and do not use int pls Given a string- return a new string.pdf
 
it were the total dividends paid for 2022-Maniplo Cnorce 57-84 milion.pdf
it were the total dividends paid for 2022-Maniplo Cnorce 57-84 milion.pdfit were the total dividends paid for 2022-Maniplo Cnorce 57-84 milion.pdf
it were the total dividends paid for 2022-Maniplo Cnorce 57-84 milion.pdf
 
j-51119ji-01274i- mplify the sum.pdf
j-51119ji-01274i- mplify the sum.pdfj-51119ji-01274i- mplify the sum.pdf
j-51119ji-01274i- mplify the sum.pdf
 
Ivanhoe Inc- wishes to accumulate $1-612-000 by December 31- 2035- to.pdf
Ivanhoe Inc- wishes to accumulate $1-612-000 by December 31- 2035- to.pdfIvanhoe Inc- wishes to accumulate $1-612-000 by December 31- 2035- to.pdf
Ivanhoe Inc- wishes to accumulate $1-612-000 by December 31- 2035- to.pdf
 
Jocelyn Rivers is a 68-year-old admitted for acute pulmonary edema- He.pdf
Jocelyn Rivers is a 68-year-old admitted for acute pulmonary edema- He.pdfJocelyn Rivers is a 68-year-old admitted for acute pulmonary edema- He.pdf
Jocelyn Rivers is a 68-year-old admitted for acute pulmonary edema- He.pdf
 
Joe Newbie completed a test to inspect a sample of sales invoices to v.pdf
Joe Newbie completed a test to inspect a sample of sales invoices to v.pdfJoe Newbie completed a test to inspect a sample of sales invoices to v.pdf
Joe Newbie completed a test to inspect a sample of sales invoices to v.pdf
 
Joan owns a citrus tree farm near Mesa- Arizona- Joan and her family h.pdf
Joan owns a citrus tree farm near Mesa- Arizona- Joan and her family h.pdfJoan owns a citrus tree farm near Mesa- Arizona- Joan and her family h.pdf
Joan owns a citrus tree farm near Mesa- Arizona- Joan and her family h.pdf
 
ITN 298- Capstone Project 1- Describing WAN technologies- including VP.pdf
ITN 298- Capstone Project 1- Describing WAN technologies- including VP.pdfITN 298- Capstone Project 1- Describing WAN technologies- including VP.pdf
ITN 298- Capstone Project 1- Describing WAN technologies- including VP.pdf
 
Ivanhoe Ltd- had the following account balances at December 31- 2024-P.pdf
Ivanhoe Ltd- had the following account balances at December 31- 2024-P.pdfIvanhoe Ltd- had the following account balances at December 31- 2024-P.pdf
Ivanhoe Ltd- had the following account balances at December 31- 2024-P.pdf
 
Jennifer is an older Aboriginal client- She has lived in the city all.pdf
Jennifer is an older Aboriginal client- She has lived in the city all.pdfJennifer is an older Aboriginal client- She has lived in the city all.pdf
Jennifer is an older Aboriginal client- She has lived in the city all.pdf
 
Jeff is trying very hard to change his flat tire- He struggles to lift.pdf
Jeff is trying very hard to change his flat tire- He struggles to lift.pdfJeff is trying very hard to change his flat tire- He struggles to lift.pdf
Jeff is trying very hard to change his flat tire- He struggles to lift.pdf
 
JCL Inc- is a major chip manufacturing firm that sells its products to.pdf
JCL Inc- is a major chip manufacturing firm that sells its products to.pdfJCL Inc- is a major chip manufacturing firm that sells its products to.pdf
JCL Inc- is a major chip manufacturing firm that sells its products to.pdf
 
Jenna is a flight attendant for an international carrier- In the summe.pdf
Jenna is a flight attendant for an international carrier- In the summe.pdfJenna is a flight attendant for an international carrier- In the summe.pdf
Jenna is a flight attendant for an international carrier- In the summe.pdf
 
JBL Lab 9 (Applying Best Practices for Security Logging and Monitoring.pdf
JBL Lab 9 (Applying Best Practices for Security Logging and Monitoring.pdfJBL Lab 9 (Applying Best Practices for Security Logging and Monitoring.pdf
JBL Lab 9 (Applying Best Practices for Security Logging and Monitoring.pdf
 

Recently uploaded

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 

Java Programming- Below is the ProgramNode extends Node-java file- The (1).pdf

  • 1. Java Programming: Below is the ProgramNode extends Node.java file. There are errors in the code so please fix those errors. There must be no errors at all. Attached is the rubric that is circled in black all the components the ProgramNode extends Node.java file must have. public class ProgramNode extends Node { private Map<String, FunctionNode> functions; public ProgramNode(Map<String, FunctionNode> functions) { this.functions = functions; } public Map<String, FunctionNode> getFunctions() { return functions; } public void setFunctions(Map<String, FunctionNode> functions) { this.functions = functions; } public String toString() { return "ProgramNode [functions=" + functions + "]"; } public FunctionNode function() { if(checkToken("define")) { nextToken(); String name = getToken(TokenType.IDENTIFIER); nextToken(); if(checkToken("(")) { nextToken();
  • 2. List<VariableNode> parameters = parameterDeclarations(); if(checkToken(")")) { nextToken(); if(checkToken(TokenType.END_OF_LINE)) { nextToken(); List<VariableNode> constants = constantDeclarations(); List<VariableNode> variables = variableDeclarations(); if(checkToken(TokenType.INDENT)) { nextToken(); List<StatementNode> statements = new ArrayList<StatementNode>(); while(true) { StatementNode statement = expression(); if(statement == null) { break; } else { statements.add(statement); } } if(checkToken(TokenType.DEDENT)) { nextToken(); return new FunctionNode(name, parameters, constants, variables, statements); } }
  • 3. } } } } return null; } public List<VariableNode> parameterDeclarations() { List<VariableNode> parameters = new ArrayList<VariableNode>(); while(true) { if(checkToken("var")) { nextToken(); boolean changeable = true; } else { boolean changeable = false; } String name = getToken(TokenType.IDENTIFIER); nextToken(); Node type = factor(); if(type == null) { break; } VariableNode variable = new VariableNode(name, changeable, type); parameters.add(variable);
  • 4. if(checkToken(",")) { nextToken(); } else { break; } } return parameters; } public List<VariableNode> constantDeclarations() { List<VariableNode> constants = new ArrayList<VariableNode>(); while(true) { if(checkToken("const")) { nextToken(); } String name = getToken(TokenType.IDENTIFIER); nextToken(); Node type = factor(); if(type == null) { break; } VariableNode constant = new VariableNode(name, false, type); constants.add(constant); if(checkToken(",")) {
  • 5. nextToken(); } else { break; } } return constants; } public List<VariableNode> variableDeclarations() { List<VariableNode> variables = new ArrayList<VariableNode>(); while(true) { if(checkToken("var")) { nextToken(); } String name = getToken(TokenType.IDENTIFIER); nextToken(); Node type = factor(); if(type == null) { break; } VariableNode variable = new VariableNode(name, true, type); variables.add(variable); if(checkToken(",")) { nextToken();
  • 6. } else { break; } } return variables; } public ProgramNode parse() { Map<String, FunctionNode> functions = new HashMap<String, FunctionNode>(); while(true) { FunctionNode function = function(); if(function == null) { break; } else { functions.put(function.getName(), function); } } return new ProgramNode(functions); } public static void main(String[] args) { ProgramNode program = parse(); for(FunctionNode function : program.getFunctions().values()) { System.out.println(function); }
  • 7. } }