This commit is contained in:
Gašper Dobrovoljc 2025-03-08 19:36:20 +01:00
parent 56facf7372
commit 5ed3016bfd
No known key found for this signature in database
GPG Key ID: 0E7E037018CFA5A5
3 changed files with 35 additions and 7 deletions

1
.idea/misc.xml generated
View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="homebrew-23" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="homebrew-23" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />

View File

@ -1,2 +1,16 @@
var test = "1234" // hello world 1234567890
var something = 33 = , && || ! == != > < >= <= + - * / % ^ ( )
=,&&||!==!=><>=<=+-*/%^()
_a_0_ A0312 asd312 a_132asdnmznkjNAJDKNSJKDF
fun var if then else while do let in end
_fun_ _var_ _if_ _then_ _else_ _while_ _do_ _let_ _in_ _end_
infun invar inif inthen inelse inwhile indo inlet inin inend
funin varin ifin thenin elsein whilein doin letin endin
// == * 1248129 d8as90d8as9d asdkal //
1234567890='a' // 1+2
-1/asd*'x'+""
'a' '\'' '\\' '\0a' "\\ 1231 \n \ff _-ads"
"BESEDNJAKKKK" "0\" 0123" 0=XYZ 123+3+2+1(SSS) 4_bese
dica beseder_3456

View File

@ -240,13 +240,14 @@ public class LexAn implements AutoCloseable {
return; return;
case '/': case '/':
start = currentLocation();
nextChar(); nextChar();
if (buffChar != '/') { if (buffChar != '/') {
buffToken = new Token(currentLocation(), Token.Symbol.DIV, null); buffToken = new Token(start, Token.Symbol.DIV, null);
return; return;
} }
while (buffChar != '\n') { while (buffChar != '\n' && buffChar != -1) {
nextChar(); nextChar();
} }
@ -399,10 +400,24 @@ public class LexAn implements AutoCloseable {
nextChar(); nextChar();
while (buffChar != '"') { while (buffChar != '"') {
if (buffChar == -1) { if (buffChar == '\n' || buffChar == -1) {
throw new Report.Error(currentLocation(), "Unterminated string."); throw new Report.Error(currentLocation(), "Unterminated string.");
} }
if (!isChar()) {
if (buffChar == '\\') {
lexeme.append((char) buffChar);
nextChar();
if (buffChar == 'n' || buffChar == '\\' || buffChar == '"') {
} else if (isHex()) {
nextChar();
lexeme.append((char) buffChar);
if (!isHex()) {
throw new Report.Error(currentLocation(), "Invalid ascii code '" + (char) buffChar + "'.");
}
} else {
throw new Report.Error(currentLocation(), "Invalid escaped character '" + (char) buffChar + "'.");
}
} else if (!isChar()) {
throw new Report.Error(currentLocation(), "Invalid character '" + (char) buffChar + "'."); throw new Report.Error(currentLocation(), "Invalid character '" + (char) buffChar + "'.");
} }