Giter Site home page Giter Site logo

py2v's Introduction

py2v

py2v is a Python to V source transpiler written (mostly) in V. py2v aims not to have a bug-to-bug 100% accurate transpilation but to create a baseline to ease re-making Python projects in V.

Please see the examples folder to see the least py2v can do.

Installation

Dependencies:

  • V
  • Python 3.6+
git clone https://github.com/vlang/py2v.git
cd py2v
<path to V> -prod py2v.v -o py2v

Usage

./py2v <Python input file> <V output file>

Contributing

PRs are welcome. Please prefix your PR titles with the component you are editing. (docs: improve README.md etc.)

License

MIT License

py2v's People

Contributors

ccode-lang avatar div72 avatar medvednikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py2v's Issues

Deprecated Map Syntax

Using v run py2v.v ~/myfile.py raises the following error:

json2v/json2v.v:12:14: error: deprecated map syntax, use syntax like `{'age': 20}`
   10 | 
   11 | const (
   12 |     operators = map{
      |                 ~~~
   13 |         'LShift': token.Kind.left_shift
   14 |         'RShift': token.Kind.right_shift

Can't run on mac because of apples weird permissions

The terminal output is.

  File "ast2json.py", line 33
    print(f'USAGE: {sys.argv[0]} <source> <destination>')
                                                       ^
SyntaxError: invalid syntax
V panic: optional not set (failed to open file "/tmp/ast2json.temp.json")
v hash: d0100fa
0   libdyld.dylib                       0x000000018548d450 start + 4

Haven't looked into the code much so I have no idea what this means.

Also, I don't know how to read v errors.

Looks like it can't open the file or can't find it. I do know this project creates a file in /tmp. I checked it's not there.

Contibuting

How can I help with the development of this project? I have experience in Python and I have enthusiasm to be useful in developing V.
Maybe it makes sense to describe a list of tasks?

long build warning with newest version of v

json2v/json2v.v:3:8: warning: module 'os' is imported but never used
    1 | module json2v
    2 | 
    3 | import os
      |        ~~
    4 | import v.ast
    5 | //import v.checker
json2v/json2v.v:392:79: notice: direct sum type init (`x := SumType{}`) will be removed soon
  390 |                     mut ident := e as ast.Ident // FIX: assignment on to a function parameter with a default value will break this cast
  391 |                     typ := t.get_type(right[i])
  392 |                     mut scope_obj, mut scope := t.scope.find_with_scope(ident.name) or { ast.ScopeObject{}, &ast.Scope{parent: 0} }
      |                                                                                              ~~~~~~~~~~~~~
  393 |                     match scope_obj {
  394 |                         ast.Var {
json2v/json2v.v:392:79: notice: direct sum type init (`x := SumType{}`) will be removed soon
  390 |                     mut ident := e as ast.Ident // FIX: assignment on to a function parameter with a default value will break this cast
  391 |                     typ := t.get_type(right[i])
  392 |                     mut scope_obj, mut scope := t.scope.find_with_scope(ident.name) or { ast.ScopeObject{}, &ast.Scope{parent: 0} }
      |                                                                                              ~~~~~~~~~~~~~
  393 |                     match scope_obj {
  394 |                         ast.Var {
json2v/json2v.v:392:79: notice: direct sum type init (`x := SumType{}`) will be removed soon
  390 |                     mut ident := e as ast.Ident // FIX: assignment on to a function parameter with a default value will break this cast
  391 |                     typ := t.get_type(right[i])
  392 |                     mut scope_obj, mut scope := t.scope.find_with_scope(ident.name) or { ast.ScopeObject{}, &ast.Scope{parent: 0} }
      |                                                                                              ~~~~~~~~~~~~~
  393 |                     match scope_obj {
  394 |                         ast.Var {
json2v/json2v.v:392:79: notice: direct sum type init (`x := SumType{}`) will be removed soon
  390 |                     mut ident := e as ast.Ident // FIX: assignment on to a function parameter with a default value will break this cast
  391 |                     typ := t.get_type(right[i])
  392 |                     mut scope_obj, mut scope := t.scope.find_with_scope(ident.name) or { ast.ScopeObject{}, &ast.Scope{parent: 0} }
      |                                                                                              ~~~~~~~~~~~~~
  393 |                     match scope_obj {
  394 |                         ast.Var {

Looks like the script is soon going to be unsupported. Might have to fix these.

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.