zxul767 / lox

An interpreter for the Lox language
1 stars 0 forks source link

make `jlox` support relative paths #16

Open zxul767 opened 1 year ago

zxul767 commented 1 year ago

clox currently supports relative paths when running files as follows:

make run NAME=../samples/basic_class.lox

we should make jlox support the same. at present it throws this error:

Exception in thread "main" java.nio.file.NoSuchFileException: ../samples/basic_class.lox
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:375)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:426)
        at java.base/java.nio.file.Files.readAllBytes(Files.java:3272)
        at dev.zxul767.lox.Lox.runFile(Lox.java:49)
        at dev.zxul767.lox.Lox.main(Lox.java:42)
zxul767 commented 1 year ago

marking as p1 because the workaround, although easy, is not intuitive:

make run NAME=$PWD/../samples/string.lox