Baguette
The Baguette# programming language is an esoteric programming language created to be BASIC-like but with name of pastries!
Basic Syntax
Generally speaking the syntax is fairly simple, a Baguette# program is a list of function call to the standard library of Baguette#, a function call is structured like this
NAME ( PARAM_1 PARAM_2 ... PARAM_N ) ;
But the fun is in the parameters, common symbols are
- The '(' is 'CHOUQUETTE'
- The ')' is 'CLAFOUTIS'
- The '"' are 'PARISBREST'
- The `;` is _of course_ `BAGUETTE`
- The `[` is `BABAAURHUM`
- The `]` is `CHARLOTTEAUXFRAISES`
- The `{` is `CRUMBLE`
- The `}` is `SCHNECKENKUCHEN`
- Keyword `BEGIN` is `MUFFIN`
- Keyword `END` is `COOKIES`
- Keyword `LABEL` is `ICECREAM`
- Keyword `IF` is `SABLE`
- Keyword `THEN` is `FRAMBOISIER`
- Keyword `GOTO` is `PAINVIENNOIS`
And for example print is CROISSANT so the traditional Hello World is
CROISSANT CHOUQUETTE PARISBREST Hello World PARISBREST CLAFOUTIS BAGUETTE
Basic Usage
The language supports
- IO
- Arithmetic
- Boolean algebra
- Arrays
- String manipulation
IO
Input and Output functions are the following
- `CROISSANT <list of arguments>` prints the arguments separated with a blank character, this list can be non-homogeneous meaning you can print integers,booleans,floats and strings with the same instruction, this instruction also ends with a newline character.
- `PAINAUCHOCOLAT <message> <list of replacement>` a `printf` version of `CROISSANT` the placeholder is `%d` for everything.
- `QUATREQUART <string:name> <argument:value>` create a new variable with the index `name` and assign it the value `value`
- `MADELEINE <string:name>` offer access to the variable of index `name` throw an exception if the index does not exist
- `ECLAIR` read the standard input
Arithmetic
Arithmetic operations in the standard library are
- `CANELE <list of numbers>` returns a _number_ which is the sum of the arguments (if you put a string somewhere in the args it will switch to concatenation of strings for the remaining of the list)
- `STHONORE <list of numbers>` same as CANELE but with the standard multiplication
- `KOUGNAMANN <number:a> <number:b>` returns `a^b`
- `PROFITEROLE <number:a>` returns the square root of a
- `FINANCIER <int:n>` returns the nth Fibonacci number as an integer
- `PAINAURAISIN <number:a> <number:b>` returns `a-b`
- `CHOCOLATINE <number:a> <number:b>` returns `a/b`
- `BRETZEL <int:a> <int:b>` returns a random integer in `[a,b]`
- `BAGUETTEVIENNOISE <number:a> <number:b>` returns the logarithm of a in the base b, so `ln a/ln b` with ln being the natural log
- `OPERA <number:a>` returns `-a`
- `MILLEFEUILLE <number:a>` returns the floor of a as an integer
- `FRAISIER <number:a>` returns the ceil of a as an integer
Boolean Algebra
- `TIRAMISU <argument:a> <argument:b>` returns `a==b`
- `MERINGUE <argument:a> <argument:b>` returns `a<=b`
- `MERVEILLE <argument:a> <argument:b> returns `a<b`
- `BRIOCHE <argument:a> <argument:b>` returns `a>=b`
- `TARTE <argument:a> <argument:b>` returns `a>b`
- `FLAN <argument:a> <argument:b>` returns `a&&b`
- `PAINDEPICE <argument:a> <argument:b>` returns `a||b`
- `CREPE <argument:a> <argument:b>` returns a XOR b
- `CHAUSSONAUXPOMMES <argument:a>` returns not a
Arrays
- `TARTEAUXPOMMES <int> <element>` : creates an array of n times the element
- `TARTEAUXFRAISES <int> <array>` : access the nth value of the array
- `TARTEAUXFRAMBOISES <int> <array> <element>` : replaces the nth value of the array with element
- `TARTEALARHUBARBE <n:int> <p:int> <element>` : creates a n by p matrix of element
- `GLACE <array>` : prints a human-readable string of the array
- `BEIGNET <array> <element>` : populates the array with elements without constructing a new one
String Manipulation
- `DOUGHNUT <s1:string> <s2:string> <s3:string>` : replace all occurrences of s2 in s by s3
- `BUCHE <int> <string>` : creates a string with n times the string provided
- `GAUFFREDELIEGE <s1:string> <s2:string>` : concat s1 and s2 (s1 ^ s2)
- `GAUFFREDEBRUXELLES <int> <string>` : returns the nth char of the provided string
- `GAUFFRE <s1:string> <s2:string>` : split s1 at each s2 and returns a string array
- `PANCAKE <string>` : transforms the string into an array of chars (of type string)
- `SIROPDERABLE <array>` : transforms the array into a string (joining the chars)
Type conversion
- `FROSTING <element>` converts the element into a string
- `CARROTCAKE <string>` converts the string into an integer
- `GALETTEDESROIS <string>` converts the string into a floating point number
- `FRANGIPANE <string>` converts the string into a boolean
Advanced Usage
Label's syntax are as followed
LABEL "name" BEGIN //CODE END ;
IF's syntax are
IF condition THEN BEGIN //CODE END ;
Function declaration syntax are
FUNCTION { "PARAM_1" "PARAM_2" ... "PARAM_N" } ( ..code.. ) ;
In Baguette#
- LABEL is ICECREAM
- BEGIN is MUFFIN
- END is COOKIES
- THEN is FRAMBOISIER
- CUPCAKE is true
- POPCAKE is false
An example of an IF statement
SABLE CUPCAKE FRAMBOISIER MUFFIN CROISSANT CHOUQUETTE PARISBREST this is true PARISBREST CLAFOUTIS COOKIES BAGUETTE
Examples
Hello World
CROISSANT CHOUQUETTE PARISBREST Hello World PARISBREST CLAFOUTIS BAGUETTE
Test of a function declaration
TEST CRUMBLE PARISBREST arg1 PARISBREST SCHNECKENKUCHEN CHOUQUETTE PAINAUCHOCOLAT CHOUQUETTE PARISBREST Argument %d PARISBREST MADELEINE CHOUQUETTE PARISBREST arg1 PARISBREST CLAFOUTIS CLAFOUTIS CLAFOUTIS BAGUETTE RDEUX CRUMBLE SCHNECKENKUCHEN CHOUQUETTE APFELSTRUDEL CHOUQUETTE 11 CLAFOUTIS CLAFOUTIS BAGUETTE TEST CHOUQUETTE PARISBREST Hello World PARISBREST CLAFOUTIS BAGUETTE
More test can be found on the github here