Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exam 1 - assignment 1 #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/pins24/common/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public enum Symbol {
SUB,
/** Simbol {@code *}. */
MUL,
/** Simbol {@code times}. */
TIMES,
/** Simbol {@code /}. */
DIV,
/** Simbol {@code %}. */
Expand Down
1 change: 1 addition & 0 deletions src/pins24/phase/LexAn.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ private void tryReadKeywordOrIdentifierToken() {
case "let" -> Token.Symbol.LET;
case "in" -> Token.Symbol.IN;
case "end" -> Token.Symbol.END;
case "times" -> Token.Symbol.TIMES;
default -> Token.Symbol.IDENTIFIER;
};
this.makeToken(symbol, lexeme.toString(), true);
Expand Down
4 changes: 2 additions & 2 deletions src/pins24/phase/SynAn.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ private AST.Init parseInitializer(boolean isOptional) {
Report.Locatable startPosition = nextPosition();
if (check(Token.Symbol.INTCONST)) {
Token num = consume(Token.Symbol.INTCONST);
if (check(Token.Symbol.MUL)) {
consume(Token.Symbol.MUL);
if (check(Token.Symbol.TIMES)) {
consume(Token.Symbol.TIMES);
AST.AtomExpr value = parseConst(false);
return saveNodeRangeAndReturn(startPosition, new AST.Init(
saveNodeRangeAndReturn(startPosition, new AST.AtomExpr(AST.AtomExpr.Type.INTCONST, num.lexeme())),
Expand Down
3 changes: 3 additions & 0 deletions tests/case-1.pins
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var a = 5 times 'A'

fun main() = putstr(^a)