Replies: 2 comments 1 reply
-
Since Teal is built on top of Lua, the decision was made to be able to maintain compatability, only in specific circumstances are those words recognized as keywords. So the following is entirely valid Teal, (but shouldn't be encouraged)
Is this all you are planning? You can probably get away with just saying those are keywords in the lexer then. |
Beta Was this translation helpful? Give feedback.
-
Oh I see, so it is the parser that makes a difference between parsing Lua and parsing Teal, right? Would there be a way to force
Well, the actual plan is more contrived; the plan is to parse Teal (and other Lua-based languages), extracting comments as part of the AST preferrably, to automatically generate documentation for Teal projects, with the possibility to also extract types and include them in the documentation. That alone sounds like the simplest part, in comparison to the other part I'd need a parser for: generating highlighted source code that isn't only colored, but also links identifiers to their definitions, shows a variable's type on hover... It's basically documentation generation but much more involved, and similar to Haddock. Now that I know the parser is exposed, I will probably use that, but I would also appreciate being able to query the types of certain identifiers to include them in the result, without having to infer the types myself.
Will definitely check out! Thank you. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm making a project that involves lexing different Lua-based languages, and Teal is one of them. I discovered the
lpeg-lexer
branch on this repository and was surprised to find an already workinglpeg.re
-based lexer, which is miraculously exactly what I was looking for. However, upon closer inspection, I noticed that the lexer doesn't include any such keywords likeis
,record
,enum
,type
... These are instead treated as identifiers. Is this how the lexer is supposed to be used?Apart from lexing Teal using
lpeg.re
, I am looking to extend the leafo/lua-syntaxhighlight repository with Teal support, for HTML highlighting, and while it isn't complicated, I need to know what are all changes over base Lua that Teal makes, apart from keywords.As a third point: how easy would it be to repurpose the
lpeg-lexer
to be a simple Lua lexer? Is it simply about removing:
as an operator? What else would it involve?Thank you.
Update: Seems like this has escalated a whole lot! I thought I could get away with only the lexer, but it turns out that I also need a parser and ideally, to be able to extract type information (as detailed in #180). Teal becoming modular might help a lot with what I want to do.
Beta Was this translation helpful? Give feedback.
All reactions