:orphan: .. **************************************************************************** .. CUI .. .. The Advanced Framework for Simulation, Integration, and Modeling (AFSIM) .. .. The use, dissemination or disclosure of data in this file is subject to .. limitation or restriction. See accompanying README and LICENSE for details. .. **************************************************************************** WSF Grammar Format ------------------ Overview ======== The WSF grammar format defines the syntax of WSF commands. The grammar is used in the WSF IDE for parsing WSF files. Grammar files already exist for many WSF modules and can be found in .ag files in 'grammar' subdirectories of SVN project directories. :: WSF/grammar/WSF_core.ag WSF_nx/grammar/WSF_nx.ag ... It is the developer's responsibility when adding new types and commands to maintain the grammar files so that tools like the IDE can correctly process WSF files. Grammar File Definition ======================= The grammar file has two main features: **Rules** to parse the WSF input and **Actions** to create data representing the input file. Rules ***** Sequences ^^^^^^^^^ The most basic rule is a sequence. Sequences are indicated by the '{' '}' symbols. Sequences define a list of sub-rules which each must be matched in succession. :: { *rule0 rule1* ... } Within a sequence, rules are counted starting at 0. Later, rules may be referenced using the '$0' notation. Literals ^^^^^^^^ Literals match a single specific string of characters. Literals can either be quoted strings or plain text. :: end_time "end_time" Rule References ^^^^^^^^^^^^^^^ Rules may be referenced after they are defined using the '' format. :: Recurrences ^^^^^^^^^^^ Recurrences are rule references that recur 0 to many or 0 to 1 times. The '*' character is used to denote a zero to many recurrence. '+' for 1 to many. '?' for 0 to 1. :: { string_list * end_string_list | A B C D {E F G}? } Built-in Rules ^^^^^^^^^^^^^^ Matches a whitespace delimited character string :: MY_PLATFORM Matches either a whitespace delimited string or a quoted string :: MY_PLATFORM "C:\Program Files\MyPath" Matches any string with a list of exceptions :: # match any string except invalid_word1 and invalid_word2 (string-except invalid_word1 invalid_word2) Matches an integer :: -123 Matches a real number :: -2 -2.0 -2.0e-7 (error {}) Defines a sequence which when matched triggers an error :: #This matches any string. If it is an integer, an error will be logged. { (error { }) | } (delimited ...) Defines a non-space delimited word. All rules are matched assuming whitespace delimited inputs. This provides a way to bypass this limitation. Each argument is matched without spaces. There are some limitations using this rule, most notably, every other argument must be a literal. :: # this will match latitude values like 10.5n and 60s { (delimited n) | (delimited s) } (new *storage-address* *load-address* [:option...]) Defines a rule which attempts to create a new symbol. The symbol at *load-address* is copied into *storage-address*. The addresses must be either (subtype ...) or (type ...). (new_replace ...) Same as (new ...), but will replace any existing symbol. (load *load-address*) Loads an existing symbol from the symbol table. (delete *address*) Deletes an existing symbol. :: # Make a new sub-symbol on the current symbol named 'mover', loaded from 'moverType.WSF_AIR_MOVER' (new (subtype mover) (type moverType WSF_AIR_MOVER)) If there exists no symbol at load-address, the rule normally fails to match. However, if the :backup option is present, another load-address may be attempted. This allows an the WSF parser to partially process types that are unknown. :: # Try to load a user-defined mover. If the user-defined type isn't found, make a WSF_AIR_MOVER. (Logs an error) (new (subtype mover) (type moverType $1) :backup (type moverType WSF_AIR_MOVER)) # Load 'mover' as the new current symbol (load (subtype mover) Named Rules ^^^^^^^^^^^ A new named rule is created using this syntax:: (rule *rule-name* { *rules* }) Examples:: # Define a new rule (rule my-rule { end_time