Highlights
Problem Statement
Your task is to write lexer and parser for Boolean algebra using ML-Lex and ML-Yacc.
Problem Specification
Create lexer and parser files using ML-Lex and ML-Yacc for SML. Add a make-file to generate executable named a2.
Input: The executable should take the name of the file to be analyzed as a command-line argument. The syntax of the program, along with the names of
token types for each token, is as follows:
1. The input file consists of a single input program. Define a non-terminal program for the entire program. Each file should end with a token type EOF.
2. A program is a set of statements. A statement is a boolean formula followed by a `termination character semicolon (\;"). Use non-terminal statement for a valid statement and token type TERM for semicolon.
3. Represent a formula by non-terminal formula. A formula may consists of:
(a) Constants \TRUE" and \FALSE" representing bool 1 and 0 respec- tively. Use token type CONST for constants.
(b) Right-to-left associative prefix unary operator \NOT" of a formula, having form \NOT formula". Use token type NOT for token \NOT".
(c) Left-to-right associative infix binary operators over two formulas, having form \formula1 binop formula2", where \binop" can be \AND", \OR", \XOR" and \EQUALS". Represent these using token types
AND, OR, XOR and EQUALS respectively.
(d) Right-to-left associative implication operator of the form \formula1 IMPLIES formula2". Use token type IMPLIES for token \IMPLIES".
(e) Right-to-left associative if-then-else operator of the form \IF formula1 THEN formula2 ELSE formula3". Use token types IF, THEN and ELSE for \IF", \THEN" and \ELSE".
(f) Parenthesis to define order of evaluation over dierent operations \(formula)". Use token types LPAREN and RPAREN for left and right parenthesis respectively.
4. A formula or statement may be written in several lines. Executing the Program: We will compile your submission by running make command and run the executable as ./a2 hfilenamei
Output: The executable a2 should produce the output of the lexer followed by a newline, then the parser's output. Lexer output should be a comma- separated list (enclosed in square brackets) of tokens in order of their appear- ance in the input file. Each token in output should be of the form \htoken typei space hactual token in the input file enclosed in double quotesi". The output of the parser should be the preorder traversal of the generated parse tree.
The preorder traversal should be a comma-separated list of each node's representation. Use the production rules to represent a non-terminal node, and \htoken typei space hactual token in the input filei" to represent the terminal nodes in preorder traversal.
Tasks to be done
Task1: Write EBNF for the language given in this document in a file named ebnf.txt. Take care of the order of evaluation specified here.
Task2: Create a file for lexical analysis using ML-Lex for the language given in this document. Follow the specifications given regarding input, output, and execution.
Task3: Create a file for parsing the language given in this document using ML-Yacc. Follow the specifications given regarding input, output, and execution.
This COL226 - IT Assignment has been solved by our IT experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.