Parsers

A parser is an Editor command that acts interactively on a file to improve the presentation of the data in the file. A parser uses indentation, colors, and fonts to highlight different items in a programming language file. For example, language keywords are highlighted in one color, variable names in another, and string literals in yet another. Indentation is used to highlight program logic structure.

The Source view or the Editor window displays a file according to instructions given by the parser and associated load macros. You can add your own instructions to:

 

Creating a New Parser

To create a parser, you need programming skills, preferably in C. You also need to be familiar with creating external commands. You also need to understand the concepts of lines, fonts, and classes.

A parser is an external command that can be executed from the command line or from within macros. Commands for parsers are added to the Source view or the Editor window by writing Editor extensions using the Applications Programming Interface (API). Because parsers are called quite often, and may have to perform a lot of processing, they are usually written in the C language.

 

Setting Up Live Parsing

Live parsing means that the parser monitors and records all changes made to the file as you make them. New data is colored as you add it.

 

Deciding on a Load Macro

A parser normally works with one particular type of file, such as C or COBOL. The file type is indicated by the file-name extension. Each time a file with a specific file-name extension is loaded, a load macro is called to set up the instructions for the parser. Typically, the load macro does the following:

You can use the load macros supplied with the Source view or the Editor window as examples when developing your own load macros.



Changing Token Display Attributes