ExpandCollapsePrev Next Index

+ 5.1 Output control

When Felix emits primitive functions, by default it will have to put parentheses around every subexpression, since it does not actually parse the C code. This would make the output look like Scheme rather than C++!

+ 5.1.1 Specifying precedence

You can specify the precedence to avoid gratuitous parentheses like this:

  fun add: int * int -> int = "$1:add + $2:mult" is add;

The precedences are named, from tightest binding to loosest binding:

  atom
  primary
  postfix
  unary
  cast
  pm
  mult
  add
  shift
  rel
  eq
  band
  bxor
  bor
  and
  xor
  or
  cond
  assign
  comma
  expr

+ 5.1.2 Special cases

Felix does parse some special cases (exactly as written no spaces allowed):

  $1++
  $1--

  ~$1
  +$1
  -$1
  !$1
  &$1
  *$1
  ++$1
  --$1
  $1+$2
  $1-$2
  $1*$2
  $1/$2
  $1%$2

  $1<<$2
  $1>>$2
  $1&$2
  $1|$2
  $1^$2
  $1&&$2
  $1||$2

  $1+=$2
  $1-=$2
  $1*=$2
  $1/=$2
  $1%=$2
  $1<<=$2
  $1>>=$2
  $1&=$2
  $1|=$2
  $1^=$2

  $1<$2
  $1>$2
  $1>=$2
  $1<=$2
  $1==$2
  $1!=$2

  $1
  $1[$2]
  $1->$2
  $1.*$2
  $1->*$2
  $1,$2

  &::std::cout
  &::std::cerr
  $1.size
  $1.data[$2]

  ::flx::rtl::strutil::str<int>
  ::flx::rtl::strutil::str<#1>
  static_cast<#0>
  reinterpret<?1>

and the form

  name(expr)

which is assumed to be a function application. Additional forms may be recognised in the future. If you don't mis-specify precedences, Felix should always generated correct code (it just might have more parentheses than it needs).