Preview

COMPILER CONSTRUCTION TOOLS

Good Essays
Open Document
Open Document
2111 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
COMPILER CONSTRUCTION TOOLS
COMPILER CONSTRUCTION TOOLS

INTRODUCTION: Writing a computer is tedious and time consuming task. There are some specialized tools for helping in implementation of various phases of compilers. These tools are called compiler construction tools. These tools are also called compiler-compiler, compiler-generator, or translator writing system.

TOOLS FOR COMPILER :
Lex
Flex lexical Analyser
Quex
Ragel
Yacc
Antlr

LEX: Lex is a computer program that generates lexical analyzers ("scanners" or "lexers"). Lex is commonly used with the yacc parser generator. Lex, originally written by Mike Lesk and Eric Schmidt and described in 1975, is the standard lexical analyzergenerator on many Unix systems, and an equivalent tool is specified as part of the POSIX standard.
The structure of a Lex file is intentionally similar to that of a yacc file; files are divided into three sections, separated by lines that contain only two percent signs, as follows:
Definition section
%%
Rules section
%%
The definition section defines macros and imports header files written in C. It is also possible to write any C code here, which will be copied verbatim into the generated source file.
The rules section associates regular expression patterns with C statements. When the lexer sees text in the input matching a given pattern, it will execute the associated C code.
The C code section contains C statements and functions that are copied verbatim to the generated source file. These statements presumably contain code called by the rules in the rules section. In large programs it is more convenient to place this code in a separate file linked in at compile time.

FLEX: Flex (fast lexical analyzer generator) is a free software alternative to lex. It is a computer program that generates lexical analyzers("scanners" or "lexers"). It is frequently used with the free Bison parser generator. Unlike Bison, flex is not part of the GNU Project.

You May Also Find These Documents Helpful

  • Good Essays

    Nt1310 Unit 3 Quiz

    • 6337 Words
    • 26 Pages

    What is the primary purpose of the __P() macro? Choice 1 The __P() macro has no function, and merely obfuscates library function declarat ions. It should be removed from further releases of the C library. Choice 2 The __P() macro provides forward compatibility for C++ compilers, which do not r ecognize Standard C prototypes. Choice 3 Identifiers that begin with two underscores are reserved for C library implement ations. It is impossible to determine the purpose of the macro from the context given. Choice 4 The __P() macro provides backward compatibility for K&R C compilers, which do no t recognize Standard C prototypes. Choice 5 The __P() macro serves primarily to differentiate library functions from applica tion-specific functions. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*question number 68*/ Which one of the following is NOT a valid identifier? Choice 1 __ident Choice 2 auto [Ans] Choice 3 bigNumber Choice 4 g42277 Choice 5 peaceful_in_space - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*question number 69*/ /* Read an arbitrarily long string. */ Code: int read_long_string (const char ** const buf) { char * p = NULL; const char * fwd = NULL; size_t len = 0; assert(buf); do { p = realloc(p, len += 256); if (!p) return 0; if (!fwd) fwd = p; else fwd = strchr(p, '\0'); } while (fgets(fwd, 256, stdin)); *buf =…

    • 6337 Words
    • 26 Pages
    Good Essays
  • Good Essays

    In this phase a token is generated against all the lexemes in the source code. These lexemes and tokens are stored in the Symbol Table. Tokens against the lexemes are generated based on some patterns or rules.…

    • 703 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Unit 4 Homework

    • 401 Words
    • 2 Pages

    Name and describe the two parts that a module definition had in most languages. Header and Body…

    • 401 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    f. The set of all strings consisting of the keyword begin, followed by zero or more statements with a semicolon after each one, followed by the keyword end. Use the non-terminal for statements, and do not give productions for it.…

    • 470 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    (): The parentheses aren’t true wildcards, not in a matching sense. They allow you to divide a pattern into logical sequences.…

    • 404 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    unit 4

    • 691 Words
    • 4 Pages

    2. Name and describe the two parts that a module definition has in most languages.…

    • 691 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Miss

    • 274 Words
    • 2 Pages

    * It is like a library that contains all categories of identifiers that makes it easier and reduces number of codes. It is used as a prefix before the local name.…

    • 274 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Java Cis Assignment 1

    • 674 Words
    • 3 Pages

    1(a) Delimiters are used as comments. The Phrase is put in there to be shown to the user whilst programming, but is not shown when the program is to run.…

    • 674 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Objective-C Intro

    • 449 Words
    • 2 Pages

    X-Code (the compiler for Objective-C) builds it’s projects a little differently. In Python or C++, we have our class, struct’s, & functions all in the same document. However, X-Code splits up the delegation of these tasks to individual documents:…

    • 449 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Attribute grammar

    • 591 Words
    • 3 Pages

    where NUM and VAR are tokens. The lexer provides an attribute NUM.val that is the (integer) value of a NUM token. It also provides an attribute VAR.name that is the name of a variable. You would like to translate these expressions into instructions for a stack machine. The stack machine has the following instructions. Push the value of the variable at offset k onto the stack…

    • 591 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Linkers and Loaders

    • 739 Words
    • 3 Pages

    In computer science, a linker or link editor is a program that takes one or more objects generated by a compiler and combines them into a single executable program.…

    • 739 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    This design is based on the rule that all macro definitions should appear at the beginning of the program.…

    • 488 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    10) When a function is declared _________ the compiler replaces the function call with the respective function code.…

    • 694 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    C C++ User Guide

    • 126111 Words
    • 505 Pages

    About this document . . . . . . . . . . . . . . . . . . . . . . xv Typographical conventions . . . . . . . . . . . . . . . . . . . . . xv How to read syntax diagrams . . . . . . . . . . . . . . . . . . . xvi Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . xvi Syntax items . . . . . . . . . . . . . . . . . . . . . . . . xvi Syntax examples . . . . . . . . . . . . .…

    • 126111 Words
    • 505 Pages
    Satisfactory Essays
  • Powerful Essays

    The term compiler-compiler is sometimes used to refer to a parser generator, a tool often used to help create the lexer and parser.…

    • 3794 Words
    • 16 Pages
    Powerful Essays

Related Topics