Showing posts with label LEX & YACC. Show all posts
Showing posts with label LEX & YACC. Show all posts

Wednesday, 8 November 2017

Lexical Analyzer for Sample Language

                       In this post, we will see LEX code to generate Lexical Analyzer for sample language.

Wednesday, 3 May 2017

LEX YACC program to check / recognize valid Arithmetic Expression

                  In this post, we will see LEX and YACC programs to check or recognize valid arithmetic expression. This expression may have operations like Addition(+), Subtraction(-), Multiplication(*), Division(/) or Modulus(%). Expression may contain balanced round brackets.
                 Explanation of the program, is given at the end of this post.
                Go through the following programs:

Monday, 18 January 2016

Concurrent YACC to Parse Input Text File

(With the help from Prof. Shailesh Cheke)
                In this post, we will see concurrent Lex-YACC program to parse a input text file which consists of several arithmetic expressions.
                To create threads, here we have used OpenMP API. To avoid race condition among threads to get access of global variables (like yylval, yyin, yytext), we have to use re-entrant parser. 

                Go through the following program:

Saturday, 9 January 2016

LEX YACC To Parse Input Text File

            In this post, we will see how to provide text file as input to Lex Yacc program. Here we will take example of arithmetic expression evaluation which takes arithmetic expressions from a text file.
           yyin is standard file pointer which is defined by lex yacc library. So that, just we have to declare it in yacc file by using keyword extern.
           
            Go through the following program:


Thursday, 1 October 2015

Intermediate code generation for sample language using LEX and YACC

                   In this post, we will see Intermediate code generation or three address code generation for sample language (here C Language) using LEX and YACC.
                   Following are the input file (input.txt), LEX & YACC files (intmcode.l, intmcode.y). Output is given at the end of this post.


Monday, 29 June 2015

LEX YACC program to evaluate arithmetic expression ( LEX and YACC programs for arithmetic expression evaluation )

                 In this post, I have given a LEX and YACC program to evaluate arithmetic expression. 
                 (Note: If you want to check just validity of arithmetic expression (i.e. valid or invalid), go through this post: LEX YACC program to check / recognize valid Arithmetic Expression)
                 Here arithmetic expression may have operations like Addition(+), Subtraction(-), Multiplication(*), Division(/) or Modulus(%). Expression may contain balanced round brackets.
                 Explanation of the program, is given at the end of this post.
                Go through the following programs: