Git Product home page Git Product logo

pl0-compiler's Introduction

PL0-Compiler

Compiler for PL0 language written in C for Systems Software Project Summer 2020

Equipped with Virtual Machine, Lexical Analyzer, Parser and Code Generator

                                  HOW TO COMPILE:

Enter the following into a Linux Shell Environment (requires GCC): "gcc driver.c lex.c parser.c codegen.c vm.c"


NOTE: Running any file will only print to the terminal the input/output and any directives you enter. All information (input, lex table/list, generated code, vm execution) will be printed into a text file called "output.txt" regardless of directives

                                     HOW TO RUN:

If you want to run all directives: (note for running any files, you don't have to give all directives like the examples)

"./a.out input.txt -l -a -v"

(Whatever input text file you want to test goes into the second argument)

RUNNING THE GIVEN FILES: (NOTE, ALL WRITE PRINTS WILL BE RIGHT AFTER THE INPUT FILE PRINT IN TERMINAL, NOT DURING STACK TRACE)

  • "noelleexampleinput.txt" is the name of the sample run input text file I submitted that parses and generates code perfectly with no errors
  • To run just type "./a.out noelleexampleinput.txt -l -a -v"
  • The output of that run is in "noelleexampleoutput.txt"

ERROR FILES:

  • I created multiple error text files to test every different invalid input
  • To run them just type "./a.out error1.txt -l -a -v", this example runs error test case 1 (there are 21 total error txt files)

ERROR VALUE MEANINGS:

Error 1, Period expected

Error 2, const, var or procedure must be followed by identifier

Error 3, double declaration within the same scope and level is not allowed

Error 4, constant identifier must be followed by =

Error 5, = must be followed by a number

Error 6, Semicolon or comma missing

Error 7, undeclared identifier

Error 8, assignment to constant or procedure is not allowed

Error 9, assignment operator expected

Error 10, end expected

Error 11, then expected

Error 12, do expected

Error 13, read must be followed by variable type identifier

Error 14, call sym must be followed by a proc identifier

Error 15, Relational operator expected

Error 16, Right parenthesis missing

Error 17, identifier, number or ( expected in factor

Error 18, used = instead of :=

Error 19, There should be nothing after period

Error 20, identifier expected after call

Error 21, use of procedure identifier in factor

pl0-compiler's People

Contributors

hungjn avatar

Watchers

 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.