Python Forum

Full Version: help in creating a new language with python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i am creating my own programming language (the name is codime) interpreter\compiler with python,but every time i want to compile\interpret my script written in my language,i need to go to cmd and key in

first,the directory.
then,run it like this:
python test.py test.codime

test.py(the interpreter create with python)
test.codime(stuff written in my language)

1)how to make it run by just clicking a run button in a text editor instead of needing to go the cmd and write the above comment line  again and again to run it?

2)how do i make it so that the interpreter that i am creating can only interpret file that have the .codime file extension?(like python can only compile file with  .py   extension.

i am a beginner, so please make the answer as detailed as possible  Smile ,but not too long word ,if possible.  Big Grin
thanks......
(Dec-19-2016, 04:45 AM)hsunteik Wrote: [ -> ](like python can only compile file with  .py   extension.
who says that python can only compile a file with .py extension?
Normally, I will open a terminal, navigate to the directory I want, type in my program to run it the first time. After that, I just use the term's 'history' by hitting the up-arrow key and then enter.  Saves a little bit of typing.
(Dec-19-2016, 01:41 PM)sparkz_alot Wrote: [ -> ]Normally, I will open a terminal, navigate to the directory I want, type in my program to run it the first time. After that, I just use the term's 'history' by hitting the up-arrow key and then enter.  Saves a little bit of typing.
dont you think clicking a button from the text editor is easier than going to cmd and run it.

(Dec-19-2016, 09:41 AM)Skaperen Wrote: [ -> ]
(Dec-19-2016, 04:45 AM)hsunteik Wrote: [ -> ](like python can only compile file with  .py   extension.
who says that python can only compile a file with .py extension?
Does that mean that  python can also compile filename with( the( .txt) ,( .js ) ,(.c) ,( .class) ,( .jar)  and any other text file extension.)
i dont think so. Dance Naughty Big Grin
(Dec-20-2016, 06:33 AM)hsunteik Wrote: [ -> ]
(Dec-19-2016, 09:41 AM)Skaperen Wrote: [ -> ]who says that python can only compile a file with .py extension?
Does that mean that  python can also compile filename with( the( .txt) ,( .js ) ,(.c) ,( .class) ,( .jar)  and any other text file extension.)
i dont think so. Dance Naughty Big Grin

Only the actual file contents count.... the file extension is a mere convention. People tend to stick to it because it is useful but it is in no way mandatory.
Quote:dont you think clicking a button from the text editor is easier than going to cmd and run it.

Not really.  Your plain 'vanilla' text editors don't run scripts, nor are they meant to. More advanced editors can (such as Notepad++), but require a bit of work to set up.  Personally, I use PyCharm Community Edition (though there are several equally good IDE's) to write my scripts. This allows me to write and run the script from within the same environment the majority of the time.  A good place to start is here: Python IDE's.
Quote:dont you think clicking a button from the text editor is easier than going to cmd and run it.
Nope. Once you start using the terminal, GUI is dreadfully slow and laggy. For everything in GUI there is a comparison in terminal. Terminal torrent clients, terminal browsers, Vim editor (which is what i use), and on and on. 

When i code, i popup a terminal, navigate to my files, open tmux to split the terminal, and in one i open in Vim, and the other split terminal i set aside for execution. Now every time i use an IDE i cant stand the slow loading and lag of the GUI. 

This is the same reason i avoid Windows like the plague. Because they prefer GUI over terminal (not the only reason). And sometimes you can really tell, and sometimes you can only tell when you have a linux box side by side a windows, you are already jumping into your program while Windows is still loading. 

Some linux users dont even install a display manager. Their whole computer is just a terminal. If your not programming something that requires a GUI (such as a visual game) you dont even need a display manager either.
Thanks for the answer,especially the one from ofnuts.
(Dec-20-2016, 03:12 PM)metulbur Wrote: [ -> ]Some linux users dont even install a display manager. Their whole computer is just a terminal. If your not programming something that requires a GUI (such as a visual game) you dont even need a display manager either.

Looks like kate for cavemen :)

[attachment=100]
i use to use kate 5 years ago or so. Most IDE/text editors have an embedded terminal option...or plugin. But i meant the sole fact of reducing GUI programs completely. Although from what i remember i never had a problem with kate. Though ive had laggy programs in linux, i was more referring to windows.