Announcement

Collapse
No announcement yet.

Wanted: C to PB Header file translator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wanted: C to PB Header file translator

    Anyone know of such ac ritter?

    I have one that is 14,459 lines long...
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Dacorbi Pattern Search

    Take a look at Dacorbi Pattern Search (at www.dacorbi.com ). It should be an ideal tool for such a task. It comes with a starter Delphi to BASIC converter module. If you examine the patterns for that one, you should be able to do something like it for translating a C header to PB. If I could see a sample of your original C header code, I might be able to get you started.
    Daniel Corbier
    uCalc Fast Math Parser
    uCalc Language Builder
    sigpic

    Comment


    • #3
      I believe that would be José Roca

      James

      Comment


      • #4
        It's old but it's a start...
        Win 32: Use REGEXPR to convert ".h" and .".rc" files into PB ".bi" files with equates March 05, 2000

        (Ok, so that's the easy stuff. What did you expect of me then? I was new!)
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Here's a Dacorbi Pattern solution

          This should be very easy to do with Dacorbi Pattern Search. Let me show you how. Let me start with a before/after shot of a sample header, which you'll see to the right (the after shot is obtained by pressing Replace All):

          Before


          After


          There is no need to write complicated parsing code. Dacorbi Pattern Search handles that part for you. All you have to do is create a series of Search / Replace rules using Dacorbi Patterns (you can then save it for further use). Basically, you tell it:
          • When you find something like 0xFFFF change it to &HFFFF
          • When you find something like #define Add(a, b) a+b, change it to Macro Add(a, b) = a + b
          • etc.


          The rules all works concurrently. Here, I have just 8 rules, and you can see just one of them in the screenshot. You will want to gradually add to it (community project anyone?). Here is the list of all 8 rules in this example: (they all have the "Pass Once" box checkmarked; also some lines have a carriage return in the Replace box, but you can't see it in the representation below):

          ---------------- Pattern 1 of 8 ----------------

          Find
          const {ConstantName} = {Value};

          Replace With
          %{ConstantName} = {Value}

          ---------------- Pattern 2 of 8 ----------------

          Find
          const {DataType} {ConstantName} = {Value};

          Replace With
          macro {ConstantName} = {Value}

          ---------------- Pattern 3 of 8 ----------------

          Find
          //

          Replace With
          '

          ---------------- Pattern 4 of 8 ----------------

          Find
          /* {Comment} */

          Replace With

          ---------------- Pattern 5 of 8 ----------------

          Find
          #define {Constant} {"\r\n"}

          Replace With
          %{Constant} = 1

          ---------------- Pattern 6 of 8 ----------------

          Find
          #define {MacroName} {Value} {"\r\n"}

          Replace With
          Macro {MacroName} = {Value}

          ---------------- Pattern 7 of 8 ----------------

          Find
          #define {MacroName}({Params}) {Value} {"\r\n"}

          Replace With
          Macro {MacroName}({Params}) = {Value}

          ---------------- Pattern 8 of 8 ----------------

          Find
          {HexPrefix:"0x"}{HexNumber:"[0-9A-F]+"}

          Replace With
          &H{HexNumber}
          Daniel Corbier
          uCalc Fast Math Parser
          uCalc Language Builder
          sigpic

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎