Giter Site home page Giter Site logo

llama's Introduction

llama

Build Status Coverage Status

A llama implementation in Python.

Resources

  • Llama spec in greek
  • PLY: lex/yacc framework in Python.
  • pylint: Static analysis of Python code.
  • nose: Easy test discovery.
  • sure: DSL for human-readable assertions in Python.
  • flake8: Python style checker.

License

llama is released under the MIT License.

llama's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dkoutsou renelvon

llama's Issues

Array of int ref parses in incorrect order

The type of array of int ref parses as an (array of int) ref instead of array of (int ref).

The following test fails:

_assert_equivalent("array of int ref", "array of (int ref)")

Here's the actual VS expected AST result:

X = ASTNode:Ref with attributes:
    * copy_pos = '(non-scalar of type method)'
    * lexpos = '1'
    * lineno = '1'
    * type = 'ASTNode:Array with attributes:
        * copy_pos = '(non-scalar of type method)'
        * dimensions = '1'
        * lexpos = '1'
        * lineno = '1'
        * type = 'ASTNode:Int with attributes:
            * copy_pos = '(non-scalar of type method)'
            * lexpos = '10'
            * lineno = '1'
            * name = 'int'''
    and
Y = ASTNode:Array with attributes:
    * copy_pos = '(non-scalar of type method)'
    * dimensions = '1'
    * lexpos = '1'
    * lineno = '1'
    * type = 'ASTNode:Ref with attributes:
        * copy_pos = '(non-scalar of type method)'
        * lexpos = '10'
        * lineno = '1'
        * type = 'ASTNode:Int with attributes:
            * copy_pos = '(non-scalar of type method)'
            * lexpos = '11'
            * lineno = '1'
            * name = 'int'''
X is a Ref and Y is a Array instead

OCaml-ise errors/warnings.

Make the errors/warnings emmitted by the compiler follow the format of the standard OCaml compiler, ocamlc.

Function type must involve all input parameters

Currently, function type has a fromType and toType. However, this does not allow semantic validation that the return type is not of function type, as required by the spec (section 1.2, pg. 7, line 19).

Change function type to include a tuple of fromType parameters.

After changing the data structure, change the type semantic check to check that functions never return functions.

Get rid of parser_db

Rework the optimizations and other features of parser_db into the regular parser library, as they are useful beyond testing.

Even simpler API

Make the following work:

from compiler import parse
parse.parse("int ref ref", "type")

Investigate PLY parser caching

There seems to be an interaction between cached parsers and the parsing tables made by make prepare, resulting in reuse of a non-complete parser during functional tests.

Investigate.

Add `code` attribute to ast.Node

This attribute will contain the source code that was used to construct the particular ast.Node and can be used for debugging purposes.

For example, an ast.BinaryExpression + node could have code value "(f 2) + 3".

`!new int` does not parse

!new int does not parse from the expr parser state. This is because the bang operator is defined as taking a simple expr as an argument, but new does not return a simple expression.

Consider converting new to be a simple expression.

Starting from non-program state has caching issues

dionyziz@erdos ~/llama (validtypes) % python3
Python 3.4.1 (default, May 19 2014, 13:10:29)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from compiler import parse
>>> p = parse.Parser(start="type")
>>> p.parse("int ref ref")
<stdin>: 1:1: error: Syntax error on token INT  int
ASTNode:Program with attributes:
    * copy_pos = '(non-scalar of type method)'
    * lexpos = 'None'
    * lineno = 'None'
    * list = '[]'
>>> p = parse.Parser(start="type", optimize=False)
>>> p = parse.Parser(start="type", optimize=False, debug=False)
>>> p.parse("int ref ref")
ASTNode:Ref with attributes:
    * copy_pos = '(non-scalar of type method)'
    * lexpos = '1'
    * lineno = '1'
    * type = 'ASTNode:Ref with attributes:
        * copy_pos = '(non-scalar of type method)'
        * lexpos = '1'
        * lineno = '1'
        * type = 'ASTNode:Int with attributes:
            * copy_pos = '(non-scalar of type method)'
            * lexpos = '1'
            * lineno = '1'
            * name = 'int'''
>>>

Parser appends on the wrong side of lists.

When reducing rules that result to lists or sequences, the parser currently appends elements at the start and not the end of lists. This is a possible performance issue.

Proposed fix: Make the parser append at the end of lists, but reverse the said lists just before embedding them inside the AST Nodes. This will maintain program order.

Accompany with appropriate unit tests demonstrating correctness of patch.

Redefining built-in types should be a semantic error, not a syntax error

Current implementation of parser rejects the following definition of built-in bool type as a syntax error.

test bool = Bool

The parser should be refactored to accept the above definition and delegate semantic checking to the type module. The relevant features of type.Table and the respective tests are already in place (branch renelvon/test).

Refactor `string` into `array of char`.

According to the spec, a string literal has type array of char and is stored as a null-terminated string.

Refactor lexer, parser and type module to match the spec.

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.