Git Product home page Git Product logo

cpsc-323-compiler's Introduction

RAT24S Compiler

1. Compiler Usage

usage: compiler.py [-h] [--print-tokens] [--save-tokens SAVE_TOKENS] [--print-productions] [-s SAVE_PRODUCTIONS] [--symbol-table SYMBOL_TABLE] source file

positional arguments:
  source file           Path to the source code file that will be compiled

options:
  -h, --help            show this help message and exit
  --print-tokens        print tokens returned by lexer
  --save-tokens SAVE_TOKENS
                        Specify output file for tokens
  --print-productions   Print productions to console
  -s SAVE_PRODUCTIONS, --save-productions SAVE_PRODUCTIONS
                        Save syntax analyzer productions to a file
  --symbol-table SYMBOL_TABLE
                        Save symbol table to a file

2. Language Specification

2.1 Comments

A comment starts with a [* and ends with a *]. Comments are ignored by the lexical analyzer and syntax analyzer.

[* This is a one line comment *]

[* This is a multiline comment
that spans three rows. All three
rows will be ignored by the compiler. *]

2.2 Identifiers

An identifier is a sequence of letters (a - z), digits (0 - 9), and underscores ("_"). The first character in an identifier must be a letter. Case is insignificant, so the lexical analyzer must convert all uppercase letters to lowercase so that all tokens are lowercase.

2.3 Keywords

The following identifiers are keywords of the language and cannot be used for ordinary identifiers.

boolean		else		endif
false		function	if
integer		print		real
return		scan		true
while		endwhile

2.4 Integers

Integers are unsigned decimal integers. They are a sequence of digits.

Examples of integers

7	153	1849375932

2.5 Reals

A real is an integer, followed by a dot ("."), followed by an integer. There must be an integer before the dot, and an integer after the dot, meaning that something like 89. or .57 would be invalid.

Examples of reals

3.14	22.5	0.99	25.0

2.6 Operators

The following tokens are operators.

+	-	*	/
==	!=	>	<
<=	=>	=

2.7 Separators

The following tokens are separators.

(	)	{	}
,	;	$

Space (' ') is also a separator used to separate tokens and symbols.

cpsc-323-compiler's People

Contributors

santi224m avatar fanaticaj avatar josephvelasquez48 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.