Intro

yupp is syntactically based on Lisp-like parenthesized prefix notation. The following are the language сore syntactic forms:
  • literal constants
    • strings and characters (like in C) - "Hello world!"
    • integer and float numbers - 1.618
    • atoms (like C identifiers but can contain hyphen) - phi
    • quotes(`the string without quotation marks)
  • list forms
    • simple lists - (0 0x01 2.0)
    • application forms - ($sqrt 2)
    • source code insertions [case type_($T):]
  • infix expressions - {(1 + sqrt(5)) / 2}
  • lambda expressions are list  forms with parameters - \p.($pow 2 p)
Any list forms can be nested within each other. Only the application form can be embedded into the source code directly.
Application form is a list with $ character before the first item. The first item is a function, the rest are arguments. The following examples can be tried out on yupp Web Console at http://yup-py.appspot.com/.
($add 17 71)
88
In the above example, the built-in function of addition takes two numeric arguments. Any functions from string, operator and math modules of Python standard library can be used in expressions.
Set form allows to bind an atom with certain value.
($set ovi 8)
($set fwd (ovi 13 28))
($fwd)
81328
In order to define a function - bind an atom with a lambda expression.
($set cen \f.($1 *f))
($cen fwd)
13
Above is an example of function definition (cen) with one parameter (f), which returns the second element of a list passed as an argument. An application of a number is the subscripting operation on arguments.
($0 20 72 1)
20
Embedding of one list into another implements by the * operator.
($set ru1 ( *fwd 55 26 20))
($set ru2 (17 71 41 *(79 6) 20))
If the subscripting takes only one argument which is a list - the embedding is implied, so we can miss * in the cen function definition.
($set cen \f.($1 f))
The application of a list spawns a cycle, functions passing as arguments are applied to each item of the list.
($(2 1 0) \n.($n fwd))
28138

($fwd \n.[($n), ])
8, 13, 28,
The [] brackets are used for enclosing of the source code into preprocessor expressions  as well as an application of the code function and the reverse square brackets ]<EOL> <EOL>[ . Square brackets can be safely used into the source code insertion e.g. [a[1] = 0].
($set p (L C R D D G))
($ ($range ($len p)) \n.]
    ($n p): ($n ru2)
[ )
L: 17  C: 71  R: 41  D: 55  D: 26  G: 20
The built-in range function generates lists containing arithmetic progressions.
($range 5 10 2)
579
Conditional expression contains: condition, alternative - an expression to be evaluated if the condition evaluates to zero (empty list (), empty code [] or empty quote (`)) and consequent - an expression to be evaluated for other values of the condition.
consequent ? condition | alternative
($set fib
    \n.($ n ? { n < 2 } | {($fib { n - 1 }) + ($fib { n - 2 })})
)
($ ($range 6 11) \i.]
    ($ru1 \n.($n ? ($eq n ($fib i))))
    
[ )
8
13

55
The {} braces enclose infix expressions on Python. An infix expression can be embedded straight into the source code as follows:
(${} log1p(e - 1))
1.0
As arguments, the macro definition ($macro ) takes a name of the macro, a list of parameters and a token sequence which is referred to as the macro's expansion. The following dict macro has three parameters: the identifier of dictionary (id), the list of columns identifiers (cols) and actually, the dictionary (body).
($macro dict (id cols body)
    ($set cols-($id) ($range ($len (($cols)) )))
    ($set each-($id) ($range ($len (($body)) )))
    ($set (($cols))
        ($cols-($id) \i.($ (($body)) \var.($i var)))
    )
)
When the macro name is invoked in an application, the macro's expansion replaces the macro invocation. Therefore, the following application of the dict macro
($dict D
    (` name  type             length )
    (`
    (  a     char             10     )
    (  b     float            1      )
    (  c     char             1      )
    (  d     (`unsigned int)  1      )
    )
)
equals to
($set cols-D (0 1 2))
($set each-D (0 1 2 3))
($set name (a b c d))
($set type (char float char (`unsigned int)))
($set length (10 1 1 1))
Quote ($quote ) returns its arguments, as written, without evaluating them.  (` ) is an abbreviation for ($quote ).
($each-D \i.]
    ($i type) ($i name)($[[($i length)]] ? { ($i length) > 1 });
    
[ )
char a[10];
float b;
char c;
unsigned int d;
In some specific cases ,, (double comma) and ;; (double semicolon) can be used for the source code enclosing e. g. ($exp,,text,,text;;exp,,text).
($import 'dict.yu')
($set n 5)
($unfold n,,30*pi/180, ,,60*pi/180, ,,90*pi/180, )
equals to
($unfold n [30*pi/180, ] [60*pi/180, ] [90*pi/180, ])
30*pi/180, 60*pi/180, 90*pi/180, 90*pi/180, 90*pi/180,
Application of import ($import ) has the following variants:
  • import of the library on yupp -
($import stdlib)
  • including of the text (the same file may be inserted several times) -
($import 'dict.yu')
  • import of the library on Python -
($import 'grab_sensors.py')
  • including of the text generated by the infix expression on Python -
($import {grab_sensors('https://goo.gl/mJ6cHv', 'sensors.json')})

If the last parameter is the ellipsis \... the lambda can take a variable number of arguments. Optional arguments are accessible into the variable argument list __va_args__.
($ \fn.\...($__va_args__ \n.[($fn n) ]) sqrt 4 16 64 0x100)
2.0 4.0 8.0 16.0
The latest version of the preprocessor and a few more examples can be found on yupp project page under http://github.com/in4lio/yupp/.