Keywords: xcoral

Next: Function definition Up: Smac Previous: Smac

# Smac definition

Smac is a SMall Ansi C interpreter developed to extend Xcoral editor services, but it is also possible to use Smac outside Xcoral (see §9 page ).

This chapter gives definitions of Smac functions independently of Xcoral, valid whether they are used within or without Xcoral. The next chapter will describe their interface with Xcoral.

Smac implements a subset of the ANSI C standard, but to be fully functional it also implements some extensions of it:

- In traditional C, a program has a single entry point named main(). In Smac, each function is an entry point, thus a main() definition is not required, besides Smac does not know the name main.
- You can evaluate a sequence of expressions outside any function definition. These expressions are placed between braces as a function body, and are named free expressions. The only restriction is that you cannot put any declaration in a free expression, for instance to define a local variable.

  For example, you can directly write:

- There is no programming time and run time (in the C usual sense) in Smac. As in LISP you define functions and global variables, or execute free expressions when and where you want (providing that all necessary global definitions are made).
- Files are not separately considered, as soon as you declare or define functions and variables, you increase your global environment .

To manually interrupt a Smac execution, hit Ctrl-c in the window where Xcoral or just Smac is running (kill -2 on Xcoral pid). To stop current execution by program (as with exit() UNIX system function but without Xcoral or Smac ending) see error() §6.6.7 page .

According to the Smac compiling flags (see §9 page ) Smac can check all your memory access/modification to avoid core dump or other things. In this case, all allocated objects are taken from a special memory area whose default size is `2^18` bytes under Xcoral, and `2^15` bytes otherwise. You can update the SMAC_MEMORY_SIZE environment variable to increase it, its value must be a power of two (default `2^18` or `2^15`).

In all cases the Smac stack size is 1024 words by default. To increase it update the SMAC_STACK_SIZE environment variable; its value corresponds to the number of words it can contain (a word permits to memorize a char, an int or a pointer).

- Function definition
- Global variable definition
- Preprocessor
- Types
- Keywords
- Predefined functions
  - Formatted output conversion
    - printf
    - sprintf
  - Memory
    - malloc
    - calloc
    - free
    - memcpy
  - Strings
    - strcat
    - strchr
    - strcmp
    - strcpy
    - strcspn
    - strdup
    - strlen
    - strncat
    - strncmp
    - strncpy
    - strpbrk
    - strrchr
    - strspn
    - strstr
    - strtok
    - index
    - rindex
  - Redefinition
    - remove_function_definition
    - debug_mode
  - Function
    - function_name
    - function_arg_count
    - function_is_builtin
    - function_type
    - function_list init_function_list
  - Execution profile
    - start_profile
    - stop_profile
    - function_percent
  - Others
    - load_file
    - error
    - showed_stack_size

Next: Function definition Up: Smac Previous: Smac