Giter VIP home page Giter VIP logo

aps-logcomp's Introduction

K Language

Run

To run a program, just use the compiler as python module:

$ python -m compiler ./demo/simple_program.k

Unit Tests

$ python -m pytest -v --no-header

Demo

demo

EBNF

TOP_LEVEL = { STATEMENT } ;

BLOCK = "{" , { STATEMENT }, "}" ;

TYPE = "integer" | "string" | "void";

IDENTIFIER_DECLARATION = TYPE , IDENTIFIER ;

FUNCTION_DEFINITION = TYPE , IDENTIFIER , "(" [ , TYPE, IDENTIFIER [ , { "," , TYPE, IDENTIFIER } ] ] , ")" , FUNCTION_BODY;

FUNCTION_BODY = "{" , { STATEMENT }, [ , FUNCTION_RETURN ] , "}";

FUNCTION_RETURN = "return", EXPRESSION ;

FUNCTION_CALL = IDENTIFIER , "(" [ , IDENTIFIER [ , { "," , IDENTIFIER } ] ] , ")" ;

STATEMENT = ( λ | IDENTIFIER_DECLARATION | FUNCTION_DEFINITION | FUNCTION_CALL | ASSIGNMENT | BLOCK | WHILE_STATEMENT | IF_STATEMENT ), ";";

FACTOR = ( NUMBER | IDENTIFIER | FUNCTION_CALL | ( UNNARY_OPERATOR , FACTOR ) | "(" , CONDITIONAL , ")" );

TERM = FACTOR, { ("\*" | "/" | "and"), FACTOR } ;

EXPRESSION = TERM, { ("+" | "-" | "or"), TERM } ;

CONDITIONAL = EXPRESSION , { ("<" | "<=" | "==" | "!=" | ">=" | ">" ) , EXPRESSION } ;

WHILE_STATEMENT = "while" , "(" , CONDITIONAL , ")" , BLOCK ;

IF_STATEMENT = "if" , "(" , CONDITIONAL , ")" , BLOCK , [ "else" , BLOCK ] ;

ASSIGNMENT = IDENTIFIER, "=" , EXPRESSION ;

IDENTIFIER = LETTER, { LETTER | DIGIT | "_" } ;

UNNARY_OPERATOR = ( "+" | "-" | "not" ) ;

NUMBER = DIGIT [ { , DIGIT } ] ;

LETTER = ( "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" |
"M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" |
"Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" |
"k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" |
"w" | "x" | "y" | "z" ) ;

DIGIT = ( "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0" ) ;

aps-logcomp's People

Contributors

cicerotcv avatar

Watchers

James Cloos avatar  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.