This page has been written by Hubert Tonneau, then enhanced by William Merriam.
The Pliant parser is original in that it doesn't rely on an automaton derived from a grammar. It is simpler, but more customizable and therefore much more powerful.
The syntax introduced below should not be seen as imposed by Pliant; it is simply the default. It has been designed to be the cleanest ever built (needing the smallest number of non-significant symbols). However, keep in mind that if you don't like it, it is possible to write a module that extends it, or even changes it.
foo(3,5)
(foo 3 5)
console "Hello world" eol # This is my first program.
5 -12 2Ch 0B74Eh 10010010b
10.3 -1.27e-3
"abc" "abc def["]ghi"
abc def"ghi
abc abc_def32 'abc' 'abc def'
The link operator is ':'. As an example:
abc:def:ghi:jkl
(((abc def) ghi) jkl)
The separation operation is ';' . As an example:
abc def ; ghi jkl mno ; pqr stu
{ (abc def) (ghi jkl mno) (pqr stu) }
abc def := ghi jkl mno
( ':=' (abc def) (ghi jkl mno) )
The ':>' operator has exactly the same syntax as ':=' but has a different meaning.
not condition condition1 and condition2 condition1 or condition2
c1 or not c2 and c3
c1 or ((not c2) and c3)
The behavior of '-' operator is a bit more complex:
.not. .or. .and. .xor. operators are bitwise operators equivalent to the ~ | & ^ operators of C.
.+. .-. .*. .^. operators are the same as + - * ^ but do not generate an error on overflow.As an example, in a 32-bit environment,
2*10^9+10^9
2*10^9.+.10^9
Please note that there are no bit-shift operators (equivalent to << and >> in C) in Pliant since the ^ operator, which does not exist in C, can replace them.
->
The following program:
abc def gh ijk lm nop qr st
(abc def gh { (ijk lm) (nop qr st) } )
The rules are very simple to deduce:
These rules are very simple and efficient, and avoid most ( ) and { }As an example, here is the definition of the 'factorial' function:
function factorial x -> f arg Int x f if x=0 f := 1 else f := x * (factorial x-1)
Tabs are not allowed in the source code: you have to use spaces instead. The main reason for not allowing them is that not everybody agrees on the number of spaces each tab stands for, so when a program contains several modules provided by different people, the number could be different in various modules. Tabs could be allowed if the number of spaces they stood for were declared at the beginning of the module, but then the various editors would have to be aware of that ... so it is simpler to use only spaces. Furthermore, most editors provide a 'translate tabs to spaces' function.