Skip to content

Commit 2e548ef

Browse files
committed
Translate remaining comments to English and ignore auto-generated CUP file
1 parent 919e5d6 commit 2e548ef

8 files changed

Lines changed: 37 additions & 529 deletions

File tree

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ logs/
1515
*.java~
1616

1717
# Ignore notes, TO-DO lists, and other temporary files
18-
.dev/
18+
.dev/
19+
20+
# Ignore the intermediate CUP grammar file automatically generated for AST construction
21+
src/main/resources/*_astbuild.cup

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,5 @@ Note that, for testing purposes, standard input has been substituted with a file
102102
You can always run MicroJava Compiler as a standalone application.
103103
In order to achieve this, you just have to type `gradlew run <source-file-name> <obj-file-name>` (Windows) or `./gradlew run <source-file-name> <obj-file-name>` (macOS and Linux).
104104

105-
## Note to the reader of this README
106-
107-
If you have any question, suggestion or collaboration offer, please feel free to [contact me](mailto:[email protected]).
108-
**If you find this repository useful, please consider starring it!**
105+
---
106+
**If you find this repository useful, please consider starring it! ⭐**

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ tasks.build {
6363
dependsOn("spotlessCheck")
6464
}
6565

66-
val jflexDir = layout.buildDirectory.dir("generated/sources/jflex/java/main").get()
67-
val cupDir = layout.buildDirectory.dir("generated/sources/cup/java/main").get()
66+
val jflexDir: Directory = layout.buildDirectory.dir("generated/sources/jflex/java/main").get()
67+
val cupDir: Directory = layout.buildDirectory.dir("generated/sources/cup/java/main").get()
6868

6969
sourceSets.main {
7070
java.srcDirs(jflexDir, cupDir)

settings.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
rootProject.name = 'microjava-compiler'
2-

src/main/resources/mjlexer.flex

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ Identifier = [a-zA-Z][a-zA-Z0-9_]*
6060
%%
6161

6262
<YYINITIAL> {
63-
// Whitespace characters (Beline)
63+
// Whitespace characters
6464
{Whitespace} { /* ignore */ }
6565

66-
// Keywords (Ključne reci)
66+
// Keywords
6767
"program" { return newSymbol(sym.PROGRAM); }
6868
"break" { return newSymbol(sym.BREAK); }
6969
"class" { return newSymbol(sym.CLASS); }
@@ -80,54 +80,53 @@ Identifier = [a-zA-Z][a-zA-Z0-9_]*
8080
"continue" { return newSymbol(sym.CONTINUE); }
8181
"const" { return newSymbol(sym.CONST); }
8282

83-
// Operators (Operatori)
84-
// Arithmetic (Aritmetički)
83+
// Operators
84+
// Arithmetic operatrors
8585
"+" { return newSymbol(sym.PLUS); }
8686
"-" { return newSymbol(sym.MINUS); }
8787
"*" { return newSymbol(sym.TIMES); }
8888
"/" { return newSymbol(sym.DIV); }
8989
"%" { return newSymbol(sym.MOD); }
9090
"++" { return newSymbol(sym.INCR); }
9191
"--" { return newSymbol(sym.DECR); }
92-
// Relational (Relacioni)
92+
// Relational operatrors
9393
"==" { return newSymbol(sym.EQ); }
9494
"!=" { return newSymbol(sym.NEQ); }
9595
"<" { return newSymbol(sym.LT); }
9696
"<=" { return newSymbol(sym.LEQ); }
9797
">" { return newSymbol(sym.GT); }
9898
">=" { return newSymbol(sym.GEQ); }
99-
// Logical (Logički)
99+
// Logical operatrors
100100
"&&" { return newSymbol(sym.AND); }
101101
"||" { return newSymbol(sym.OR); }
102102

103-
// Assignment (Dodela vrednosti)
103+
// Assignment
104104
"=" { return newSymbol(sym.ASSIGN); }
105105

106-
// Separators (Separatori)
106+
// Separators
107107
";" { return newSymbol(sym.SEMI); }
108108
"," { return newSymbol(sym.COMMA); }
109109
"." { return newSymbol(sym.DOT); }
110110

111-
// Delimiters (Delimiteri)
112-
"(" { return newSymbol(sym.LPAREN); } // Parentheses (Oble (male) zagrade).
111+
// Delimiters
112+
"(" { return newSymbol(sym.LPAREN); } // Parentheses
113113
")" { return newSymbol(sym.RPAREN); }
114-
"[" { return newSymbol(sym.LBRACKET); } // (Square) Brackets (Uglaste (srednje) zagrade).
114+
"[" { return newSymbol(sym.LBRACKET); } // (Square) Brackets
115115
"]" { return newSymbol(sym.RBRACKET); }
116-
"{" { return newSymbol(sym.LBRACE); } // (Curly) Braces (Vitičaste (velike) zagrade).
116+
"{" { return newSymbol(sym.LBRACE); } // (Curly) Braces
117117
"}" { return newSymbol(sym.RBRACE); }
118118

119-
// Comments (Komentari)
119+
// Comments
120120
{Comment} { /* ignore */ }
121121

122-
// Literals (Literali)
122+
// Literals
123123
{DecIntegerLiteral} { return newSymbol(sym.INT, new Integer(yytext())); }
124124
{BooleanLiteral} { return newSymbol(sym.BOOL, Boolean.valueOf(yytext())); }
125125
{PrintableCharLiteral} { return newSymbol(sym.CHAR, new Character(yytext().charAt(1))); }
126126

127-
// Identifiers (Identifikatori)
127+
// Identifiers
128128
{Identifier} { return newSymbol(sym.IDENT, yytext()); }
129129

130-
// Lexical error (Leksička greška)
131-
// Svi tekst-editori numerisu linije počev od broja 1. Stoga je na yyline dodat broj 1.
130+
// Lexical error (all text editors use 1-based indexing for lines, so yyline is incremented by 1)
132131
[^] { lexicalErrorMJLogger.log(yytext(), yyline + 1, yycolumn + 1); return newSymbol(sym.ERROR); }
133132
}

src/main/resources/mjparser.cup

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ scan with {:
8787
/* ************** NON-TERMINAL SYMBOLS *************** */
8888

8989
/*
90-
* Neterminalni simboli su navedeni po redosledu pojavljivanja na desnoj strani smena.
90+
* Non-terminal symbols are listed in the order of their appearance on the right-hand side of the productions
9191
*/
9292
nonterminal Program;
9393

@@ -177,7 +177,7 @@ nonterminal Relop;
177177
/* *************** TERMINAL SYMBOLS *************** */
178178

179179
/*
180-
* Terminalni simboli su navedeni po redosledu pojavljivanja na desnoj strani smena.
180+
* Terminal symbols are listed in the order of their appearance on the right-hand side of the productions
181181
*/
182182

183183
terminal PROGRAM;
@@ -188,7 +188,7 @@ terminal String IDENT;
188188
terminal CONST;
189189
terminal SEMI;
190190
terminal CLASS;
191-
terminal String RBRACE; // Dummy atribut tipa String (videti objašnjenje u PRODUCTIONS delu).
191+
terminal String RBRACE; // Dummy String attribute (refer to the explanation in the PRODUCTIONS section)
192192

193193
terminal COMMA;
194194

@@ -204,17 +204,17 @@ terminal RBRACKET;
204204
terminal EXTENDS;
205205

206206
terminal LPAREN;
207-
terminal String RPAREN; // Dummy atribut tipa String (videti objašnjenje u PRODUCTIONS delu).
207+
terminal String RPAREN; // Dummy String attribute (refer to the explanation in the PRODUCTIONS section).
208208

209209
terminal VOID;
210210

211211
terminal INCR;
212212
terminal DECR;
213213
terminal IF;
214214
terminal WHILE;
215-
terminal String BREAK; // Dummy atribut tipa String (videti objašnjenje u PRODUCTIONS delu).
216-
terminal String CONTINUE; // Dummy atribut tipa String (videti objašnjenje u PRODUCTIONS delu).
217-
terminal String RETURN; // Dummy atribut tipa String (videti objašnjenje u PRODUCTIONS delu).
215+
terminal String BREAK; // Dummy String attribute (refer to the explanation in the PRODUCTIONS section).
216+
terminal String CONTINUE; // Dummy String attribute (refer to the explanation in the PRODUCTIONS section).
217+
terminal String RETURN; // Dummy String attribute (refer to the explanation in the PRODUCTIONS section).
218218
terminal READ;
219219
terminal PRINT;
220220

@@ -254,9 +254,9 @@ precedence left ELSE;
254254
/* *************** PRODUCTIONS *************** */
255255

256256
/*
257-
* Smene su navođene u poretku koji odgovara preorder obilasku sintaksnog stabla.
258-
* Atributi sa nazivom "dummy" uvedeni su, kao što im i ime sugeriše, ne zbog potrebe da se koristi njihova vrednost,
259-
* već da bi se mogao zapamtiti u odgavarajucem sintaksnom čvoru broj linije, u izvornom fajlu MikroJava programa, koja sadrži odgovarajući neterminal.
257+
* Productions follow the preorder traversal of the syntax tree.
258+
* 'Dummy' attributes are used solely to store the source line number
259+
* for the non-terminal within the syntax node, rather than for their actual values.
260260
*/
261261

262262
Program ::= (Program) PROGRAM ProgramName DeclList LBRACE MethodDeclList ProgramEnd;
@@ -413,11 +413,11 @@ ArrayElemAccessDesignatorLBracket ::= (ArrayElemAccessDesignatorLBracket) LBRACK
413413
Expr ::= (TermExpr) Term
414414
| (MinusTermExpr) MINUS Term
415415
| (AddopExpr) Expr Addop Term;
416-
// Leva rekurzija, jer se zahteva da Addop operatori (+ i -) budu levo ascoijativni
416+
// Left recursion, because Addop operators (+ and -) are required to be left-associative
417417

418418
Term ::= (FactorTerm) Factor
419419
| (MulopTerm) Term Mulop Factor;
420-
// Leva rekurzija, jer se zahteva da Mulop operatori (*, / i %) budu levo asocijativni
420+
// Left recursion, because Mulop operators (*, / and %) are required to be left-associative
421421

422422
Factor ::= (DesignatorFactor) Designator
423423
| (MethodCallFactor) Designator ActParsStart ActPars ActParsEnd

0 commit comments

Comments
 (0)