How does one become a C operator?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parinaz
    New Member
    • Jan 2010
    • 5

    #1

    How does one become a C operator?

    I mean for example if I wanna make a new programmin language how to make a operator?
    if I write = what should I do to let my programming language know I mean what work?
    I can explain my question more if you want.
    thank you.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    It would be the language compilers responsibility to either compile the language syntax into the correct assembler for the platform (or if you were using gcc into intermediate code) for a compiled language or the interpreters responsibility to interpret the language syntax and perform the correct operation for an interpreted language.

    Comment

    • parinaz
      New Member
      • Jan 2010
      • 5

      #3
      hi thank you but if I want to add a new syntax and function for it what should I do?

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        It's your language you define the syntax and you define how it should be handled.

        Comment

        • parinaz
          New Member
          • Jan 2010
          • 5

          #5
          Idon't know how to add a syntax.for example if I type a syntax how to define it so that when the compiler see it,does the work I want.can I explain my problem clearly?:(

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            Hmmm, you initially said
            I mean for example if I wanna make a new programmin language how to make a operator?
            which appears to indicate that you are trying to write a completely new language (a fairly major feat in itself).

            However I am beinging to get the impression that may be you think you can add an operator to the C (or C++) language. If the later is the case then the simple answer is you can't add operators to languages, or rather that you probably shouldn't, in theory you could do something like get the source for a compiler and modify to include a new operator.

            In C you extend the language by adding functions. In C++ you could extend the language by adding functions but on the whole a better approach would be to add classes (object definitions). In C++ you can override most of the existing operators for your new classes should you wish, however you still can't create your own operator.

            If you really want to create your own language I would suggest that you start by reading the specifications of some existing languages. Also you should have a clear idea of what improvements your new language would provide over the language it is supposed to replace.

            If all you really want to do is implement some operator you perceive to be missing from C/C++ then write a function.

            Comment

            • weaknessforcats
              Recognized Expert Expert
              • Mar 2007
              • 9214

              #7
              Create a Backus-Naur chart for your language.

              You can use that to write your compiler.

              Comment

              • parinaz
                New Member
                • Jan 2010
                • 5

                #8
                I'm amateur in C .so what is Backus-Naur chart?:(

                Comment

                • Banfa
                  Recognized Expert Expert
                  • Feb 2006
                  • 9067

                  #9
                  Wikipedia has a good introduction.

                  Comment

                  Working...