Giter Site home page Giter Site logo

scanner's Introduction

Terry Ford Jr. - CS 4280 Compiler Project - P3 Static Semantics - 11/18/2023
git - https://github.com/tfordjr/scanner

Three options for invokation:
./P3                                      Read from stdin (stop input with Ctrl+D)
./P3 filename(exclude extention)          Read from file, .f23 file extention assumed
./P3 < filename(include extention)        Put file into stdin

implementation: 
main.cpp handles file input and stdin input
parser.cpp, parser.h handle parser function and full BNF
scanner.h handles scanner function and token definition
testTree.cpp, testTree.h, node.h handle node definition, tree traversal, semantics
testing files t1-t10 are good programs, tb1-tb10 are bad programs
simple makefile and readme included

Added static semantics (double declaration or use without declaration)
added it to testTree.cpp and testTree.h because the semantics are just another traversal

Full BNF:
<program>     ->      <vars> xopen <stats> xclose
<vars>        ->      empty | xdata <varList>
<varList>     ->      identifier : integer ; | identifier : integer <varList>
<exp>         ->      <M> / <exp> | <M> * <exp> | <M>
<M>           ->      <N> + <M> | <N>      
<N>           ->       <R> - <N> | ~ <N> |  <R>
<R>           ->      ( <exp> )  | identifier | integer
<stats>       ->      <stat>  <mStat>
<mStat>       ->      empty |  <stat>  <mStat>
<stat>        ->      <in>   | <out>   | <block> | <if>  | <loop>  | <assign>
<block>       ->      { <vars> <stats> }
<in>          ->      xin >> identifier ;
<out>         ->      xout << <exp> ;
<if>          ->      xcond [ <exp> <RO> <exp> ] <stat>
<loop>        ->      xloop [ <exp> <RO> <exp> ]  <stat>
<assign>      ->      xlet  identifier  <exp> ;
<RO>          ->      << (one token)  | >>  (one token)  | < | > | = | % 

scanner's People

Contributors

tfordjr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.