[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua parser enhancement request
- From: Paul K <paul@...>
- Date: Wed, 29 Jul 2015 21:56:09 +0000
>> local i --[[:integer]] = 0
>> Ravi could parse the --[[: prelude and treat it as a type annotation,
>> tools do.
>> /s/ Adam
> This seems great to me. Ravi (or others) can parse the clean way and
> the commented way.
> A filter could convert code in both directions, if needed.
> If inline comments were a common way to do something like this,
> perhaps a more terse inline comment (perhaps with special
> restrictions, such as no nesting or it ends when when an = sign is
> present, as you're suggesting) would make some sense.
I took the same approach with integrating typedlua syntax into
ZeroBrane Studio analyzer (in a separate branch:
One can write:
const new:(self, number, number) -> (self)
local Shape = require "shape"
--[[const]] function Shape:new(x --[[:number]], y --[[:number]])
print(self, x, y) return self end
local shape --[[:Shape]] = Shape:new(10, 10)
to get it properly parsed by (extended) typedlua analyzer. The
"standard" typedlua syntax is also supported, but this approach allows
to skip the compilation step and still get the type information into
consideration during static analysis.