From b325647ad9e7d0fa4e1ad2b1b20e424ad13fba70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Dobrovoljc?= Date: Tue, 3 Jun 2025 22:20:10 +0200 Subject: [PATCH] Limited comment length to 10 characters --- .gitignore | 1 - prg/test.pins25 | 2 ++ src/pins25/phase/LexAn.java | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 prg/test.pins25 diff --git a/.gitignore b/.gitignore index 585d773..5545717 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ out/ *.zip prg/**/*.ast prg/**/*.out -prg/**/*.pins25 \ No newline at end of file diff --git a/prg/test.pins25 b/prg/test.pins25 new file mode 100644 index 0000000..1d85da8 --- /dev/null +++ b/prg/test.pins25 @@ -0,0 +1,2 @@ +//1234567890 +//12345678901 \ No newline at end of file diff --git a/src/pins25/phase/LexAn.java b/src/pins25/phase/LexAn.java index 888f692..3b046e8 100644 --- a/src/pins25/phase/LexAn.java +++ b/src/pins25/phase/LexAn.java @@ -246,8 +246,14 @@ public class LexAn implements AutoCloseable { buffToken = new Token(start, Token.Symbol.DIV, "/"); return; } + nextChar(); + int length = 0; while (buffChar != '\n' && buffChar != -1) { + length++; + if (length > 10) { + throw new Report.Error(currentLocation(), "Comments can only be 10 characters long"); + } nextChar(); }