Skip to content

Commit

Permalink
Code improvements
Browse files Browse the repository at this point in the history
[+] Added JFileChooser for input file on parser code
[·] Added ignored auto-generated files from lexer and parser
  • Loading branch information
Ziocash committed Jul 13, 2024
1 parent a54958c commit 08651a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ hs_err_pid*
# .vscode subfolder
.vscode/
CompilatoreAcDc/src/test/data/output.txt
JCup/src/cup/Symbols.java
JCup/src/cup/Lexer.java
JCup/src/cup/Parser.java
10 changes: 8 additions & 2 deletions JCup/src/parser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import cup.symboltable.*;
import java.io.IOException;
import java.io.FileReader;
import java.io.File;
import javax.swing.JFileChooser;

parser code {:

Expand Down Expand Up @@ -173,11 +174,16 @@ init with {:
logger = new StringBuilder();
ComplexSymbolFactory f = new ComplexSymbolFactory();
symbolFactory = f;
File file = new File("C:\\Users\\Simone Gattini\\source\\repos\\UPO-Fondamenti-Linguaggi-Traduttori\\JCup\\data\\input.txt");
FileReader reader = null;
try {
JFileChooser chooser = new JFileChooser(new File(".").getCanonicalPath());
int value = chooser.showOpenDialog(null);
File file = null;
if(value == JFileChooser.APPROVE_OPTION) {
file = new File(chooser.getSelectedFile().getAbsolutePath());
}
reader = new FileReader(file);
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
}
lexer = new Lexer(f,reader);
Expand Down

0 comments on commit 08651a0

Please sign in to comment.