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

Doubt: How do I run a file with lox code? #1

Open
kvnandula04 opened this issue Oct 3, 2020 · 2 comments
Open

Doubt: How do I run a file with lox code? #1

kvnandula04 opened this issue Oct 3, 2020 · 2 comments

Comments

@kvnandula04
Copy link

Hi, so, I'm new to all of this but I am trying to run a file with lox code and am not sure how to do it. I cloned the java interpreter to try it out and I feel so constrained as I can only type single line code snippets in the REPL. So, I was wondering about how to run a file with code. I have a few questions:

  1. What file extension do I use?
  2. How do I run it? Is it using the terminal?
  3. Do I need to compile the code before running it?

Any help would be much appreciated! Thanks a lot!

@geertguldentops
Copy link
Owner

geertguldentops commented Oct 3, 2020

Hi @kvnandula04,

Thanks for showing interest! Did you find the information in the README.md file? It gives a brief overview of how you can run a lox program.

To answer your specific questions:

  1. The file extension does not matter, the Java interpreter does not check this. I use .lox by convention.
  2. The easiest way to run a program is by using an IDE, I recommend using IntelliJ IDEA. Just run the main program (LoxMain). You were already able to do this successfully, this gives you the REPL functionality. Just pass in the absolute path to a Lox program as the first program argument and it will interpret that file as a Lox program.
  3. You need to compile the Java program (the interpreter itself) but the Lox code itself does not need to be compiled, it is immediately interpreted by the Java program.

I wrote a bunch of acceptance tests that run Lox programs. You can find those Lox programs here: src/main/resources/lox/src for instance: HelloWorld.lox

Hope this explanation helps. Happy coding!

@kvnandula04
Copy link
Author

Hi @geertguldentops,

Wow! Thanks for the help! Getting some things cleared up now. For point 2, I'm still uncertain. Would you mind sharing a code snippet or a screenshot of how to do it please?

For some context, I'm currently building an IDE for a lox dialect that I'm working on called Krystal. It's expected to look something like this...

image

And I plan to make it an executable file which I can upload online so that people can download that and start using Krystal(don't know if that's possible in Java). So any help with this would also be much appreciated!

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants