Designing structure of the language
This commit is contained in:
parent
fd49fbc3c5
commit
fcbe96b91e
@ -1,6 +1,18 @@
|
||||
file = io.open("test.dms","rb")
|
||||
content = file:read("*a")
|
||||
line_num = 0
|
||||
CMD = {}
|
||||
CMD.__index = CMD
|
||||
function CMD:new(ln,cmd,args)
|
||||
local c = {}
|
||||
setmetatable(c,self)
|
||||
c.line_num = ln
|
||||
c.command = cmd
|
||||
c.args = args
|
||||
end
|
||||
function CMD:process()
|
||||
|
||||
end
|
||||
function string:trim()
|
||||
return (self:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
@ -8,12 +20,16 @@ local choice
|
||||
for line in content:gmatch("(.-)\n") do
|
||||
line_num = line_num + 1
|
||||
line = line:trim()
|
||||
line = line:gsub("")
|
||||
if line=="" then goto continue end
|
||||
::back::
|
||||
if line:match("^%[[_:,%w%(%)]+%]") then
|
||||
print(line_num,"BLOCK_START",line)
|
||||
elseif line:match("choice%s+\".+\"%s*:") then
|
||||
print(line_num,"CHOICE_BLOCK",line)
|
||||
choice = true
|
||||
elseif line:match("::([_:,%w%(%)]+)::") then
|
||||
print(line_num,"LABEL_BLOCK",line)
|
||||
elseif choice then
|
||||
choice = false
|
||||
if line:match("\".*\"%s*[_:,%w%(%)]+%(.*%)") then
|
||||
@ -25,4 +41,5 @@ for line in content:gmatch("(.-)\n") do
|
||||
else
|
||||
print(line_num,line)
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
16
test.dms
16
test.dms
@ -7,8 +7,8 @@ LOADFILE
|
||||
"This works!"
|
||||
"What's up"
|
||||
|
||||
Ryan: "Hello how are you doing?"
|
||||
Bob: "I'm good you?"
|
||||
Ryan "Hello how are you doing?"
|
||||
Bob "I'm good you?"
|
||||
|
||||
list = {1,2,3,true,false, {1,2,3}}
|
||||
a = list[1]
|
||||
@ -16,22 +16,22 @@ LOADFILE
|
||||
|
||||
::label::
|
||||
|
||||
choice "Pick one:":
|
||||
choice "Pick one:"
|
||||
"first" func()
|
||||
"second" func()
|
||||
"third" func()
|
||||
|
||||
for x = 1,10:
|
||||
for x = 1,10
|
||||
...
|
||||
|
||||
while cond:
|
||||
while cond
|
||||
...
|
||||
|
||||
if cond:
|
||||
if cond
|
||||
...
|
||||
elseif cond:
|
||||
elseif cond
|
||||
...
|
||||
else:
|
||||
else
|
||||
...
|
||||
|
||||
var1,var2 = func(1,"string", 2+5)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user