cznic / golex

github.com/cznic/golex has moved to modernc.org/golex
https://godoc.org/modernc.org/golex
BSD 3-Clause "New" or "Revised" License
182 stars 18 forks source link

Move examples to a subfolder; add lex&parse example using lex library. #12

Closed snakeru closed 7 years ago

snakeru commented 7 years ago

This example uses the lex.Lexer instead of a custom one. The reasons for the pull are two-fold: 1) There is no lexer+parser example for the languages with keywords yet. The most evolved example (calc) uses only operations and numbers, no keywords 2) Ability to mark the lexed candidate and then unread bytes on abort. I have lost the whole day before I realized what the problem was (the calc example is too primitive). Hopefully someone else will use my example. Specifically I was trying to parse a C-like language that features divisions (single slash) and comments until end of the line (double slash).

snakeru commented 7 years ago

Just in case my 'Done' comments already propagated to you: please bare with me, it's the first time I use github for code reviews. I am currently researching what is the proper way to git commit --amend here.

cznic commented 7 years ago

Just in case my 'Done' comments already propagated to you: please bare with me, it's the first time I use github for code reviews.

No problem and thanks for the PR!

snakeru commented 7 years ago

I amended my commit and did a force-push (hopefully that's the right way to do it - I was not able to find a clear instruction how to make changes and keep just a single commit). Please take another look. The correct commit is bf73...

Thank you for the TokenBytes() hint! I was able to delete a few lines.

snakeru commented 7 years ago

Thanks! Done.

cznic commented 7 years ago

Thank you!