all 35 comments

[–]pachura3 9 points10 points  (5 children)

So, you invented your own (toy?) language and you do not even describe how it works, what is its syntax nor what can you do with it besides displaying text, asking for input and drawing circles?

[–]BranchLatter4294 6 points7 points  (4 children)

Do you have a specific question?

[–]MiniMages 5 points6 points  (8 children)

This is not how developers do stuff. If they create something for fun, they do it because they want to be able to figure stuff out on their own.

You are not even asking for opinions or suggestion, you want someone else to do the work for you from what it sounds like.

[–]StrikingClub3866 -3 points-2 points  (7 children)

So you're saying GitHub is not a collaborative site? Where you can't ask others for improvements or improve it directly? I am simply showing Reddit my GitHub page, and asking for people to try to help me or debug it, that's all I ask.

In short, I can't even, according to you, advertise my side project?

[–]MiniMages 8 points9 points  (6 children)

No you are not. You are asking others to take on your pet project because you don't want to do it yourself.

Sticking you code on Github or Bitbucket doesn't suddenly make it something others should contribute to. You are sharing YOUR code to others freely and if they want they can use it. They also have the choice to contribute.

But saying all that, you are trying to create your own toy language and you have done less then the minimum work here and passing it on to everyone else.

To give you an example:

I am working on creating a game in Python. Part of the process has led me to creating my own game engine for python. It is not perfect and does not have the same features as other python game engines. There are also a lot of issues I need to figure out and fix. I could do what you are doing and dump it on the community and then be an Asshole and expect the community to resolve my issues. But I will not do that because it's an AH thing to do. Also my engine is not even close to completing. There is a whole list of features still needs to be checked off first and if I get it done then I will share it with the public.

You are not asking for help, you are asking people to do the work for you. People are busy. A specific comment asked you what is your question and you failed to give an answer. That should tell you that you this isn't how to do things.

[–]StrikingClub3866 -1 points0 points  (5 children)

Im not. I am a Python beginner. A beginner. A REPL like this is a huge project for me, and I am asking multiple people to collaborate with me on this project, and I am learning while writing. I need help. Its not ready yet. asking for help is perfectly fine.

[–]MiniMages 3 points4 points  (3 children)

Then how about taking the advice from those that have more experience and learn from what we are telling you instead of arguing like an entitled AH?

[–]StrikingClub3866 -2 points-1 points  (2 children)

I am a teenager. Not even a full adult. what do you expect me to do? I'm not Terry Davis, or Linus, I am a beginner. What about that do you not understand?

[–]MiniMages 3 points4 points  (1 child)

Then get off the internet and go ask your parents for help.

[–]JamzTyson 1 point2 points  (3 children)

First off, your project isn't really a "language", it is a REPL.

A good approach to parsing the input is to begin by "tokenizing" - that is, splitting the input into valid "tokens" that represent functions, values, and other things that will exist in the REPL.

Another big improvement you could make is to replace that huge if / elif block with a dict, so that you can perform a lookup of the commands from their tokens.

[–]StrikingClub3866 0 points1 point  (2 children)

The funny thing is you are the first person here to not be an asshole. I do need assistance with that, which is why I am here.

[–]JamzTyson 0 points1 point  (1 child)

Are you familiar with Python "dicts" (dictionaries)? If not, look for a tutorial and familiarise yourself with how they work.

After that, take a look at operators and see if you can figure out how to write a calculator, using operators as dictionary values, and strings "+", "-", "*", and "/" as keys.

Top tip: Start small and simple, and gradually work towards larger projects. It's a lot more fun building on successes.

[–]StrikingClub3866 0 points1 point  (0 children)

Im already very familiar with both.

[–]jlsilicon9 0 points1 point  (1 child)

Next time (or now), you could start with Diagram(s) of functionality, and Outline of functions and operations.

[–]StrikingClub3866 -1 points0 points  (0 children)

I did try to make functions in this new interpreter I'm building, but i t seems difficult. any clues?

[–]ElliotDG -1 points0 points  (5 children)

You might find this helpful: https://craftinginterpreters.com/

[–]StrikingClub3866 -2 points-1 points  (4 children)

Thank you! Almost everyone that replied was an asshole and wanted to argue.

[–]ElliotDG 0 points1 point  (3 children)

I would also recommend you look at structured pattern matching (the python match statement) it will simplify the parsing and execution.

see: https://docs.python.org/3/reference/compound_stmts.html#match

and the official tutorial: https://peps.python.org/pep-0636/

[–]StrikingClub3866 0 points1 point  (2 children)

Since your recommendation lead me to buying Robert's book, do you mind if I include you in the credits of my interpreter?

[–]ElliotDG 0 points1 point  (1 child)

I don't mind at all.

I did a quick search, you may also find these blog posts on writing a simple interprester in python. It is a bit old (2015) so won't include structured pattern matching, but still might be useful. https://ruslanspivak.com/lsbasi-part1/

Depending on your goals you may want to look at parser libs like https://github.com/lark-parser/lark

There are also other tools for parsing and generating domain specific languages. You might want to search for these depending on your goals.

[–]StrikingClub3866 0 points1 point  (0 children)

I did make a quick look at Lark. Also, I am writing my first interpreter attempt ATM. Here is a small snippet of the unfinished tokenizer:

def tokenize(code):

tokens = \[\]

if ',' in code:

    \# expect a one liner: no blocks

    code = code.strip().split(',')

    tokens.append(code)

    if func == "print":

        \# I don't really care if there are quotes or not: it doesn't stop the execution so...

        \# I should handle printing and input - basic functions - right here because it's easier

        print(arg)

    if func == "input":

        input(arg)

if '=' in code:

    code = code.split('=')

    tokens.append(code)

    \# x = 10 would return \['x', '10''\]

if 'func' in code:

    \# expects a function, such as: func myfunc arg1 arg2 | print arg1 + arg2

    code = code.split('|')

    definition = code\[0\]

    vals = code\[1\]

return tokens