BARfly Help - Working with BAR I.F.s - The compilation process

  The compilation process

This page describes content of the BARfly Gold build.

The I.F. compilation process is divided into six passes.  None of the passes require user intervention, but it helps to understand them when it comes to reporting compilation errors and warnings.

If errors occur in one pass, no further passes are performed; compilation stops after one pass.

First Pass:  Tokenizing

Preprocessor directives (beginning with a number symbol '#'), keywords, identifiers, operators, punctuators, numbers, strings, whitespace, and remarks are processed and "tokenized."  A BAR implementation file equates each "token" with a unique identifier, which is a long integer starting at 1 and counting up.

A token is composed of one or more characters.  A single keyword counts as one token, as does a single identifierOperators and punctuators are composed of one or more non-alphanumeric symbols; each operator or punctuator counts as one token.  Each number or string also counts as one token.

Whitespace, preprocessor directives, and remarks are NOT counted as tokens.  After the first pass, these components disappear from consideration.

Second Pass:  File Scope Interpretation

The token stream generated from the first pass is processed next.  File scope declarations are handled, including enumerated constant declarations, structure declarations, block declarations, list declarations, global variable declarations, and global function declarations.

All constructs in the file are acknowledged in this pass.

Structure definitions, block declarations, and global function body definitions are not fully handled in this pass; they are completed in future passes.

Third Pass:  Structure Scope Interpretation

Individual structure definitions are processed next.  All structure variables and member functions of structures are acknowledged in this pass.

Fourth Pass:  Block Scope Interpretation

Individual block definitions are processed next.  All member functions of blocks are acknowledged in this pass.

Fifth Pass:  Construct and Function Declaration Finalization

All function parameter lists are acknowledged in this pass.  The pass also contains handles variable initial value processing and internal consistency checks.

The following internal consistency checks are performed:

  • Critical-step functions are identified.  If critical-step functions do not match required return type or parameter format, errors are generated.
  • Structures containing pointers are identified.  Structures containing pointers are not allowed to have member functions.  If they do, errors are generated.
  • Fragmentation issues are identified.  The "nofragment" attribute is only permitted for constructs that do not make use of Deserialize or OffsetTweak critical steps, either directly or through the use of children.  If a conflict is found, errors are generated.
  • Discardability issues are identified.  The "discardable" attribute is only allowed to exist once within a particular branch of the construct hierarchy diagram.  There cannot be any possibility of pause points existing at a higher level and a lower level at the same time.  If a conflict is found, errors are generated.
  • Structures containing pointers are screened out of the construct hierarchy.  If structures containing pointers are permitted within the deserialization hierarchy, errors are generated.

Sixth Pass:  Function Body Interpretation

The contents of individual function bodies are compiled last, including local variables and function statements.

Final Action:  Writing to file

After successfully compiling an I.F., the compiler must write the data, in binary or mixed form, to a disk file.  This operation always succeeds unless there is a disk error.

Click here to learn more about implementation file syntax.

Click here for information about critical step implementation.


  See also: [Three forms:  text, binary, mixed] [Editing BAR I.F.s using BARfly's integrated text editor] [BAR implementation file reference]


BARfly Help Copyright © 2009 Christopher Allen