SciRuby / rubex

rubex - A Ruby-like language for writing Ruby C extensions.
BSD 2-Clause "Simplified" License
451 stars 21 forks source link

Allow inline C code. #7

Open v0dro opened 7 years ago

v0dro commented 7 years ago

A new directive called C_INLINE should allow the user to directly write C code inside a Rubex file which will be directly copied into the resulting C code as-is. The opening and closing of this section will be demarcated on similar lines as flex's %{ ... %} directive for demarcating code sections.

The code inside this section will not be parsed with the Rubex compiler. Syntax correctness is the programmer's responsibility.

Code sample:

def meth
  int a = 4
  C_INLINE<<
    float b = 5;
    printf("%d", b);
  <<C_INLINE
end