help with getting macros
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2012 at 18:16, xxxxxxxx wrote:
I have been programming for a little over two years, and have learned very quickly. I'm now trying to make a language called jade (.jd) and decided to start with macros. the syntax is:
MACRO: command replacement textso lets say i had break but wanted to make it shorter
MACRO: break brkthe only problem is my code doesn't work right. can someone please explain?
heres my code
def replaceMacros(file) : while file.readline() : line = file.readline() if line[0:6] == "MACRO:": startCommand = line.find(" ") endCommand = line.end(" ", startCommand + 1) command = line[startCommand + 1 : endCommand] print command macro = line[endCommand + 1:] print macro
*Note: I know macros are meant to replace what they stand for, but right now im just trying to make sure its reading in the correct values right. once it is ill have it put in a global (scope wise) dictionary called macroList. where macroList[macro] = command
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2012 at 19:26, xxxxxxxx wrote:
why so super complicated , why don't you just convert the input file into a token
stream and then parse this stream step by step. string.split() has been made for this.myString = "cmdToken,valToken,cmdToken,valToken" stream= string.split(myString,",") for token in stream: print token
on the other hand i do not really understand why you do not use just a multipurpose
file format which is already there like pythons JSON or c4ds own hyperfile.on top of that, without wanting to sound harsh (i am still a kind of beginner myself),
i do not think that you are up to writing a script language, when you cannnot even
handle some string pushing.just my 2 cents, no offense.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2012 at 19:53, xxxxxxxx wrote:
im up to it, i just dont neccesarily know every feature of a language
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2012 at 19:54, xxxxxxxx wrote:
and how am i supposed to read that in as a file line and see if the line is a "MACRO:"
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2012 at 20:00, xxxxxxxx wrote:
and once again another problem. how do i keep it from printing MACRO:? and how do i turn each iteration into a dictionary
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2012 at 20:13, xxxxxxxx wrote:
Originally posted by xxxxxxxx
and how am i supposed to read that in as a file line and see if the line is a "MACRO:"
its part of the token design idea, you first sort the input and then you can look if it
makes any sense. this way you can also implement some kind of grammar. you can also
parse forwards, backwards or by importance this way. or to be more specific macro would
be a 'command token' in your case, telling your parser that after this token tokens to be
executed will follow.and to the whole 'i don't have to...' thing , i have written 3 or 4 years ago a function
parser in C# at a overall coding bgeinner state and intermediate c# knowledge and it has
been pretty hard for me. writing a scripting language is more or less the same i guess,
only that it is much harderif you really think, you are up to this you should read something like this (at least this has
been the pasing method i used, not sure if you can use this also for a script language, but i
guess you can) : -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2012 at 20:13, xxxxxxxx wrote:
Originally posted by xxxxxxxx
and once again another problem. how do i keep it from printing MACRO:? and how do i turn each iteration into a dictionary
split returns a list.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2012 at 22:27, xxxxxxxx wrote:
Hi jadeDeveloper,
your question is not related to the Cinema 4D API at all. A better
place to ask this question would be a general programming
forum or a site like StackOverflow.Please also note, that you can edit a post once you have
posted it. You do not have to do three posts in a row.Best,
Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/12/2012 at 16:31, xxxxxxxx wrote:
*this is an honest question not a sarcastic remark* where does it say that this is for cinema 4d api?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/12/2012 at 16:34, xxxxxxxx wrote:
subforum description says :
Discussion about PYTHON for CINEMA 4D