TMDLang icon indicating copy to clipboard operation
TMDLang copied to clipboard

project setup and improvements

Open pyx opened this issue 7 years ago • 6 comments

Besides the pull request I just created (#2), I can also help you to setup the project structure and installation script:

  • setup.py and friends
  • dependencies handling, I think the only one right now is cairocffi
  • proper command line handling with argparse, thus, a better CLI
  • unit testing if needed

then this parser can be installed and run as simply as:

# make virtualenv, optional
pip install TMDLang
# then, to run
tmd

It should be possible to have it in homebrew this way.

In function Pass1 inside tmd.py, module-level global variables in TMDScanner are being modified, which I think is a BAD idea.

There are also many places that can be improved, and once I understand what the language spec. is, I might be able to help you on the parser as well, but there is no documentation now and reading regular expressions is no fun.

BTW, I cannot run the program (Linux: gentoo, with Python 3.5.2, cairocffi 0.7.2, cairo-1.14.6)

The first problem is that you seemed to switch to CFFI version of python cairo binding from pycairo, but you still referring to pycairo in TMDDrawer.py (import cairo), this one should be easy to fix.

The second one is when I tried it with your work

python src/tmd.py example/三天三夜.tmd

I got something like:

Traceback (most recent call last):
  File "src/tmd.py", line 96, in 
    main()
  File "src/tmd.py", line 92, in main
    TMDDrawer.ChordDrawer(Page, testChordList)
  File "/home/pyx/projects/TMDLang/src/TMDDrawer.py", line 39, in ChordDrawer
    Surface.move_to(Chord[3][0], Chord[3][1])# 2200, 3208 for temp
IndexError: string index out of range

This should be either something wrong with the parsing logic (missing required non-empty string field in ChordList) or feeding erroneous input data to the parser with which it cannot handle gracefully.

pyx avatar Oct 31 '16 23:10 pyx