Chapter 6. Parse Directives

Qore supports the use of parse directives in order to set parsing options, load modules, control warnings, and include other files. Parse directives that set parsing options can be used any time parse options have not been locked on a Program object. They are used most often when it's not possible or desirable to set the parse options in the qore command-line.

Table 6.1. Parse Directives

Directive

Description

%disable-all-warnings

Turns off all warnings

%disable-warning warning-code

Disables the named warning until %enable-warning is encountered with the same code or %enable-all-warnings is encountered

%enable-all-warnings

Turns on all warnings

%enable-warning warning-code

Enables the named warning.

%exec-class class name

Instantiates the named class as the application class. Also turns on %no-top-level. If the program is read from stdin or from the command-line, an argument must be given specifying the class name.

%include file_name

Starts parsing file_name immediately. Parsing resumes with the current input after file_name has been completely parsed.

%lock-options

Prohibits further changes to parse options (equivalent to the --lock-options command-line option).

%lock-warnings

Prohibits further changes to the warning mask (equivalent to the --lock-warnings command-line option).

%no-class-defs

Disallows class definitions. Equivalent to PO_NO_CLASS_DEFS and the --no-class-defs command-line option.

%no-child-restrictions

Allows child program objects to have parse option restrictions that are not a strict subset of the parents'. Equivalent to parse option PO_NO_CHILD_PO_RESTRICTIONS and the --no-child-restrictions command-line option.

%no-constant-defs

Disallows constant definitions. Equivalent to parse option PO_NO_CONSTANT_DEFS and the --no-constant-defs command-line option.

%no-database

Disallows access to database functionality (for example the Datasource class. Equivalent to parse option PO_NO_DATABASE and the --no-database command-line option.

%no-external-info

Disallows any access to functionality that provides external information (see %no-external-info for a list of features not available with this parse option). Equivalent to parse option PO_NO_EXTERNAL_INFO and the --no-external-info command-line option.

%no-external-process

Disallows any access to external processes (see %no-external-process for a list of features not available with this parse option). Equivalent to parse option PO_NO_EXTERNAL_PROCESS and the --no-external-process command-line option.

%no-filesystem

Disallows access to the local filesystem. Equivalent to parse option PO_NO_FILESYSTEM and the --no-filesystem command-line option.

%no-global-vars

Disallows the use of global variables. Equivalent to parse option PO_NO_GLOBAL_VARS and the --no-global-vars command-line option.

%no-gui

Disallows functionality that draws graphics to the display. Equivalent to parse option PO_NO_GUI and the -pno-gui command-line option.

%no-locale-control

Disallows access to functionality that changes locale information (see %no-locale-control for a list of features not available with this parse option). Equivalent to parse option PO_NO_LOCALE_CONTROL and the --no-locale-control command-line option.

%no-namespace-defs

Disallows new namespace definitions. Equivalent to PO_NO_NAMESPACE_DEFS and the --no-namespace-defs command-line option.

%no-network

Disallows access to the network. Equivalent to parse option PO_NO_NETWORK and the --no-network command-line option.

%no-new

Disallows use of the new operator. Equivalent to parse option PO_NO_NEW and the --no-new command-line option.

%no-process-control

Disallows access to functions that would affect the current process (see %no-process-control for a list of features not available with this parse option). Equivalent to parse option PO_NO_PROCESS_CONTROL and the --no-process-control command-line option.

%no-subroutine-defs

Disallows subroutine (function) definitions. Equivalent to parse option PO_NO_SUBROUTINE_DEFS and the --no-subroutine-defs command-line option.

%no-terminal-io

Disallows access to terminal I/O (see %no-terminal-io for a list of features not available with this parse option). Equivalent to parse option PO_NO_TERMINAL_IO and the -pno-terminal-io command-line option.

%no-thread-classes

Disallows access to thread classes (see %no-thread-classes for a list of features not available with this parse option). Equivalent to parse option PO_NO_THREAD_CLASSES and the --no-thread-classes command-line option.

%no-thread-control

Disallows access to thread control operations (see %no-thread-control for a list of features not available with this parse option). Equivalent to parse option PO_NO_THREAD_CONTROL and the --no-thread-control command-line option.

%no-thread-info

Disallows any access to functionality that provides threading information (see %no-thread-info for a list of features not available with this parse option). Equivalent to parse option PO_NO_THREAD_INFO and the --no-thread-info command-line option.

%no-threads

Disallows access to all thread control operations and thread classes (equivalent to --no-thread-control and --no-thread-classes together). Equivalent to parse option PO_NO_THREADS and the --no-threads command-line option.

%no-top-level

Disallows top level code. Equivalent to parse option PO_NO_TOP_LEVEL_STATEMENTS and the --no-top-level command-line option.

%require-our

Requires global variables to be declared with our prior to use (like perl's use strict vars pragma). Equivalent to parse option PO_REQUIRE_OUR and the --require-our command-line option.

%require-prototypes

Requires type declarations for all function and method parameters and return types. Variables and object members do not need to have type declarations. Equivalent to parse option PO_REQUIRE_PROTOTYPES and the --require-prototypes command-line option.

%require-types

Requires type declarations for all function and method parameters, return types, variables, and object members. Equivalent to parse option PO_REQUIRE_TYPES and the --require-types command-line option. Implies also %strict-args.

%requires feature [<|<=|=|>=|> <version>]

If the named feature is not already present in Qore, then the QORE_MODULE_DIR environment variable is used to provide a list of directories to seach for a module with the same name (feature.qmod). If the module is not found, then the qore default module directory is checked. This directive must be used to load modules providing parse support (i.e. modules providing classes, constants, functions, etc that are resolved at parse time). If version information is provided, then it is compared with the module's version information, and if it does not match a parse exception is raised. See also load_module() for a run-time module loading.

%strict-args

Prohibits access to builtin functions and methods flagged with RT_NOOP and also causes errors to be raised if excess arguments are given to functions that do not access excess arguments.


6.1. disable-all-warnings

Parse Directive

%disable-all-warnings

Command-Line

none, warnings are disabled by default

Parse Option Constant

n/a

Description

Disables all warnings while parsing. See Warnings for more information.