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. A New Language In C#

A New Language In C#

Scheduled Pinned Locked Moved C#
csharphelpquestion
8 Posts 6 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.
  • J Offline
    J Offline
    jas0n23
    wrote on last edited by
    #1

    Hi All, I was wondering if it would at all be possible to create my own very small and simple programming language using C# Express Edition? And how one might go about doing so? I'd appreciate any help I can get on this. Thanks in advance :-) j.t.

    j.t.

    M P R P G 5 Replies Last reply
    0
    • J jas0n23

      Hi All, I was wondering if it would at all be possible to create my own very small and simple programming language using C# Express Edition? And how one might go about doing so? I'd appreciate any help I can get on this. Thanks in advance :-) j.t.

      j.t.

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      Basically you will need to learn assembly language i.e. how an executable is created Then you would need to parse you language and produce your assembly code based on the parsed values Quite a simple theory really :P

      If only MySelf.Visible was more than just a getter... A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting

      1 Reply Last reply
      0
      • J jas0n23

        Hi All, I was wondering if it would at all be possible to create my own very small and simple programming language using C# Express Edition? And how one might go about doing so? I'd appreciate any help I can get on this. Thanks in advance :-) j.t.

        j.t.

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        You could always take a look at developing a DLR language (Dynamic Language Runtime). Take a look here[^] for a marketing type overview, and here[^] for more detail.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        My blog | My articles | MoXAML PowerToys

        1 Reply Last reply
        0
        • J jas0n23

          Hi All, I was wondering if it would at all be possible to create my own very small and simple programming language using C# Express Edition? And how one might go about doing so? I'd appreciate any help I can get on this. Thanks in advance :-) j.t.

          j.t.

          R Offline
          R Offline
          riced
          wrote on last edited by
          #4

          What you will need to do is create a program that will take in source code and emit object code. The source code will be written in your language; the object code be targeted at some machine. So it will either be machine code, aimed at a particular CPU, or byte code that runs on some virtual machine (e.g. the CLR in .Net or Java in a JVM). Effectively this means you have to write a compiler (or interpreter) in C#. This is not a trivial task. You might try looking at this book: Compilers: Principles, Techniques, and Tools Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman Addison-Wesley Pub Co ISBN: 0201100886 Regards David R

          P 1 Reply Last reply
          0
          • R riced

            What you will need to do is create a program that will take in source code and emit object code. The source code will be written in your language; the object code be targeted at some machine. So it will either be machine code, aimed at a particular CPU, or byte code that runs on some virtual machine (e.g. the CLR in .Net or Java in a JVM). Effectively this means you have to write a compiler (or interpreter) in C#. This is not a trivial task. You might try looking at this book: Compilers: Principles, Techniques, and Tools Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman Addison-Wesley Pub Co ISBN: 0201100886 Regards David R

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Or it could be an interpreted language and maybe not general-purpose.

            1 Reply Last reply
            0
            • J jas0n23

              Hi All, I was wondering if it would at all be possible to create my own very small and simple programming language using C# Express Edition? And how one might go about doing so? I'd appreciate any help I can get on this. Thanks in advance :-) j.t.

              j.t.

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Possible, yes. I've written a very simple interpreted scripting language for a very specific purpose; automating a telnet session. Do you have a particular need? Or just a curiosity? See also this[^] article.

              J 1 Reply Last reply
              0
              • J jas0n23

                Hi All, I was wondering if it would at all be possible to create my own very small and simple programming language using C# Express Edition? And how one might go about doing so? I'd appreciate any help I can get on this. Thanks in advance :-) j.t.

                j.t.

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                I took a few minutes and made a programming language. Create a console application (named GuffaProgrammingLanguage of course), and put this in the Main method:

                static void Main(string[] args) {
                foreach (string line in File.ReadAllLines(args[0]+".gpl")) {
                switch (line.Substring(0,Math.Min(line.Length,4))) {
                case "out ": Console.WriteLine(line.Substring(4)); break;
                case "time": Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); break;
                case "end.": return;
                default: Console.WriteLine("Syntax error."); return;
                }
                }
                }

                Create a text file in the bin folder named test.gpl with this content:

                out Hello
                out World!
                time
                end.

                Open a console window and go to the bin folder, start the program with GuffaProgrammingLanguage test and you get an amazing result like this:

                Hello
                World!
                2009-02-11 18:48:49

                :)

                Despite everything, the person most likely to be fooling you next is yourself.

                1 Reply Last reply
                0
                • P PIEBALDconsult

                  Possible, yes. I've written a very simple interpreted scripting language for a very specific purpose; automating a telnet session. Do you have a particular need? Or just a curiosity? See also this[^] article.

                  J Offline
                  J Offline
                  jas0n23
                  wrote on last edited by
                  #8

                  Well, it's just out of plain curiosity and wanting to learn that's all. :-)

                  foreach( inch on Jason ) { Girlfriend.IsHappier(); }

                  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