-
-
Notifications
You must be signed in to change notification settings - Fork 4
Syntax Ideas
Mario Alejandro Montoya edited this page Sep 5, 2020
·
2 revisions
-- Comments start with 2 'minus' symbol
--- Multiline
commentaries
---
- All integers are 64-bits.
Syntax:
1
- All binary floating-point are 64-bits.
Syntax:
1.1f
- For decimal floating-point are 64-bits,
d
subfix is not necessary (is the default float type)
Syntax:
1.1d = 1.1
0b
1b
0100110b
(Array)
Syntax:
true
false
-
All strings are UTF-8 encoding guaranteed. You could delimiter strings with double-quotes or an apostrophe.
-
Using double-quotes if you want to escape apostrophes.
Syntax: "hello 'wonderful' world!"
- Using apostrophes if you want to escape double-quotes.
Syntax: 'hello "wonderful" world!'
- You could use triple quotes for multiline strings.*
Syntax:
"""hello from
multiline world!"""
You can do string interpolation
"hello {1 + 2}"
- Dates are written in ISO format
dt"2001-01-10T23:02:10"
d"2001-01-10"
t"23:02:10"
not and or
< <= => >
<>
=
+ - * /
:=
+= -= *= /=
() grouping
[] vector
|| row
[<>] writen as rows
[||] writen as cols
do
end
var -- mutable
let -- inmutable
Color -- types
COLOR -- const
color -- vars/others
color_blue -- multi-words
Int
Dec
Str
Float
Bit
Date
Time
DateTime
Char
Vec
Map
Tree
Any
Rows & Values
, -- separate columns
; -- separate rows
nums = Vec[it:i32; 1; 2; 3]
nums = 1
nums = [1]
Fac := Map[| key id:Int, code:Str, cust:Str, salesman:Int|] -- header/type
-- written as rows
Map := Map[|
id:Int, name:Str;
1, "hello"; -- row0
2, "world" -- row1
|]
-- written as columns
Tree := Tree[<
id:Int = 1; 2; 3 -- col0
name:Str = "hello"; "world"; "other" -- col1
>]
-- Define a primary key (pk) is optional, if pk is not used then the row is unique.
city := Map[| id:Int, code:Dec pk]
city := Tree[| id:Int, code:Dec, name:Str pk|]
named:
city := | id=1, name="miami" |
anon:
city := | 1, "miami" |
enum Color do
Blue: Int
Red: (String, String)
Rgb: (red:Int, blue:Int, green:Int)
Other
end
-- Only for numbers, string, characters and boolean values
enum HttpError do
E404 := 404
E500 := 500
end
rel City do
key id:Int pk,
code:Str,
cust:Str,
salesman:Int
end
a := [1, 2, 3] # 0
>> a = 1
[1, 3, 4] # [0, 2] = [1, 4]
city ?select #name (#0 ?limit 1)
city #name #id
city ?select #name
if is a:Vec[Int] do
let a = cast a:Vec[Int]
let value :=
if true do
1
elif a > 2
2
else
2
end
pending...
match thing do
1 do 1 end
2 do 1 end
_ do 4 end
is a:Vec _ do
end
is Color.Rgb(a, b, c) do
end
end
while true do
println("this repeat forever")
end
for i in range(1,10) do --this count from 1 to 9
println(i)
end
fun save(a:Int, b:Int) = Int do
end