[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LPEG and indentation based syntax
- From: Fabien <fleutot+lua@...>
- Date: Fri, 13 Apr 2007 18:09:27 +0200
There's a sample in metalua which uses indentation to structure statement blocks. The extension is here:
http://metalua.luaforge.net/src/samples/pythonic.lua.html
And here's an example of a program using it:
----------------------------------------------------------------------
-- This file requires an alternative lexer, therefore it must be
-- compiled that way:
-- > mlc -x pythonic.lua pysample.lua
-- Or, if you want to execute it right away:
-- > mlc -x pythonic.lua -x pysample.lua
----------------------------------------------------------------------
print "Eratosthenes' Sieve, in pythonic Metalua:"
function print_sieve (limit):
local sieve, i = { }, 2
while i<limit:
while sieve[i]:
i=i+
1
print(i)
for j = i*i, limit, i:
sieve[j] = true
i=i+1
print_sieve(100)
In case there are issues with indentation through mail (one of the reasons why I'm no fan of significant whitespaces in real-life conditions), it's also available at
http://metalua.luaforge.net/src/samples/pysample.lua.html