Compiler Final

download Compiler Final

of 2

description

Core principles of Compiler

Transcript of Compiler Final

ParsingIn computer technology, a parser is a program, usually part of acompiler, that receives input in the form of sequential source program instructions, interactive online commands, markup tags, or some other defined interface and breaks them up into parts (for example, the nouns (objects), verbs (methods), and their attributes or options) that can then be managed by other programming (for example, other components in a compiler). A parser may also check to see that all input has been provided that is necessary.Parsingorsyntactic analysisis the process of analysing astringof symbols, either innatural languageor incomputer languages, conforming to the rules of aformal grammar.

In computer science,LR parsersare a type of bottom-upparsersthat efficiently handle deterministic context-free languages in guaranteed linear time.1. Apredictive parseris a recursive descentparserthat does not require backtracking.he goal of predictive parsing is to construct a top-down parser that never backtracks. To do so, we must transform a grammar in two ways:1. eliminate left recursion, and2. perform left factoring.

Javacc is a tool usually used for parsers and is actually maintained by Sun Microsystems. Is very simple, efficient and safe.

1. Acontext-free grammar(CFG) is a set of recursive rewriting rules (or productions) used to generate patterns of strings. A CFG consists of the following components: a set of terminal symbols, which are the characters of the alphabet that appear in the strings generated by thegrammar.aregular expression(abbreviatedregexorregexpand sometimes called arational expression[1][2]) is a sequence ofcharactersthat define a search pattern, mainly for use inpattern matchingwithstrings, orstring matching, i.e. "find and replace"-like operations.Lex Break the source file into individual words, or tokensParse Analyze the phrase structure of the program.compileris a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code).