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

Lua code examples #14

Open
osiyuk opened this issue Feb 27, 2018 · 2 comments
Open

Lua code examples #14

osiyuk opened this issue Feb 27, 2018 · 2 comments

Comments

@osiyuk
Copy link

osiyuk commented Feb 27, 2018

I think the first thing to do is to get codebase of simple Lua scripts/programs... or prepare it yourself. It will be helpful as starting point to think about parser/tokenizer and for testing purposes.

The idea is simple: if you want to test compiler, you'll need to prepare several code examples.

@osiyuk
Copy link
Author

osiyuk commented Mar 1, 2018

osiyuk@4253409

@yjerem What you think?

@paigeruten
Copy link
Contributor

paigeruten commented Mar 9, 2018

Currently I'm thinking the beginning of the book will just add Lua features to C, so you can write programs in C in sort of a Lua style using the Lua API. Since Lua is made to be embeddable in C and all. But I'm not sure about this, I'm still in the very early stages of planning this out.

But yeah, eventually we want the reader to build something that can actually parse and run some real Lua code. I'm thinking we'll start with parsing expressions, and implement sort of a "data-language" kinda like JSON, where it just parses literal Lua values (including arrays/tables) and gives you back an object and an API to traverse that object.

Then it'll proceed to add actual language features to the "data-language", like variables, functions, flow control, and so on. At that point it might be useful to have example Lua programs, although we might be able to let the reader make up their own programs to test with.

But you bring up a real good point about needing to test the program on something. I think it's important for the reader to be able to compile their program every few steps and test it out on something to actually see the results of the code they typed in. It's much more satisfying to build something big when you can constantly run it and see the changes yourself.

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