Files
lua/type.lua
The Lua team b9dde086db This is Lua 1.0. It was never publicly released. This code is a snapshot of
the status of Lua on 28 Jul 1993. It is distributed for historical curiosity
to celebrate 10 years of Lua and is hereby placed in the public domain.

There is no documentation, except the test programs. The manual for Lua 1.1
probably works for this version as well.

The source files for the lexer and parser have been lost: all that is left is
the output of lex and yacc. A grammar can be found inside y_tab.c in yyreds.

The code compiles and runs in RedHat 5.2 with gcc 2.7.2.3. It may not run in
newer systems, because it assumes that stdin and stdout are constants, though
ANSI C does not promise they are. If make fails, try using the fixed modules
provided in the "fixed" directory. To see the differences (which are really
quite minor), do "make diff".

To see Lua 1.0 in action, do "make test". (The last test raises an error on
purpose.)

Enjoy!

-- The Lua team, lua@tecgraf.puc-rio.br
2003-10-09 23:44:30 -03:00

35 lines
801 B
Lua
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
$debug
function check (object, class)
local v = next(object,nil);
while v ~= nil do
if class[v] = nil then print("unknown field: " .. v)
elseif type(object[v]) ~= class[v].type
then print("wrong type for field " .. v)
end
v = next(object,v);
end
v = next(class,nil);
while v ~= nil do
if object[v] = nil then
if class[v].default ~= nil then
object[v] = class[v].default
else print("field "..v.." not initialized")
end
end
v = next(class,v);
end
end
typetrilha = @{x = @{default = 0, type = "number"},
y = @{default = 0, type = "number"},
name = @{type = "string"}
}
function trilha (t) check(t,typetrilha) end
t1 = @trilha{ x = 4, name = "3"}
a = "na".."me"