Giter Club home page Giter Club logo

uw-compilers's Introduction

## SUBMISSION BY SAURABH SETH -- HW 8 FOR EXTRA CREDIT 

1. All the grammar conditions are working as described by the assignment.
2. Exponentiation is right-associative i.e. 2**3**2 = 512 not 64.
3. list, clear, quit, exit, sqrt are all keywords.
4. Extra keywords have been added for extra credit part. Please note that these will not work as identifiers. Details below -->
	'cbrt' --> Computes the cube root of x.
	'sin'  --> Computes the sine of x (expressed in radians).
	'cos'  --> Computes the cosine of x (expressed in radians).
	'tan'  --> Computes the tangent of x (expressed in radians).
	'log'  --> Computes the logarithm of x.


******************* EXTRA CREDIT *************************

5. Meaningful message printed after assignment and clear statements for 1st point (very easy)
	- On success of assignment, a saved to memory message printed with value.
	- On success of clear, a removed from memory message printed with value.
	
6. Language has been extended for 2nd point (fairly easy) -->
	- Allowing Empty Lines (statements) in the input
	- Allowing Multiple Statements on an input line separated by semicolons. Please note that ";" is now a valid symbol.
	- Unary Minus Operator. This is done by including extra rules in grammar like -->
			
			factor ::= id  |  number  |  ( exp ) | sqrt ( exp ) | - number  |  - ( exp )
	- Please note that -id will not work. Instead use -(id) in the calculations.
			
7. Language has been extended for 3rd point (more complex) -->
	- 'cbrt' --> Computes the cube root of x.
	- 'sin'  --> Computes the sine of x (expressed in radians).
	- 'cos'  --> Computes the cosine of x (expressed in radians).
	- 'tan'  --> Computes the tangent of x (expressed in radians).
	- 'log'  --> Computes the logarithm of x.
	- Extended grammar rules -->
			
		factor ::= id  |  number  |  ( exp ) | sqrt ( exp ) | - number  |  - ( exp ) | cbrt ( exp ) | sin ( exp ) | cos ( exp ) | tan ( exp ) | log ( exp )


8. Add decent error handling for 4th point -->
	- This has been implemented in all over the code by producing meaningful error messages 
		- If exp is not evaluated, prints "INCORRECT SYNTAX. PLEASE CHECK THE MANUAL."
		- If extra characters are present, prints "JUNK PRESENT IN THE INPUT."
		- In clear statement, if identifier not present in the map, prints "UNKNOWN IDENTIFIER --> " id.
		- In assign statement, if exp not evaluated, prints "INCORRECT SYNTAX. PLEASE CHECK THE MANUAL."
		- If unassigned ID used anywhere in exp, prints "UNKNOWN IDENTIFIER --> id. INCORRECT SYNTAX. PLEASE CHECK THE MANUAL."
		- Check for Left Parenthesis for all expressions, prints "MISSING ( IN THE EXPRESSION."
		- Check for Right Parenthesis for all expressions, prints "MATCHING ) NOT FOUND FOR (."
		- Specific message for 0 division, prints "DIVISION BY ZERO NOT ALLOWED."
		- In clear statement, other symbol provided instead of identifier, print "ERROR IN SYNTAX. AN IDENTIFIER EXPECTED AFTER clear."
		
	- Resumes scanning and parsing after an error in an input statement.

uw-compilers's People

Watchers

Saurabh Seth 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.