Syntax / Structure
Language Syntax
Fluency Programming Language follows the JavaScript / ECMAScript (ES6) syntax closely.
Any user with some familiarity of JavaScript can quickly pick up this language. Addtionally, ES6 syntax compatibility allows the FPL code to be highlighted and error-checked in most common Code editors used today.
Hello, World!
A sample FPL program code block:
function main() {
printf("Hello, World!\n")
return {}
}
FPL Code Block
The main()
function
An FPL script / code block consist of a main()
function. The main()
function must return a Map
object.
function main() {
let s = 100
if (s == 5) {
printf("s is equal to 5")
} elseif (s < 10) {
printf("s is less than 10 (and is not 5)")
} else {
printf("s is greater or equal to 10")
}
return {}
}
note
In the Fluency Platform (processor) pages, sometimes the main()
functions can return a status string
.
function main() {
...
return "pass" // "drop", "abort", "error"
}
This is a shorthand for:
return { status: "pass" }
It is also possible to pass in arguments into this function and they can be given a default value
// the function takes an argument s and has a default value of 100
function main({s=100}) {
if (s == 5) {
printf("s is equal to 5")
} elseif (s < 10) {
printf("s is less than 10 (and is not 5)")
} else {
printf("s is greater or equal to 10")
}
return {}
}
Comments
Comments are supported with the follow syntax:
function main() {
// this is a single line comment
/*
block
with multiple lines
line 3
*/
return {}
}