Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

In development compiler for UFRGS Compilers course.

NotificationsYou must be signed in to change notification settings

camargodev/compilers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compiler for a programming language called The Language.Proposed and developed in UFRGS' Compilers course.You can clone or download this repository freely.

Prerequisites

TLC is a flex-bison based compiler. So, you will need to install them.You can use

apt-get install flex

and

apt-get install bison

It also uses programming language C, so you will need GCC.

Installing

To get started, open the main folder on a Unix based system and typemake.This command should generateflex andbison necessary files.Also, withmake, you automatically generates the AST (Abstract Syntax Tree) for the language.

Running the tests

To test, you can usemake test.Also, each part has a different set of tests.You can just get into the part specific folder and run the same command.

Parts

The root folder has everything that is necessary for running this compiler.Each specific part folder just marks the evolution of the project.Just runmake to generate the necessary files. Visiting theMakefile of each folder will show you how to test.

Part 1 [Aug 2018]

A lexer scanner was developed to accept the tokens of the language.This scanner uses onlyflex and is available atpart-1/scanner.l.

Part 2 [Sep 2018]

In this part,bison was introduced to perform the syntactic analysis.If you accesspart-2/parser.y, you'll see that now some syntactic rules were done to give some sense to the inputs.Still, no semantic analysis is performed, so something likeint x = "hello"; is accepted.

Part 3 [Oct 2018]

In this part, the AST (Abstract Syntax Tree) is build within the syntactic analysis.For this, structs like the onestree.h andlexeme.h were developed.Also, values were added to tokens onscanner.l and tree construction functions were used onparser.y.

Part 4 [Oct 2018]

In this part, the semantic analysis was added.During the syntactic analysis, the tokens were semanticly verified.This part will prevent the use of undeclared identifiers or double declaration of a identifier, for example.A lot of structs were developed, but the most important are ontable.h, liketable_stack that represents a stack of symbol tables.Also, nodes fortree.h now have types (like a expression node) and conversions are marked on nodes.

Part 5 [Nov 2018]

In this part, we started the code generation from "The Language" toILOC.Also, the language was trully simplfied and we only deal with integers now.The commands for which code is "generated" are:

  • Variable declaration, iex int; (global vars),int x; andint x <= 1; (local var with/without inicialization).
  • If conditionals, ieif (bool) then {...}; andif (bool) then {...} else {...};.
  • While/Do-While, iedo {...} while (bool); andwhile (bool) do {...};

Built With

  • Flex - The Fast Lexical Analyzer
  • Bison - A LALR(1) general-purpose parser generator
  • GCC - The GNU Compiler Collection

Contributing

If you want to contribute to this compiler project, just e-mail me atcamargodev@gmail.com.Although this was developed for a college course, it has a huge potential for learning.

Authors

  • João Vitor de Camargo -Developer
  • Marcellus Farias -Developer

Acknowledgments

  • This project was developed under the counseling of UFRGS' professor Lucas Schnorr.

About

In development compiler for UFRGS Compilers course.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp