Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys,

i am running a 'how to make a programming language' class at school and a friend asked me this one question. lets say in my programming language, to define a variable, you just put in 'string var = "Hello World"'. I am able to do that, but if i were to put in the code 'var = "Something else"', how am i able to do this. one of the ways that i thought of doing it is

if (a.Contains("="))
{

}


but the thing is, i don't know how to make it so that it can read before that equals sign. can you please help me? Thanks.
Posted

1 solution

Seriously? You have much, much bigger problems coming up that "read before the equals sign", and a specific solution to this one problem would not be a good investment of your time.

Look at the way other compilers, interpreters and so forth are written: most of them use a process called tokenisation[^] to identify the various parts of the input, and then parse the tokens for syntactical analysis.
I think it would probably be a good idea if you spent some time reading, before launching into code. This is a good start: Google: Writing a compiler[^]
 
Share this answer
 
Comments
Member 8378691 12-Dec-12 3:27am    
seriously? you are questioning me about making programming languages? i know about tokenisation, but i am writing this programming language a little differently because this is still a beginners class. for my scanning and tokenising is a foreach statement. so as you can see, it isn't so easy. if you really want to ask me about 'MY' programming languages, as in the ones that I write for myself, that is a different topic.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900