Skip to content

Coursework for UCL Computer Science course COMP0012: Compilers

Notifications You must be signed in to change notification settings

abircb/COMP0012--Compilers-CW

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

COMP0012: Compilers

The goal of this coursework was to build a lexer (lexical analyser) and parser for the imaginary Žsec programming language using JFlex 1.6.1 and CUP v.11b-20160615. The lexer defines the language's syntax: contains regular expressions covering all legal words in the Žsec language, and the parser defines a context-free grammar describing the language's rules or semantics.
The full specification for the Žsec language is given in the project.pdf file.

Lexer and Parser

The lexer (in src/Lexer.lex)

  • Uses JFlex to automatically generate a scanner for the Žsec language.
  • Reports the line and the column (offset into the line) where an error, usually unexpected input, first occurred.

The parser (in src/Parser.cup)

  • Uses CUP(Construction of Useful Parsers) to automatically produce a parser for the Žsec language.
  • Resolves ambiguities in expressions using the precedence and associativity rules;
  • Prints “parsing successful”, followed by a newline, if the program is syntactically correct.

Usage

The project is built using MakeFile

To build, issue make

To test, issue make test

To run on a single test file, issue ./bin/sc tests/open/<some test>.s

The parser was tested against a suite of positive and negative tests (the results.csv file contains the test results) by an automatic marking script and recieved a perfect score.

About

Coursework for UCL Computer Science course COMP0012: Compilers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published