From d87d4ad3a6d2ec2804cb7b20128fecb6d9df4e6e Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Thu, 25 Jan 2018 00:30:24 +0000 Subject: Add simple conditional processing and file include Can now use C-style include declarations to include files within other sail files. This is done in such a way that all the location information is preserved in error messages. As an example: $include "aarch64/prelude.sail" $define SYM $ifndef SYM $include <../util.sail> $endif would include the file aarch64/prelude.sail relative to the file where the include is contained. It then defines a symbol SYM and includes another file if it is not defined. The <../util.sail> include will be accessed relative to $SAIL_DIR/lib, so $SAIL_DIR/lib/../util.sail in this case. This can be used with the standard C trick of $ifndef ONCE $define ONCE val f : unit -> unit $endif so no matter how many sail files include the above file, the valspec for f will only appear once. Currently we just have $include, $define, $ifdef and $ifndef (with $else and $endif). We're using $ rather than # because # is already used in internal identifiers, although this could be switched. --- src/parse_ast.ml | 1 + 1 file changed, 1 insertion(+) (limited to 'src/parse_ast.ml') diff --git a/src/parse_ast.ml b/src/parse_ast.ml index 362333f3..5eb8038a 100644 --- a/src/parse_ast.ml +++ b/src/parse_ast.ml @@ -507,6 +507,7 @@ def = (* Top-level definition *) | DEF_default of default_typing_spec (* default kind and type assumptions *) | DEF_scattered of scattered_def (* scattered definition *) | DEF_reg_dec of dec_spec (* register declaration *) + | DEF_pragma of string * string * l | DEF_internal_mutrec of fundef list -- cgit v1.2.3