General Part of Anglr File


Introduction

The general part has no content. It contains only attributes that help us define general things.

Syntax

Syntax of general part is defined as follows:


RULE G-1

<general part>
    : <attribute list> ? '%general' <identifier> '%{' <attribute list> ? '%}'
    ;
                    

Structure of general part is composed in that way:

  • general part is preceeded by possibly empty attribute list
  • next follows reserverd word %general
  • followed by <identifier> which represents the name of general part
  • between part separators %{ and %} is another attribute list which should also be empty

Attributes

Anglr compiler recognizes only one attribute which should be present in general part of Anglr file. Its name is CompilationInfo and contains default value of namespace for generated source code and default directory for generated source code:

Attribute Value Name Value Description
CompilationInfo NameSpace namespace name defult namespce for generated source code if it is not defined by particular part of anglr file. If Namespace value is not defined, default namespace value is equal to Anglr file name.
CodeDir directory path default name of source code directory if it is not defined by particular part of anglr file. If CodeDir value is not defined, default name of directory for generated source code is equal to current working directory. Current working directory can be explicitely specified by giving CodeDir value of '.'

Example

Example below represents general part of Anglr file for Anglr compiler itself:

[ Description Text='General settings' Hover='true' ]
[ CompilationInfo NameSpace='Anglr' CodeDir='.' Hover='true' ]
%general anglrSettings
%{
%}
                    

From this example we can see the following:

  • default namespace for generated code is Anglr, which can be seen from the NameSpace value of attribute CompilationInfo
  • default source code directory for generated code is equal to the current working directory which can be seen from the CodeDir value of attribute CompilationInfo