[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
Parsers-And-Lexers-in-C

Parsers and Lexers in C

-----------------------------

This tutorial is an update of an older article i have submitted as a link. Now its fully published at Codepedia.

Understanding Parsers & Lexers

Before implementing a Parser or Lexer in C/C++ one needs to know how Parsers and Lexers basically work. Also one needs to know the differences between Parsers and lexers.

1. Parsers

Parsers are a formal algorithm, or finite automate, that checks a given input if it mathes the predefined operations.

For example the parser of the C compiler checks, if all statements written in a header or source file match with the valid patterns as defined in the grammar of C programming language. ยด

The following code snippet shows valid patterns - or tokens - of C programming language:

/* defines N as 100 */
  1. define N 100
int main(int argc, char* argv[]) { int i = 0; /*i initialized with 0 */ while(i < 10) /* increment i untill it equals 9 */ i++; double k = 3.1475; /*define k as Pi */ return 0; }










last edited (July 26, 2004) by athomas, Number of views: 6173, Current Rev: 3 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.