That is one way to learn :).
Paul Clapham wrote:So in other words, first you decided to use a StringBuilder as a data structure to store some data, and now you're having trouble getting data back out of that data structure? That's because String and StringBuilder are really poor choices for storing structured data. As you are now finding out. So stop and choose some more suitable data structure.
Any suggestions on what data structures i should use to achieve what i need Paul?
2. if the input contains certain strings(i call them references), for example something like "AGE_Y" or "PROPERTY_LENGTH" (there are a lot of these also) , i grab the first occurrence of each of these and turn it into a variable to which i will add some extra code(in order for it to be read by another application) and insert it right above where it first appeared in the text. i'll post a clearer example lower.
3. once i created those variables i will replace all the occurrences of the references with the name of the variable
Now up to this point i''ve managed to do this properly, except that the insertion goes wonky, and that's why i need to do what i described in the above post. For example if i find x=PROPERTY_LENGTH; as the first occurrence of the reference , i already know the index of PROPERTY_LENGTH and of the = sign closest to it(made a method to help out with that), but i need to grab the value in front of the "=" sign in order to properly insert the newly created variable. for example , if it was in a list and the index of "=" would be , a variable called "index", i would do something like: which would grab me string "x"(who's length can obviously vary) , and after that i would simply do a
oh and for a clearer example of a string: this is a very simple example, but an accurate one.
This is a very high-level, oversimplified picture, but the key point is, you can't just say, "find the ==s and ifs in the string...".
but at the moment that is what i am struggling with .
a very high-level, oversimplified picture
@Pat: sorry, but what exactly do you mean by undergraduate CS program? Also , i will start looking into domain specific language so thanks.
Daniel Vlad wrote:@Pat: sorry, but what exactly do you mean by undergraduate CS program? Also , i will start looking into domain specific language so thanks.
Undergraduate Computer Science program. The "science" of computers as taught in a four year college to 18-22 year olds. At least that is typical in the US.
Parsers and compilers are a critical part of any complete CS program, because (1) they are fundamental to so many things we do and (2) the require a full understanding of programming and data structures.
However, these are not "beginning" topics. They are usually taught in the 3rd or 4th year of a four year program.
A course in compilers is also typically required for a MS-CS (Master of Science, Computer Science) in many US universities.
I'm not sure if you're interested in doing the whole thing yourself as an academic exercise, or if you just want the final result for practical use, or somewhere in between, so you'll have to investigate to see which of those tools are useful to you.
Additionally, you may want to look into Scala. It's a programming language that supports most or all of Java's syntax, and gets compiled to Java bytecodes that can run in JVM. It has additional syntactical features that are supposed to make it good for developing domain-specific languages, though I haven't actually done this myself, so I can't comment on this feature.