Git Product home page Git Product logo

flex-bison-jvm-language's Introduction

flex-bison-jvm-language

Simple Flex and Bison programs producing the corresponding C code to validate provided SimpleLanguage (.sl) file syntax, perform semantic analysis and compile to JVM asembly(jasmin), which can then be executed.
SimpleLanguage syntax:

start {program name}
{command0}
    .
    .
    .
{commandN}
end

Two types of commands exist:

  1. Assignment(affix format): ({var} (expression))
  2. Print: (print {var or (expression)})

Assigment command example:

(x (3 4 +))

Print command examples:

(print (3 4 +))
(print x)

Notes:

  • Each command is enclosed in parentheses
  • Type casting and coersion are supported
  • Variables are not declared(type is deducted by first assignment)

Compilation and tests execution is streamline via a Makefile.
Six valid and one invalid test SimpleLanguage files have been provided to play with.

Usage

% make

Makefile can be configured to use a different test case set and/or files.

Execution example

❯ make test
flex -s -o lexer.c lexer.l
bison -v -o parser.c parser.y
gcc -Iexternal parser.c -o compiler -lfl
Errors found 0.
Generated: test_0.class
7
Errors found 0.
Generated: test_1.class
49
49.0
Errors found 0.
Generated: test_2.class
7.0
11.0
Errors found 0.
Generated: test_3.class
7.0
Errors found 0.
Generated: test_4.class
7
Errors found 0.
Generated: test_5.class
7
Errors found 0.
Generated: test_6.class
7.0
3
ERROR: syntax error, unexpected ')'. on line 2.
Warning: value is already int, in line 4.
Variable z NOT initialized, in line 5. ERROR: Variable fault. on line 5.
Integer var y. ERROR: Narrowing Conversion (float to int). on line 6.
Warning: value is already real, in line 8.
Variable x NOT initialized, in line 9. ERROR: Variable fault. on line 9.
Errors found 4.
No Code Generated.
make: [Makefile:40: test] Error 1 (ignored)

flex-bison-jvm-language's People

Contributors

aggstam avatar

Stargazers

 avatar

Watchers

 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.