Parsing text
-
How can I parse a complete text file to make it generate script ? ex : suppose that in the text file I have my own define script functions like PopMsg("Hello","Test Caption"); and a lot of other things . How can I parse all the text file to find : 1- the function declare (like PopMsg) 2- Check for the parameters ??? Thanks
-
How can I parse a complete text file to make it generate script ? ex : suppose that in the text file I have my own define script functions like PopMsg("Hello","Test Caption"); and a lot of other things . How can I parse all the text file to find : 1- the function declare (like PopMsg) 2- Check for the parameters ??? Thanks
first you would split into lines, identified by the ; char. then you would go over each line and determine what the line contains, once you know that you can invoke a different parser for each case (var declare, function, etc) Its a lot of work when you get into strings, which may contain chars which are part of your syntax, ;'s in strings have to be ignored, for example.
-
first you would split into lines, identified by the ; char. then you would go over each line and determine what the line contains, once you know that you can invoke a different parser for each case (var declare, function, etc) Its a lot of work when you get into strings, which may contain chars which are part of your syntax, ;'s in strings have to be ignored, for example.
-
How can I parse a complete text file to make it generate script ? ex : suppose that in the text file I have my own define script functions like PopMsg("Hello","Test Caption"); and a lot of other things . How can I parse all the text file to find : 1- the function declare (like PopMsg) 2- Check for the parameters ??? Thanks
Instead of writing your own script language, I would suggest employing the .NET script engine; according to the author it only supports VB and JScript.NET. Or you could load a C# source file into memory and then compile it with the C# compiler classes then load the resulting assembly with the
System.Reflection
classes. James "And we are all men; apart from the females." - Colin Davies -
Instead of writing your own script language, I would suggest employing the .NET script engine; according to the author it only supports VB and JScript.NET. Or you could load a C# source file into memory and then compile it with the C# compiler classes then load the resulting assembly with the
System.Reflection
classes. James "And we are all men; apart from the females." - Colin Davies -
Ok but do u have sample code, because i'm new to this and what you're told me is a little upper than me :)
The two articles I linked to cover the topics; for the second article it covers compiling code; but I'm not aware if it covers loading the compiled components and executing them. My article, Using reflection to extend .NET programs, covers how to load an arbitrary assembly and execute it by using an interface known to both the program and the 'script'. James "And we are all men; apart from the females." - Colin Davies