Ask Your Question
0

Custom terminal commands, self hosting compiler

asked 2015-02-05 11:46:44 -0600

SantoshHoropter gravatar image

How to create custom terminal command? I have a shell script in /usr/h which I created and exported path to $PATH variable. It has exec permission to user, group and others. How can I invoke it on terminal.

Next, I have made a small pair of lex and yacc programs that convert my language's source code to C source code. Has anyone got any idea on how to make my compiler self hosting?

edit retag flag offensive close merge delete

Comments

If I understand your question, you want to end up with a compiler that's written in the language it compiles. (To many people, a language that can't do that is considered to be nothing but a "toy language.") There's nothing wrong with using lex and/or yacc for that, but this isn't the right forum to discuss it in. I'm not closing the question, because I may have misunderstood you and there's always the chance that somebody can point you in the right direction. Good luck!

sideburns gravatar imagesideburns ( 2015-02-05 18:02:38 -0600 )edit

Thanks for your insight. Please close this question.

SantoshHoropter gravatar imageSantoshHoropter ( 2015-02-06 05:32:36 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-02-05 15:46:52 -0600

bforte gravatar image

What about instead of exporting its path to the $PATH variable adding an alias? I myself, don't like messing with the $PATH variable too much and (at least for little scripts I wrote) use an alias.

Just echo "alias FANCY_NAME="/usr/h/script.sh"" >> ~/.bashrc to add an alias, restart terminal and you're done.

Which compiler? GCC is self-hosting, I don't get what you mean. Do you mean your yourlanguage-compiler (which isn't a compiler since it's output is source code and not machine code)? If so why not just compile C code afterwards or write a little script to translate your code and compile it?

Anyway maybe this this helps.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-02-05 11:46:44 -0600

Seen: 391 times

Last updated: Feb 05 '15