By concept/function/implementation, what are the differences between compilers and parsers?
相关问题
- Correctly parse PDF paragraphs with Python
- R: eval(parse()) error message: cannot ope
- How do shader compilers work?
- C++ Builder - Difference between Lib and Res
- How do I parse a .pls file using PHP? Having troub
相关文章
- How do I get from a type to the TryParse method?
- Slow ANTLR4 generated Parser in Python, but fast i
- How to force Delphi compiler to display all hints
- Xcode - How to change application/project name : w
- What other neat tricks does the SpecialNameAttribu
- Parsing JSON in QML [duplicate]
- What is the purpose of “-Wa,option” in GCC? [close
- How do I generate an AST from a string of C++ usin
A compiler is often made up of several components, one of which is a parser. A common set of components in a compiler is:
To add a little bit:
As mentioned elsewhere, small C is a recursive decent compiler that generated code as it parsed. Basically syntactical analysis, semantic analysis, and code generation in one pass. As I recall, it also lexed in the parser.
A long time ago, I wrote a C compiler (actually several: the Introl-C family for microcontrollers) that used recursive decent and did syntax and semantic checking during the parse and produced a tree representation of the program from which code was generated.
Today, I'm working on a compiler that does source -> tokens -> AST -> IR -> code, pretty much as I described above.
A compiler is a special type of computer program that translates a human readable text file into a form that the computer can more easily understand. At its most basic level, a computer can only understand two things, a 1 and a 0. At this level, a human will operate very slowly and find the information contained in the long string of 1s and 0s incomprehensible. A compiler is a computer program that bridges this gap.
A parser is a piece of software that evaluates the syntax of a script when it is executed on a web server. For scripting languages used on the web, the parser works like a compiler might work in other types of application development environments.Parsers are commonly used in script development because they can evaluate code when the script is executed and do not require that the code be compiled first.
A parser takes in raw-data and
parses
it into a tree structure. This syntax-tree is then passed on to generator, which will turn it into whatever it is supposed to generate.So, a parser is a part of a compiler.
In general, parser is a part of the compiler, but compiler is designed to convert the received script generally into machine-readable code or sometimes into another language.
A parser just reads a text into an internal, more abstract representation, often a tree or graph of some sort.
A compiler translates such an internal representation into another format. Most often this means converting source code into executable programs. But the target doesn't have to be machine code. It can be another programming language as well; the compiler would still be a compiler. Obviously a compiler needs a parser to actually read its input.
Compiler always have a parser inside. Parser just process the language and return the tree representation of it, compiler generate something from that tree, actual machine codes or another language.