Skip to content
Snippets Groups Projects
Commit 8dba025b authored by benjamin.franksen's avatar benjamin.franksen
Browse files

docs: document new features, fixed grammar productions

parent 1fa163c7
No related branches found
No related tags found
No related merge requests found
Compiling SNL Programs Compiling SNL Programs
====================== ======================
*snc*, the SNL to C Compiler :program:`snc`, the SNL to C Compiler
---------------------------- -------------------------------------
The SNL to C compiler *snc* compiles the state notation The SNL to C compiler :program:`snc` compiles the state notation
language into C code. The resulting file can then be compiled language into C code. The resulting file can then be compiled
with a C compiler. with a C compiler.
...@@ -17,40 +17,49 @@ SNC options start by a plus or minus sign, followed by a single ...@@ -17,40 +17,49 @@ SNC options start by a plus or minus sign, followed by a single
character. A plus sign turns the option on, and a minus turns the character. A plus sign turns the option on, and a minus turns the
option off. option off.
====== =============================================================== ============== ===============================================================
Option Description Option Description
====== =============================================================== ============== ===============================================================
+a Asynchronous ``pvGet``: the program continues without .. option:: +a Asynchronous ``pvGet``: the program continues without
waiting for completion of the ``pvGet`` operation. waiting for completion of the ``pvGet`` operation.
-a Synchronous ``pvGet``: the program waits for completion. .. option:: -a Synchronous ``pvGet``: the program waits for completion.
This is the default if an option is not specified. This is the default if an option is not specified.
+c Wait for process variables to connect before allowing the .. option:: +c Wait for process variables to connect before allowing the
program to begin execution. This is the default. program to begin execution. This is the default.
-c Allow the program to begin execution before connections .. option:: -c Allow the program to begin execution before connections
are established to all channel. are established to all channel.
+d Turn on run-time debug messages. .. option:: +d Turn on run-time debug messages.
-d Turn off run-time debug messages. This is the default. .. option:: -d Turn off run-time debug messages. This is the default.
+e Use the new event flag mode. This is the default. .. option:: +e Use the new event flag mode. This is the default.
-e Use the old event flag mode (clear flags after executing a .. option:: -e Use the old event flag mode (clear flags after executing a
when statement). when statement).
+i Generate registrar procedure that registers shell commands .. option:: +i Generate registrar procedure that registers shell commands
and programs with an IOC shell. This is the default. and programs with an IOC shell. This is the default.
-i Do not generate registrar procedure. .. option:: -i Do not generate registrar procedure.
+l Add line markers to the generated code, so that C compiler .. option:: +l Add line markers to the generated code, so that C compiler
messages refer to the SNL source file. This is the default. messages refer to the SNL source file. This is the default.
-l Do not produce line markers. .. option:: -l Do not produce line markers.
+m Include main procedure (seqMain.c) for a stand-alone program. .. option:: +m Include main procedure (seqMain.c) for a stand-alone program.
-m Do not include seqMain.c. This is the default. .. option:: -m Do not include seqMain.c. This is the default.
+s :ref:`Safe mode`: variables are local to state set .. option:: +s :ref:`Safe mode`: variables are local to state set
and must be communicated explicitly. Implies +r. and must be communicated explicitly. Implies +r.
-s Traditional (non-safe) mode. This is the default for .. option:: -s Traditional (non-safe) mode. This is the default for
compatibility. compatibility.
+r Make the generated code reentrant, thus allowing more than one .. option:: +r Make the generated code reentrant, thus allowing more than one
instance of the program to run on an IOC. instance of the program to run on an IOC.
-r Generated code is not reentrant. This is the default. .. option:: -r Generated code is not reentrant. This is the default.
+w Display SNC warning messages. This is the default. .. option:: +w Display warning messages. This is the default.
-w Suppress SNC warnings. .. option:: -w Suppress warnings.
====== =============================================================== ============== ===============================================================
.. versionadded:: 2.2
============== ===============================================================
Option Description
============== ===============================================================
.. option:: +W Display extra warnings for undefined objects.
.. option:: -W Suppress extra warnings. This is the default.
============== ===============================================================
Note that :option:`+a` and :option:`-a` are ignored for calls to Note that :option:`+a` and :option:`-a` are ignored for calls to
:c:func:`pvGet` that explicitly specify ``SYNC`` or ``ASYNC`` in the :c:func:`pvGet` that explicitly specify ``SYNC`` or ``ASYNC`` in the
...@@ -81,26 +90,26 @@ compiler option overrides. ...@@ -81,26 +90,26 @@ compiler option overrides.
Errors Errors
^^^^^^ ^^^^^^
If *snc* detects an error, it displays a message describing the error If :program:`snc` detects an error, it displays a message describing the error
and the location in the source file and aborts further compilation. and the location in the source file and aborts further compilation.
Note, however, that *snc* does *not* contain a type checker: all it Note, however, that :program:`snc` does *not* contain a type checker: all it
knows (and cares) about C is the syntax. This means that many errors knows (and cares) about C is the syntax. This means that many errors
will only be found only during the C compilation phase. The C compiler will only be found only during the C compilation phase. The C compiler
will attributed these to the corresponding location in the SNL source will attributed these to the corresponding location in the SNL source
file, since by default *snc* generates line markers in the output that file, since by default :program:`snc` generates line markers in the output that
point back to the original source. This can be turned off with the point back to the original source. This can be turned off with the
:option:`-l` ("ell") compiler switch. :option:`-l` ("ell") compiler switch.
Warnings Warnings
^^^^^^^^ ^^^^^^^^
In certain cases *snc* cannot ultimately decide whether the code is In certain cases :program:`snc` cannot ultimately decide whether the code is
erroneous. In such cases it will issue a warning message and continue. erroneous. In such cases it will issue a warning message and continue.
The most prominent example is the use of a variable or CPP macro that The most prominent example is the use of a variable or CPP macro that
has not been declared in the SNL code, but could well be defined when has not been declared in the SNL code, but could well be defined when
compiling the generated C code (for example if the declaration has been compiling the generated C code (for example if the declaration has been
in embedded C code, which *snc* does not interpret at all). Warnings in embedded C code, which :program:`snc` does not interpret at all). Warnings
can be suppressed with the :option:`-w` compiler option. can be suppressed with the :option:`-w` compiler option.
Note that since version 2.1 you can avoid these warnings by declaring Note that since version 2.1 you can avoid these warnings by declaring
...@@ -110,16 +119,17 @@ C Pre-processor ...@@ -110,16 +119,17 @@ C Pre-processor
--------------- ---------------
Depending on the application, it might be useful to pre-process the SNL Depending on the application, it might be useful to pre-process the SNL
source with a C pre-processor (*cpp*). Using the C pre-processor allows source with a C pre-processor (:program:`cpp`). Using the C
you to include other SNL files, define macros, and perform conditional pre-processor allows you to include other SNL files, define macros, and
compilation. *snc* supports this by interpreting *cpp*-generated line perform conditional compilation. :program:`snc` supports this by
markers, so that error and warning messages refer to the line numbers interpreting :program:`cpp`-generated line markers, so that error and
in the un-pre-processed SNL source. warning messages refer to the line numbers in the un-pre-processed SNL
source.
Complete Build Complete Build
-------------- --------------
The C code generated by *snc* from an SNL program is not a complete The C code generated by :program:`snc` from an SNL program is not a complete
program, but merely a collection of procedures, data types, and program, but merely a collection of procedures, data types, and
variables. The generated procedures are supposed to be called by the variables. The generated procedures are supposed to be called by the
sequencer library, which must be linked to the program. Furthermore, sequencer library, which must be linked to the program. Furthermore,
......
...@@ -342,7 +342,7 @@ program to your application, write something like :: ...@@ -342,7 +342,7 @@ program to your application, write something like ::
into your Makefile. Here, ``xyz.st`` is the name of your SNL program, and into your Makefile. Here, ``xyz.st`` is the name of your SNL program, and
``abc`` is the name of the library or binary to produce. Note that ``.st`` ``abc`` is the name of the library or binary to produce. Note that ``.st``
files are run through the C preprocessor (*cpp*) before giving them to files are run through the C preprocessor (:program:`cpp`) before giving them to
the SNL compiler. Use the extension ``.stt`` to avoid this. For details, the SNL compiler. Use the extension ``.stt`` to avoid this. For details,
see Chapter 4 of the `EPICS Application Developer's Guide`_. see Chapter 4 of the `EPICS Application Developer's Guide`_.
......
...@@ -45,7 +45,7 @@ of its syntax and semantics are directly inherited from C. The language is ...@@ -45,7 +45,7 @@ of its syntax and semantics are directly inherited from C. The language is
designed for seamless integration with C code; for instance, you can designed for seamless integration with C code; for instance, you can
directly call C procedures in SNL action blocks and state transition directly call C procedures in SNL action blocks and state transition
conditions, and the types of variables you can declare in SNL map directly conditions, and the types of variables you can declare in SNL map directly
to C types. The compiler for SNL (called *snc*, see :doc:`Compiling`) takes to C types. The compiler for SNL (called :program:`snc`, see :doc:`Compiling`) takes
a very minimalistic approach to compilation by generating portable standard a very minimalistic approach to compilation by generating portable standard
C89/90 code that works on all platforms supported by EPICS. In fact, most of C89/90 code that works on all platforms supported by EPICS. In fact, most of
the SNL action code is compiled almost verbatim to C, and the generated code the SNL action code is compiled almost verbatim to C, and the generated code
......
...@@ -100,7 +100,7 @@ any) at the given line. ...@@ -100,7 +100,7 @@ any) at the given line.
:token:`file_name` must be a single string (no automatic string :token:`file_name` must be a single string (no automatic string
concatenation). concatenation).
Line markers are typically generated by preprocessors, such as *cpp*. Line markers are typically generated by preprocessors, such as :program:`cpp`.
Program Program
------- -------
...@@ -212,35 +212,38 @@ Variable Declarations ...@@ -212,35 +212,38 @@ Variable Declarations
init_declarators: `init_declarators` "," `init_declarator` init_declarators: `init_declarators` "," `init_declarator`
init_declarator: `declarator` init_declarator: `declarator`
init_declarator: `declarator` "=" `init_expr` init_declarator: `declarator` "=" `init_expr`
declarator: `variable`
declarator: "(" `declarator` ")"
declarator: `declarator` `subscript`
declarator: `declarator` "(" `param_decls` ")"
declarator: "*" `declarator` declarator: "*" `declarator`
declarator: `direct_declarator` variable: `identifier`
direct_declarator: `variable`
direct_declarator: "(" `declarator` ")"
direct_declarator: `direct_declarator` `subscript`
init_expr: "(" `type_expr` ")" "{" `init_exprs` "}"
init_expr: "{" `init_exprs` "}" init_expr: "{" `init_exprs` "}"
init_expr: "(" `type_expr` ")" "{" `init_exprs` "}"
init_expr: `expr` init_expr: `expr`
init_exprs: `init_exprs` "," `init_expr` init_exprs: `init_exprs` "," `init_expr`
init_exprs: `init_expr` init_exprs: `init_expr`
init_exprs: init_exprs:
variable: `identifier`
Variable declarations are quite similar to C.
.. versionadded:: 2.1 .. versionadded:: 2.1
You can declare more than one variable in a single declaration (comma You can declare more than one variable in a single declaration (comma
separated) and add pointer and array markers (subscripts) ad libitum as well separated) and add pointer and array markers (subscripts) ad libitum as
as initializers. well as initializers.
The remain some limitations: .. versionadded:: 2.2
Function declarations and initializers with type casts.
* arrays must have a defined size (i.e. the integer in the The still remain some limitations:
subscript brackets is not optional as in C)
* arrays must have a defined size: the expression inside the subscript
brackets is not optional as in C; it must also be an integer literal,
not a constant expression as in C.
* you cannot declare new types or type synonyms * you cannot declare new types or type synonyms
* you cannot declare functions * no type qualifiers ("const", "volatile")
* no qualifiers ("static", "extern", "const" etc.) * no storage specifiers ("static", "extern", "auto", register")
* only certain types are allowed, see below * only certain base types are allowed, see below
Some of these restrictions may be lifted in future versions. Some of these restrictions may be lifted in future versions.
...@@ -250,24 +253,37 @@ Some of these restrictions may be lifted in future versions. ...@@ -250,24 +253,37 @@ Some of these restrictions may be lifted in future versions.
Foreign Declarations Foreign Declarations
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
.. warning::
Foreign declarations are now deprecated. They might be removed in future
versions.
.. productionlist:: .. productionlist::
declaration: "foreign" `declarators` ";" declaration: "foreign" `variables` ";"
declarators: `declarator` variables: `variable`
declarators: `declarators` "," `declarator` variables: `variables` "," `variable`
.. versionadded:: 2.1 .. versionadded:: 2.1
Foreign declarations are used let the SNL compiler know about the existence Foreign declarations are used to let the SNL compiler know about the
of C variables or C preprocessor macros (without arguments) that have been existence of C variables or C preprocessor macros (without arguments)
defined outside the SNL program or in escaped C code. No warning will be that have been defined outside the SNL program or in escaped C code. No
issued if such a variable or macro is used in the program even if warnings warning will be issued if such a variable or macro is used in the
are enabled. program even if warnings are enabled.
.. versionadded:: 2.2 .. versionadded:: 2.2
It is no longer needed to declare struct or union members as foreign It is no longer needed to declare struct or union members as foreign
entities, since the parser no longer confuses them with variables. See entities, since the parser no longer confuses them with variables. See
section `Primary Expression Operators`_ below. section `Postfix Operators`_ below.
Also, warnings for undefined entities are now disabled by default. You
can use the "extra warnings" option :option:`+W` to enable them. In
contrast to older versions, this will also warn about foreign functions
when called from SNL code. Note that enabling extra warnings is normally
not needed: if a variable or function is actually undefined in the
generated C code, the C compiler will issue a warning (or an error)
anyway.
.. _Types: .. _Types:
...@@ -342,25 +358,31 @@ not yet support 64 bit integers. ...@@ -342,25 +358,31 @@ not yet support 64 bit integers.
Type Expressions Type Expressions
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
.. versionadded:: 2.2
.. productionlist:: .. productionlist::
type_expr: `basetype` `opt_abstract_declarator` type_expr: `basetype`
opt_abstract_declarator: type_expr: `basetype` `abs_decl`
opt_abstract_declarator: `abstract_declarator` abs_decl: "*"
abstract_declarator: "*" abs_decl: "(" `abs_decl` ")"
abstract_declarator: "*" `direct_abstract_declarator` abs_decl: "*" `abs_decl`
abstract_declarator: `direct_abstract_declarator` abs_decl: `abs_decl` "(" `param_decls` ")"
direct_abstract_declarator: "(" `abstract_declarator` ")" abs_decl: `abs_decl` `subscript`
direct_abstract_declarator: `direct_abstract_declarator` `subscript` abs_decl: "(" `param_decls` ")"
direct_abstract_declarator: `subscript` abs_decl: `subscript`
param_decls: `param_decl`
Type expressions closely follow declaration syntax just as in C. They are param_decls: `param_decls` "," `param_decl`
used for type casts (`Unary Prefix Operators`_) and the special sizeof param_decl: `basetype` `declarator`
operator (`Primary Expression Operators`_). param_decl: `type_expr`
Type expressions closely follow declaration syntax just as in C. They
are used for parameter declarations as well as type casts and the
special sizeof operator (see `Prefix Operators`_).
Strings Strings
~~~~~~~ ~~~~~~~
The type :token:`string` is defined in C as:: The type ``string`` is defined in C as::
typedef char string[MAX_STRING_SIZE]; typedef char string[MAX_STRING_SIZE];
...@@ -373,7 +395,7 @@ recommend not to rely too much on the numeric value. (You can use ...@@ -373,7 +395,7 @@ recommend not to rely too much on the numeric value. (You can use
.. note:: .. note::
In contrast to C, in SNL ``string s`` is *not* a synonym for In contrast to C, in SNL ``string s`` is *not* a synonym for
``char s[MAX_STRING_SIZE]``, since variables of type :token:`string` ``char s[MAX_STRING_SIZE]``, since variables of type ``string``
are treated differently when it comes to interacting with PVs: the are treated differently when it comes to interacting with PVs: the
former gets requested with type DBR_STRING and a count of one, while former gets requested with type DBR_STRING and a count of one, while
the latter gets requested with type DBR_CHAR and a count of the latter gets requested with type DBR_CHAR and a count of
...@@ -905,7 +927,7 @@ Statements ...@@ -905,7 +927,7 @@ Statements
statement: "continue" ";" statement: "continue" ";"
statement: "state" `identifier` ";" statement: "state" `identifier` ";"
statement: `c_code` statement: `c_code`
statement: "{" `block_defns` `statements` "}" statement: `block`
statement: "if" "(" `comma_expr` ")" `statement` statement: "if" "(" `comma_expr` ")" `statement`
statement: "if" "(" `comma_expr` ")" `statement` "else" `statement` statement: "if" "(" `comma_expr` ")" `statement` "else" `statement`
statement: "while" "(" `comma_expr` ")" `statement` statement: "while" "(" `comma_expr` ")" `statement`
...@@ -927,10 +949,11 @@ Expressions ...@@ -927,10 +949,11 @@ Expressions
^^^^^^^^^^^ ^^^^^^^^^^^
Formation rules for expressions are listed in groups of descending order Formation rules for expressions are listed in groups of descending order
of precedence. of precedence. Precedence is determined by the standard C operator
precedence table.
Atomic Expression Primary Expressions
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
.. productionlist:: .. productionlist::
expr: `integer_literal` expr: `integer_literal`
...@@ -938,23 +961,16 @@ Atomic Expression ...@@ -938,23 +961,16 @@ Atomic Expression
expr: `string` expr: `string`
expr: `variable` expr: `variable`
string: `string_literal` string: `string_literal`
These are literals and variables.
Parenthesized Expression
~~~~~~~~~~~~~~~~~~~~~~~~
.. productionlist::
expr: "(" `comma_expr` ")" expr: "(" `comma_expr` ")"
Primary Expression Operators These are literals, variables, and parenthesized expressions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Postfix Operators
~~~~~~~~~~~~~~~~~
.. productionlist:: .. productionlist::
expr: `identifier` "(" `args` ")" expr: `expr` "(" `args` ")"
expr: "exit" "(" `args` ")" expr: "exit" "(" `args` ")"
expr: "sizeof" "(" `expr` ")"
expr: "sizeof" "(" `type_expr` ")"
expr: `expr` "[" `expr` "]" expr: `expr` "[" `expr` "]"
expr: `expr` "." `member` expr: `expr` "." `member`
expr: `expr` "->" `member` expr: `expr` "->" `member`
...@@ -962,24 +978,21 @@ Primary Expression Operators ...@@ -962,24 +978,21 @@ Primary Expression Operators
expr: `expr` "--" expr: `expr` "--"
member: `identifier` member: `identifier`
These are: function call, array subscript, record selection, pointer to These are all left associative.
record selection, and postfix operators (increment and decrement).
.. note:: .. note::
:token:`exit` is listed explicitly because it is a keyword, not an ``exit`` must be listed explicitly because in SNL it is a keyword,
identifier, but can also be used as a function. not an identifier. The extra rule allows calls to the standard
library function ``exit``.
.. note:: .. versionadded:: 2.2
SNL makes no use of the semantics of structure member access and .. productionlist::
struct tags are treated as if they were expressions (variables, in expr: "sizeof" "(" `type_expr` ")"
fact). A side-effect is that *snc* will warn that structure tags are
"used but not declared", which can be silenced with a :ref:`foreign
entities` declaration, just as with variables.
Unary Prefix Operators Prefix Operators
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
.. productionlist:: .. productionlist::
expr: "+" `expr` expr: "+" `expr`
...@@ -991,44 +1004,69 @@ Unary Prefix Operators ...@@ -991,44 +1004,69 @@ Unary Prefix Operators
expr: "++" `expr` expr: "++" `expr`
expr: "--" `expr` expr: "--" `expr`
Prefix operators are right-associative.
.. versionadded:: 2.2 .. versionadded:: 2.2
Type casts: Type casts and sizeof operator:
.. productionlist:: .. productionlist::
expr: "(" `type_expr` ")" `expr` expr: "(" `type_expr` ")" `expr`
expr: "sizeof" `expr`
Left-associative Binary Operators Binary Operators
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
.. productionlist:: .. productionlist::
expr: `expr` "-" `expr` expr: `expr` "-" `expr`
expr: `expr` "+" `expr` expr: `expr` "+" `expr`
.. productionlist::
expr: `expr` "<<" `expr`
expr: `expr` ">>" `expr`
.. productionlist::
expr: `expr` "*" `expr` expr: `expr` "*" `expr`
expr: `expr` "/" `expr` expr: `expr` "/" `expr`
.. productionlist::
expr: `expr` ">" `expr` expr: `expr` ">" `expr`
expr: `expr` ">=" `expr` expr: `expr` ">=" `expr`
expr: `expr` "==" `expr`
expr: `expr` "!=" `expr`
expr: `expr` "<=" `expr` expr: `expr` "<=" `expr`
expr: `expr` "<" `expr` expr: `expr` "<" `expr`
.. productionlist::
expr: `expr` "==" `expr`
expr: `expr` "!=" `expr`
.. productionlist::
expr: `expr` "&" `expr`
.. productionlist::
expr: `expr` "^" `expr`
.. productionlist::
expr: `expr` "|" `expr`
.. productionlist::
expr: `expr` "||" `expr` expr: `expr` "||" `expr`
.. productionlist::
expr: `expr` "&&" `expr` expr: `expr` "&&" `expr`
expr: `expr` "<<" `expr`
expr: `expr` ">>" `expr` .. productionlist::
expr: `expr` "|" `expr`
expr: `expr` "^" `expr`
expr: `expr` "&" `expr`
expr: `expr` "%" `expr` expr: `expr` "%" `expr`
All binary operators associate to the left.
.. note:: .. note::
Like in most programming languages, evaluation of conditional Like in most programming languages, including C, evaluation of
expressions using ``&&`` and ``||`` is done *lazily*: the second operand conditional expressions using ``&&`` and ``||`` is done *lazily*: the
is not evaluated if evaluation of the first already determines the second operand is not evaluated if evaluation of the first already
result. This particularly applies to the boolean expressions in determines the result. This particularly applies to the boolean
:token:`transition` clauses. See the built-in function :c:func:`pvGetQ` expressions in :token:`transition` clauses. See the built-in function
for an extended discussion. :c:func:`pvGetQ` for an extended discussion.
Ternary Operator Ternary Operator
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
...@@ -1164,9 +1202,9 @@ compType ...@@ -1164,9 +1202,9 @@ compType
.. note:: .. note::
Only ``SYNC`` and ``ASYNC`` are SNL built-in constants (i.e. Only ``SYNC`` and ``ASYNC`` are SNL built-in constants (i.e. known to
known to *snc*). The constant ``DEFAULT`` is for use in C code :program:`snc`). The constant ``DEFAULT`` is for use in C code (to
(to represent a missing optional argument). represent a missing optional argument).
seqBool seqBool
...@@ -1211,10 +1249,10 @@ statically checked by the compiler. ...@@ -1211,10 +1249,10 @@ statically checked by the compiler.
Several of these functions are intended to be called only from Several of these functions are intended to be called only from
:token:`transition` clauses or only from action code. It is safe to call :token:`transition` clauses or only from action code. It is safe to call
them in another context, but the effect is probably not what you want. For them in another context, but the effect is probably not what you want.
instance, calling :c:func:`delay` in action code does *not* introduce a For instance, calling :c:func:`delay` in action code does *not*
delay at this point. Later versions of *snc* may output a warning or even introduce a delay at this point. Later versions of :program:`snc` may
stop with an error. output a warning or even stop with an error.
.. todo:: What about changing this so that :c:func:`delay` in action code .. todo:: What about changing this so that :c:func:`delay` in action code
*does* introduce a delay? In other words, compile 'delay(<expr>)' to *does* introduce a delay? In other words, compile 'delay(<expr>)' to
...@@ -2208,9 +2246,9 @@ by adding a line :: ...@@ -2208,9 +2246,9 @@ by adding a line ::
This uses the one-line-escape syntax explained in the next section. This uses the one-line-escape syntax explained in the next section.
For historical reasons, *snc* complains with a warning if you use a For historical reasons, :program:`snc` complains with a warning if you
foreign variable or preprocessor macro in SNL code (but not for foreign use a foreign variable or preprocessor macro in SNL code (but not for
function calls). This can be suppressed by adding a foreign foreign function calls). This can be suppressed by adding a foreign
declaration (see `Foreign Entities`_). declaration (see `Foreign Entities`_).
...@@ -2218,9 +2256,9 @@ Escape to C Code ...@@ -2218,9 +2256,9 @@ Escape to C Code
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
Because the SNL does not support the full C language, C code may be Because the SNL does not support the full C language, C code may be
escaped in the program. The escaped code is not compiled by *snc*, escaped in the program. The escaped code is not compiled by
instead it is literally copied to the generated C code. There are two :program:`snc`, instead it is literally copied to the generated C code.
escape methods: There are two escape methods:
#. Any code between ``%%`` and the next newline character is escaped. #. Any code between ``%%`` and the next newline character is escaped.
Example:: Example::
...@@ -2265,10 +2303,10 @@ here. For instance, ...@@ -2265,10 +2303,10 @@ here. For instance,
if the header contains macro definitions, these will not be in effect if the header contains macro definitions, these will not be in effect
when the rest of the C code block gets compiled. when the rest of the C code block gets compiled.
You can defer interpretation of a preprocessor directive until You can defer interpretation of a preprocessor directive until after
after *snc* has compiled the code to C, by ensuring that some extra :program:`snc` has compiled the code to C, by ensuring that some extra
non-blank characters appear in front of the ``#`` sign, so *cpp* does non-blank characters appear in front of the ``#`` sign, so
not recognize the directive. For instance :: :program:`cpp` does not recognize the directive. For instance ::
%%#include <abcLib.h> %%#include <abcLib.h>
...@@ -2340,8 +2378,8 @@ file is always included by the generated C code. ...@@ -2340,8 +2378,8 @@ file is always included by the generated C code.
Variable Modification for Reentrant Option Variable Modification for Reentrant Option
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If the reentrant option (:option:`+r`) is specified to *snc* then all If the reentrant option (:option:`+r`) is specified to :program:`snc`
variables are made part of a structure. Suppose we have the then all variables are made part of a structure. Suppose we have the
following top-level declarations in the SNL program:: following top-level declarations in the SNL program::
int sw1; int sw1;
...@@ -2366,7 +2404,7 @@ Reference to variable ``sw1`` is made as :: ...@@ -2366,7 +2404,7 @@ Reference to variable ``sw1`` is made as ::
pVar->sw1 pVar->sw1
This conversion is automatically performed by *snc* for all SNL This conversion is automatically performed by :program:`snc` for all SNL
statements, but you will have to handle escaped C code yourself. statements, but you will have to handle escaped C code yourself.
.. note:: .. note::
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment