[NEXT] [PREV]    HANDBOOK / GETTING STARTED /

Generating a Compiler

Gentle
Applications
Concepts
Examples
Handbook
Support
Download

To generate a compiler from a Gentle specification the Gentle compiler has to be invoked for each Gentle module. Then the Reflex program is used to produce a Lex specification. Lex and Yacc are used to generate a scanner and a parser. The C compiler then translates the generated and (possibly user supplied) C modules. This Figure shows the way these tools cooperate:

Gentle

The Gentle compiler is invoked by the command


   gentle module.g
This translates a Gentle module module.g into a C module module.c (file names for Gentle modules must have the suffix .g).

If the module contains a grammar specification, then the following files are generated in addition: gen.lit contains Lex specifications for terminal symbols that appear literally in the specification. gen.tkn contains a list of tokens introduced in the specification. gen.h is a C header file that introduces a data type for token attributes and defines the codes of the tokens. gen.y is a Yacc specification of the underlying grammar.

See the Language Reference Manual for a description of Gentle.

Reflex

Reflex assembles various files and combines them to form a Lex specification.

For each token Token introduced in the specification, there must be a token description file Token.t . This file must specify a regular expression for the token and an action that computes the attributes of the token.

A block Block of the Lex specification may be overridden by a file Block.b . This allows the specific definition of white space and comment conventions ( LAYOUT.b, COMMENTS.b).

The directory reflex contains reusable token description and block files.

Reflex is invoked by the command


   reflex
This creates a Lex specification gen.l .

See the Reflex Reference Manual for details.

Lex

The command


   lex gen.l
invokes the scanner generator Lex with the specification gen.l . This creates a C module lex.yy.c .

Yacc

The command


   yacc gen.y
invokes the parser generator Yacc with the specification gen.y . This creates a C module y.tab.c .

C Compiler

The command


   cc file.c ... grts.o
creates an executable program. file.c ... is a list of generated or user-written C files. One of these modules must supply a function main that invokes the generated function ROOT(). The library provides such a function (module main.c).

See the Library Reference Manual for a description of library modules.



[NEXT] [PREV]