Pad
Pad is programming language.
Build
How to build of the pad.
UNIX & Windows
$ git clone https://github.com/narupo/pad
$ cd pad
$ make init && make
$ ./build/pad -h
In Windows, Recommend using TDM-GCC.
Syntax and feature
Bubble sort program.
{@
// Bubble sort program
vec = [3, 2, 4, 1]
k = 0
flag = true
for flag:
flag = false
for i = 0; i < len(vec) - 1 - k; i += 1:
if vec[i] > vec[i + 1]:
tmp = vec[i]
vec[i] = vec[i + 1]
vec[i + 1] = tmp
flag = true
end
end
k += 1
end
for i = 0; i < len(vec); i += 1:
puts(vec[i])
end
@}
Structure and functions and methods.
{@
struct Animal:
name = nil
def new(name):
return Animal(name)
end
met getName(self):
return self.name
end
end
animal = Animal.new("Tama")
puts(animal.getName())
@}
Functions and inject-block statement.
{@
def base(title):
block header: @}
<h1>{: title :}</h1>
{@ end
block content:
end
end
def index(title) extends base:
inject content: @}
<p>Welcome to my homepage!</p>
{@ end
super(title)
end
index("Pad")
@}
Pointer.
{@
s = "Hello"
def addWorld(pS):
*pS += ", World!"
end
addWorld(&s)
puts(s) // Hello, World!
@}
Exception.
{@
try:
1 / 0
catch ZeroDivisionError as e:
eputs(e.what()) // zero division error
end
@}
Vector and Dictionary.
{@
v1 = [1, 2, 3]
v2 = Vec()
d1 = { "a": 1, b: 2 }
d2 = Dict()
@}
Chain expression.
{@
from "unix" import cat, write
cat("README.md").upper() # write($r, "out.md")
@}
Development policy
- Pad is interpreter like C
- Pad keeps simple
- Pad needs many test cases
- Pad needs many standard libraries