Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"[Every language other than C#] doesn't have a List#concat method" #19

Open
tra38 opened this issue Dec 4, 2017 · 4 comments
Open

"[Every language other than C#] doesn't have a List#concat method" #19

tra38 opened this issue Dec 4, 2017 · 4 comments

Comments

@tra38
Copy link

tra38 commented Dec 4, 2017

To replicate:

>cat add_two_arrays.py

def add_two_arrays(arrayA, arrayB):
  return arrayA + arrayB

print(add_two_arrays([1,2,3], [4,5,6])) 

>pseudo-python add_two_arrays.py
OK
saved pseudo ast as add_two_arrays.pseudo.yaml

>pseudo add_two_arrays.pseudo.yaml go

Traceback (most recent call last):
  File "/usr/local/bin/pseudo", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/pseudo/main.py", line 44, in main
    output_source = pseudo.generate_from_yaml(intermediate_code, format)
  File "/usr/local/lib/python3.6/site-packages/pseudo/__init__.py", line 97, in generate_from_yaml
    return pseudo.generate(pseudo.loader.as_tree(pseudo_ast), language)
  File "/usr/local/lib/python3.6/site-packages/pseudo/__init__.py", line 116, in generate
    translated_ast = API_TRANSLATORS[language](pseudo_ast).api_translate()
  File "/usr/local/lib/python3.6/site-packages/pseudo/api_translator.py", line 81, in api_translate
    transformed = self.transform(self.tree)
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 34, in transform
    tree = self.transform_default(tree)
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 54, in transform_default
    setattr(tree, field, self.transform(child))
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 41, in transform
    return [self.transform(child) for child in tree]
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 41, in <listcomp>
    return [self.transform(child) for child in tree]
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 34, in transform
    tree = self.transform_default(tree)
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 52, in transform_default
    setattr(tree, field, self.transform_block(child))
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 60, in transform_block
    result = self.transform(child, True)
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 34, in transform
    tree = self.transform_default(tree)
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 50, in transform_default
    setattr(tree, field, self.transform(child, False, tree if tree.type[-10:] == 'assignment' else None))
  File "/usr/local/lib/python3.6/site-packages/pseudo/tree_transformer.py", line 32, in transform
    tree = handler(tree, in_block, assignment)
  File "/usr/local/lib/python3.6/site-packages/pseudo/api_translator.py", line 148, in transform_standard_method_call
    '%s doesn\'t have a %s#%s method' % (type(self).__name__, l, node.message))
pseudo.errors.PseudoStandardLibraryError: GolangTranslator doesn't have a List#concat method

You get this same error for C++, Ruby, JS and Python. Only C# is able to handle List#concat properly, and I am able to generate human-readable C# code using pseudo.

@alehander92
Copy link
Collaborator

Hey, Pseudo is not maintained currently, if there is enough interest, I might cleanup the errors for the stdlib functions when I have spare time(one guy wrote a nice testing tool for that, just a matter of a day to clean most of them up)

What is your usecase for it

@tra38
Copy link
Author

tra38 commented Dec 11, 2017

My current usecase is to generate exercise solutions for algorithmic problems. Rather than write the algorithm in one language and hope that practitioners of other languages can understand it, I could generate five different versions of the algorithm and show them side-by-side. (I'm doing experimental work though to check whether it's even practical for me to generate algorithmic problems in the first place, so it's not as if there's anything for me to show.)

A secondary usecase that I see is, of course, porting algorithms from one language to another, but I'm not doing that right now.

Thanks for your help. If I need to use this tool in the future, would it be okay for me to fork this and do my own maintenance work?

@alehander92
Copy link
Collaborator

Algorithmic programming was one of the main ideas I had in mind

Do you generate the problems too, or you want to generate just their solutions?

Otherwise, I might take a look at how much work is to cleanup most builtin function errors this weekend.

It's MIT, you can do whatever you want with the source : ). If you get some progress, you can also take maintenanceship of the upstream project too

@tra38
Copy link
Author

tra38 commented Dec 13, 2017

Right now, I'm thinking of just generating solutions, and have the problems be hand-written. But it might actually be preferable to instead have problems be generated as well. I'll think about that for a bit...

Thanks for your support! You really built something wonderful and useful to the world. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants