Home > fc

fc

Fc is a project mainly written in Java, based on the MIT license.

Student Project - Floating Point Calculator

fc - Floating Point Calculator

ABOUT

Fc is the result of a students project in scope of the 2010 fall term lecture Automata and Formal languages at University of Applied Science Berne.

https://modules.ti.bfh.ch/tcs/www/2010hs/afl/

The floating point calculator consists of a lexer and different types of parsers matching the following grammar (EBNF):

Statement ->  'let' Identifier '=' Expr | 'exit' | Expr
Expr -> Term { ('+'|'-') Term }
Term -> Factor { ('*'|'/') Factor }
Factor -> '(' Expr ')' | [ '-' ] ( Num | Identifier )

Num is a real number (without exposant) and Identifier is a sequence of
letters.

Two parser implementations must be realized, one using JavaCC and another one implemented without the help of third party java frameworks.

COMPILE & RUN

Please import the project into eclipse to build the software. There are some prepared run configurations in the 'misc' directory. Choose 'Organize Favorites' from the 'run' drop down menu to enable them.

You may also run the software from the command line. By means of the 'parser' property it is even possible to choose which parser implementation is used:

java fc.cli.Calculator -Dparser=fc.parser.rdp.Parser java fc.cli.Calculator -Dparser=fc.parser.javacc.Parser

AUTOMATED TESTING

There are unit tests in place which cover nearly the whole lexer and rdp parser and a great deal of the generated JavaCC code. Some test cases depend on the mocking framework mockito. Please enable mockito in the 'java build path' section in the project properties. Mockito is free software and can be optained from the mockito website:

http://www.mockito.org/

The test case fc.parser.AcceptanceTest is modelled after the examples from the problem definition. This test case can be used to verify if the implemented parsers match the requirements.