Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Parsing text

Parsing text

Scheduled Pinned Locked Moved C#
questiontoolsjson
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BLaZiNiX
    wrote on last edited by
    #1

    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

    C J 2 Replies Last reply
    0
    • B BLaZiNiX

      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

      C Offline
      C Offline
      Christopher Lord
      wrote on last edited by
      #2

      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.

      B 1 Reply Last reply
      0
      • C Christopher Lord

        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.

        B Offline
        B Offline
        BLaZiNiX
        wrote on last edited by
        #3

        do u have sample code please ?

        1 Reply Last reply
        0
        • B BLaZiNiX

          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

          J Offline
          J Offline
          James T Johnson
          wrote on last edited by
          #4

          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

          B 1 Reply Last reply
          0
          • J James T Johnson

            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

            B Offline
            B Offline
            BLaZiNiX
            wrote on last edited by
            #5

            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 :)

            J 1 Reply Last reply
            0
            • B BLaZiNiX

              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 :)

              J Offline
              J Offline
              James T Johnson
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups