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