A small scripting language implemented in Python (SimpleLangInterpreter).
LuxSimpleLang is a small educational scripting language with simple syntax. It supports variables, control structures, loops, functions, file I/O, list operations and built-in helpers.
end
or ;
.x = 5
."text"
.# comment
/* ... */
print "Hello world" x = 5 y = x * 2 print y
if x > 10: print "x greater than 10" else: print "x less or equal to 10" end
i = 0 while i < 3: print "i = " + str(i) i = i + 1 end
loop 5: print "repeated" end
for i in 1..5: if i == 3: continue print i if i == 4: break end
function greet: print "Hello from function" end call greet
Functions have no parameters in this simple interpreter (variables are global). Return values can be stored manually in variables if needed.
writefile "file.txt", "text"
– create or overwrite fileappendfile "file.txt", "text"
– append textreadfile "file.txt"
– content stored in _lastread
createdir "folder"
– create folderlistdir "path"
– list directory contentsdeletedir "folder"
– remove empty folderwritefile "log.txt", "First line\n" appendfile "log.txt", "Another line\n" readfile "log.txt" print _lastread
upper("text")
– to uppercaselower("TEXT")
– to lowercasesplit("a,b,c", ",")
– split stringname = "Antonin" print upper(name) words = split("one two three") print words
mylist = [1,2,3] append mylist, 4 remove mylist, 0 print mylist # [2,3,4]
date
– current date (YYYY-MM-DD)rand(min, max)
– random integerlen(list)
– list lengthexists("path")
– test existencesleep(seconds)
– pauseprint date print rand(1, 100) if exists("log.txt"): print "File exists" end sleep(1)
You can request input from user:
name = input "Your name:" print "Hello " + name
# single line /* multi line */
LuxSimpleLang je malý výukový skriptovací jazyk s jednoduchou syntaxí. Podporuje proměnné, podmínky, cykly, funkce, práci se soubory, seznamy a vestavěné pomocné funkce.
end
nebo ;
x = 5
"text"
#
nebo /* ... */
print "Ahoj světe" x = 5 y = x * 2 print y
if x > 10: print "x je větší než 10" else: print "x je menší nebo rovno 10" end
i = 0 while i < 3: print "i = " + str(i) i = i + 1 end
loop 5: print "opakování" end
for i in 1..5: if i == 3: continue print i if i == 4: break end
function pozdrav: print "Ahoj z funkce" end call pozdrav
Funkce v této jednoduché verzi nemají parametry (proměnné jsou globální). Návratové hodnoty lze ukládat do proměnných ručně.
writefile "soubor.txt", "text"
– vytvoří nebo přepíše souborappendfile "soubor.txt", "text"
– přidá textreadfile "soubor.txt"
– obsah uloží do _lastread
createdir "složka"
– vytvoří složkulistdir "cesta"
– vypíše obsah složkydeletedir "složka"
– odstraní prázdnou složkuwritefile "log.txt", "První řádek\n" appendfile "log.txt", "Další řádek\n" readfile "log.txt" print _lastread
upper("text")
– na velká písmenalower("TEXT")
– na malá písmenasplit("a,b,c", ",")
– rozdělí řetězecjmeno = "Antonin" print upper(jmeno) slova = split("jeden dva tři") print slova
seznam = [1,2,3] append seznam, 4 remove seznam, 0 print seznam # [2,3,4]
date
– aktuální datum (YYYY-MM-DD)rand(min, max)
– náhodné číslolen(seznam)
– délka seznamuexists("cesta")
– test existencesleep(sekundy)
– pauzaprint date print rand(1, 100) if exists("log.txt"): print "Soubor existuje" end sleep(1)
jmeno = input "Vaše jméno:" print "Ahoj " + jmeno
# jednořádkový /* víceřádkový komentář */