mirror of
https://github.com/nasa/fpp.git
synced 2026-04-12 05:01:36 -05:00
82 lines
1.5 KiB
Plaintext
82 lines
1.5 KiB
Plaintext
=== Include Specifiers
|
|
|
|
An *include specifier* specifies that a file
|
|
should be included in a
|
|
<<Translation-Units-and-Models_Translation-Units,translation unit>>.
|
|
|
|
==== Syntax
|
|
|
|
`include` <<Expressions_String-Literals,_string-literal_>>
|
|
|
|
==== Semantics
|
|
|
|
The string literal specifies a file path relative to the
|
|
<<Translation-Units-and-Models_Locations,
|
|
location>> of the include specifier.
|
|
|
|
During parsing, the translator does the following:
|
|
|
|
. Resolve the path to an absolute file name that refers to a file _F_.
|
|
|
|
. Parse _F_, recursively resolving any include specifiers that appear in _F_.
|
|
|
|
. Include its parsed elements as if they appeared
|
|
in the enclosing translation unit at the point where the include
|
|
specifier appears.
|
|
|
|
The suffix `.fppi` is conventional for included files, to distinguish them
|
|
from files presented directly for analysis or translation.
|
|
|
|
==== Examples
|
|
|
|
*Example 1.*
|
|
|
|
File `a.fppi` contains the following:
|
|
|
|
[source,fpp]
|
|
----
|
|
constant a = 1
|
|
----
|
|
|
|
File `b.fpp` contains the following:
|
|
|
|
[source,fpp]
|
|
----
|
|
include "a.fppi"
|
|
constant b = a
|
|
----
|
|
|
|
File `b.fpp` is translated identically to this translation unit:
|
|
|
|
[source,fpp]
|
|
----
|
|
constant a = 1
|
|
constant b = a
|
|
----
|
|
|
|
*Example 2.*
|
|
|
|
File `a.fppi` contains the following:
|
|
|
|
[source,fpp]
|
|
----
|
|
constant a = 1
|
|
----
|
|
|
|
File `b.fpp` contains the following:
|
|
|
|
[source,fpp]
|
|
----
|
|
module M { include "a.fppi" }
|
|
b = M.a
|
|
----
|
|
|
|
File `b.fpp` is translated identically to this translation unit:
|
|
|
|
[source,fpp]
|
|
----
|
|
module M { constant a = 1 }
|
|
b = M.a
|
|
----
|
|
|