GithubHelp home page GithubHelp logo

let-unimi / liblet Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 2.0 1.6 MB

A teaching aid library for formal languages and compiler courses

Home Page: https://liblet.readthedocs.io/

License: Creative Commons Attribution Share Alike 4.0 International

Python 96.25% Shell 0.33% Smarty 0.27% Jupyter Notebook 3.15%
formal languages graphs tree grammars automata antlr graphviz context-free-grammar

liblet's People

Contributors

andreazube avatar kristiannotari avatar lprigioniero avatar mapio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

liblet's Issues

Possible error in test

In the file automaton_test.py there is a test (test_transition_lt) that's a bit strange, feels like there's been a copy-paste from the one above
image

Shouldn't it be something like

def test_transition_lt(self):
        self.assetTrue(t1.__lt__(t2))

where t1 and t2 are previously defined transitions?

Regards,
Manuele

Consider the introduction of a Table class

Such class can provide several functionalities now spread out in the library (using dicts, or dods):

  • a read access where missing index(es) lead to less code (no try or if),
  • a write access with conflict check to avoid multiple entries per index(es),
  • a pretty print (based on current dict2table and dod2table).

Such class could simplify the LL/LR lectures quite a bit.

Grammar restrict_to method, what about the start symbol?

If you restrict a grammar using the restrict_to method and you don't pass the start symbol within the symbols to keep, what happens to the grammar? Should the method throw some sort of error/exception? Should it try to retrieve the first (single) lhs of another kept production rule in order to get a new start symbol, if possible?

Attribute Serialization

If you define an object of the AnnotatedTreeWalker class that makes use of attributes within the registered functions, saving the ATW object with the save method does not save the attributes used, as in the case of the following example:

from liblet import AnnotatedTreeWalker, Tree

tree = Tree({'name': 'test'})

test_atw = AnnotatedTreeWalker('name')
@test_atw.register
def test(visit, ast):
    test_atw.VAR = 5
    print(test_atw.VAR)
    print(3)

test_atw(tree) # out: 5 3

test_atw.save('test.atw')
test_atw = AnnotatedTreeWalker.load('test.atw')

test_atw(tree) # out: exception

By running the above code, an error is raised:

NameError: name 'test_atw' is not defined

Change `Stack` iteration order.

The Stack data structure should iterate from the top (via sequence of pop), currently it iterates in the reverse order:

list(Stack([1,2,3]))

should produce [3, 2, 1] but now produces [1, 2, 3].

This will break compatibility quite badly. At least the https://github.com/let-unimi/handouts should be revised in accordance to the change.

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.