954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

writing a simple programming language

Hi, i have two questions about making a c++ based programming language. the first: is there a c++ function or something that can separate text by commas and parenthesis, so if i wanted to write function foo with argument arg1 and arg2, i would need code to take foo(arg1,arg2) and make them separate strings? second question: how would i write the actual compiler? could i take a simple command line compiler source code and add a (really long) header with all of the new functions, wraps them to c++, and then compiles it?

mebob
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 1
 

This thread give some solutions for tokenizing strings: http://www.daniweb.com/forums/thread27905.html That's what you want to do in your first question. There are lots of ways to pull tokens out of strings.

Secondly, you want to study up on some lex and yacc, a lexical analyzer and a parser, respectively. http://luv.asn.au/overheads/lex_yacc/index.html

donaldw
Posting Whiz in Training
258 posts since Nov 2009
Reputation Points: 56
Solved Threads: 18
 

google cctype header. Its really useful.

firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
 

Thanks! ill need a little while to go through that a few times to understand the lex and yacc better :) but i understand the tokenizer, although i took a look at cctype and don't really understand it. and anyway, this was only an idea for a mod for a game called uplink, which you are a hacker. in the game, you have certain programs you can buy and use, but i though i could include my own language to program my own hacking programs in the game.

mebob
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You