Skip to content

Project 1: Practice conducting syntax analysis on given program components

Notifications You must be signed in to change notification settings

cherrymalia/Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parser

A C++ program that takes a file as input, identifies what token type the lexeme in the file are, and prints them out. It then uses the EBNF Demo Language to check if the file is a syntaxically correct program.

Author

The EBNF Demo Language

<program>   ->    <keyword><ident>() {<declares><stmts>}
<declares>  ->    <keyword><ident> ;
            |     <keyword><ident> ; <declares>
<stmts>     ->    <assign> ; <stmts>
            |     <assign> ;
<assign>    ->    <ident> = <expr>
<expr>      ->    <ident> {*|/} <expr>
            |     <ident> 
            |     (<expr>)
keyword     ->    float
ident       ->    a<ident>|b<ident>...|z<ident>

Get Started

Use the following to compile the code

sudo apt-get install g++

Running

  1. Clone the repository:
git@github.com:cherrymalia/Parser.git
  1. There are two test files. You can change which one you use by changing the code in main.cpp

  2. Compile it with:

g++ main.cpp analyzer.h analyzer.cpp -std=c++11
  1. Run it with:
./a

About

Project 1: Practice conducting syntax analysis on given program components

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages