Project Description

Simple Script is a simple implementation of an interpreter language built with GPlex and Gppg (Lex/Yacc). It's developed in C#.

This project is a student project for the "Compilers" course held by Prof. Ashot Vasilyan at the IT Eduaction and Research Center at the Yerevan State University.

More info on GPLEX here (http://gplex.codeplex.com/)
More info on GPPG here (http://gppg.codeplex.com/)
In-order to make things rolling you need to download the GPLEX and GPPG distros from the links above.

Useful Links
http://luv.asn.au/overheads/lex_yacc/yacc.html
http://www.cs.man.ac.uk/~pjj/cs212/ho/node7.html
Creating a Lexer for C# http://ivanhawkes.wordpress.com/2010/06/06/creating-a-lexer-for-a-c-parser/
http://www.mactech.com/articles/mactech/Vol.06/06.04/ParsingwithYACC/index.html

Important

The project file SimpleScript.Analyzing.csproj is customized to build the scanner and parser with gplex and gppg automatically when the Lex or Yacc files are modified.
In-order to make this working the paths to gplex.exe and gppg.exe must be added to your PATH environmental variable. And also to built the project you need to check-out the whole SimpleScript.Analyzing project, in-order not to get file permission/lock errors.

An example of a SimpleScript calculating the Greatest Common Divisor

Begin
Dim $a As int
Dim $b As int
Dim $t As int

Print "Welcome To GCD !!!"

Print "Input a:"
Input $a
Print "Input b:"
Input $b

While ($b!=0) Do
$t=$b
$b=$a % $b
$a=$t
Next
Print "The GCD is:"
Print $a
End

Stuff Implemented

Types
  • int
  • double
  • string
  • bool

Program Start and End
  • Begin <statements> End

Variable Declaration
  • Dim <Identifier> As <int, double, string, bool>

Operations
  • Assignment =
  • Add +
  • Minus -
  • Mul *
  • Div /
  • Modul %
  • And and (not yet implemented)
  • Or or (not yet implemented)
  • Not not (not yet implemented)
  • Equal ==
  • Not Equal !=
  • Little <
  • Great >
  • Great or Equal >= (not yet implemented)
  • Little or Equal <= (not yet implemented)

Input/Print Statements
*Input <Ident>
*Print <Expr>

Loops
  • : For (<ident>=<expr>) To <expr>
<Statements>
Next
  • : While (<Expr>) Do
<Statement List>
Next
Conditional Statements
  • : If (<Expr>) Then
<Statement List>
Else (else may not be present)
<Statement List>
Fi

Last edited Jan 10, 2011 at 9:20 PM by tigrantopchyan, version 7