Eli   Documents

General Information

 o Eli: Translator Construction Made Easy
 o Global Index
 o Frequently Asked Questions
 o Typical Eli Usage Errors

Tutorials

 o Quick Reference Card
 o Guide For new Eli Users
 o Release Notes of Eli
 o Tutorial on Name Analysis
 o Tutorial on Scope Graphs
 o Tutorial on Type Analysis
 o Typical Eli Usage Errors

Reference Manuals

 o User Interface
 o Eli products and parameters
 o LIDO Reference Manual
 o Typical Eli Usage Errors

Libraries

 o Eli library routines
 o Specification Module Library

Translation Tasks

 o Lexical analysis specification
 o Syntactic Analysis Manual
 o Computation in Trees

Tools

 o LIGA Control Language
 o Debugging Information for LIDO
 o Graphical ORder TOol

 o FunnelWeb User's Manual

 o Pattern-based Text Generator
 o Property Definition Language
 o Operator Identification Language
 o Tree Grammar Specification Language
 o Command Line Processing
 o COLA Options Reference Manual

 o Generating Unparsing Code

 o Monitoring a Processor's Execution

Administration

 o System Administration Guide

Mail Home

Solutions of common problems

Previous Chapter Next Chapter Table of Contents


Sorting Elements of an Array

This C module implements a function that sorts the elements of an array in place. It uses the O(n log n) Heapsort algorithm.

The module is instantiated by

   $/Tech/Sort.gnrc +instance=TYPE +referto=HDR :inst
where TYPE is the name of the array element type and HDR.h is a file that defines the array element type, e.g.
   $/Adt/Sort.gnrc+instance=DefTableKey +referto=deftbl :inst
If the element type is predefined in C the referto parameter is omitted, e.g.
   $/Adt/Sort.gnrc+instance=int :inst

All entities exported by this module can be used in specifications of type .lido, .init, .finl, and .con. They can also be used in .pdl specifications or in C modules if the interface file SortTYPE.h is imported there.

The module exports the following function:

void SortTYPE (TYPE *arr, size_t n, TYPECmpFctType cmp)
arr points to the array to be sorted, which contains n elements. cmp is the function that defines the collating sequence for the elements. It's signature is TYPE, TYPE -> int; it yields -1 if the left argument should precede the right in the sorted array, +1 if the left argument should follow the right in the sorted array, and 0 if the order of the elements in the sorted array is immaterial.


Previous Chapter Next Chapter Table of Contents