Menu

Fatal error executing: awk -f /opt/GCBASIC/preprocess.awk program1.2.3.gcb

bed
2020-04-02
2020-04-07
  • bed

    bed - 2020-04-02

    A special problem, maybe I am the only one who concern about it :-)
    Symptom: Source can not compiled:
    Fatal error executing:
    echo ' awk -f /opt/GCBASIC/preprocess.awk r1.1.gcb'
    awk -f /opt/GCBASIC/preprocess.awk r1.1.gcb
    exit

    After digging around a while I found the reason.
    The reason is that my source code has several dots "." in the file name.
    I noticed by chance.
    The error comes from the fact that makehex.sh can only handle one dot in the file name.
    I have adapted makehex accordingly and ask other Linux and MAC (?) users to try it.

    in makehex.sh begin with line 22

      # process any header files newer than current HEX file
      # ! There can be only one dot in the filename, or this will fail
      # out_name=$(basename "$1" | cut -d. -f1).hex # Note HEX suffix
      # this should work with more than 1 dots also
      out_name=$(basename "$1"|rev|cut -d. -f2-|rev).hex # Note HEX suffix
    
     

    Last edit: bed 2020-04-04
  • mkstevo

    mkstevo - 2020-04-03

    Hello.

    At some point, I had noticed this. A kind GCB member who understands the LINUX command line far better than I do, was helping me out in writing a script that extracted the #Chip directive in source code so that it could be passed to the NSDSP programmer when programming the device. When writing this script I came across this very problem and managed to remedy it, with a similar solution to yours.

    # ! There can be only one dot in the filename, or this will fail
    # hex_file=$(basename "${1}" | cut -d. -f1).hex
    # Changed as I sometimes have more than one dot in the filename
    
    hex_file=$(basename "$1" | rev | cut -d"." -f2-  | rev).hex
    
    # ! There can be only one dot in the filename, or this will fail
    # html_file=$(basename "${1}" | cut -d. -f1).html
    # Changed as I sometimes have more than one dot in the filename
    
    html_file=$(basename "$1" | rev | cut -d"." -f2-  | rev).html
    

    As for various reasons the 'awk' processes failed to work on the Mac, I have that section commented out any way.

     
    • Anobium

      Anobium - 2020-04-03

      An insight. The AWK is there to inspect for errors that the compiler did not/was not picking up and to ensure the libraries where valid.

      I will look to remove the AWK processing at the 0.98.08. I think that is possible.

      So, if you do not execute the AWK, today, what is the impact? You may get strange error messages relating to the following (as the AWK preprocessing issues proper messages):

      • Unmatched Braces
      • If - Else errors
      • Casting errors
      • Loops that are not terminated errors
      • Subs and Function that are not terminated errors



      All these errors are masked today. If someone wants to help move these checks into the compiler... please let us know.

      Evan

       
      • mkstevo

        mkstevo - 2020-04-07

        That's a question there...

        So, if you do not execute the AWK, today, what is the impact? You may get strange error messages relating to the following (as the AWK preprocessing issues proper messages):

        I am sure that in more recent macOS versions, AWK doesn't run correctly? Which is why I initially stopped using it...

        Unmatched Braces

        Tested, I get the error: CS_V2_11.gcb (956): Error: Brackets do not match up

        If - Else errors

        Tested, I get the error: CS_V2_11.gcb (972): Error: Else outside of If ... End If block
        Or: CS_V2_11.gcb (953): Error: If without matching End If

        Casting errors

        Untested

        Loops that are not terminated errors

        Tested, I get the error: CS_V2_11.gcb (1397): Error: Do without matching Loop
        Or: CS_V2_11.gcb (1420): Error: Loop without matching Do

        Subs and Function that are not terminated error

        Tested, I get the error: None, no error raised for Un-terminated Sub [Though looking at the .ASM it appears as though the sub did terminate normally?]

        When compiling this Sub with the "End Sub" commented out:

        Sub PrintAnimA
            Let D_Lat  = 0                'Start output data latch
            ShiftData(254) '-
            ShiftData(255) '
            ShiftData(255) '
            ShiftData(247) '-
            Let D_Lat  = 1                'End output data latch
        'End Sub
        

        The .ASM looks like this:

        PRINTANIMA
        ;Let D_Lat  = 0                'Start output data latch
            banksel LATC
            bcf LATC,4
        ;ShiftData(254) '-
            movlw   254
            banksel DATAOUT
            movwf   DATAOUT
            call    SHIFTDATA
        ;ShiftData(255) '
            movlw   255
            movwf   DATAOUT
            call    SHIFTDATA
        ;ShiftData(255) '
            movlw   255
            movwf   DATAOUT
            call    SHIFTDATA
        ;ShiftData(247) '-
            movlw   247
            movwf   DATAOUT
            call    SHIFTDATA
        ;Let D_Lat  = 1                'End output data latch
            banksel LATC
            bsf LATC,4
        ;End Sub
            banksel STATUS
            return
        

        Remove the commented out "'End Sub" completely and the .ASM looks like this:

        PRINTANIMA
        ;Let D_Lat  = 0                'Start output data latch
            banksel LATC
            bcf LATC,4
        ;ShiftData(254) '-
            movlw   254
            banksel DATAOUT
            movwf   DATAOUT
            call    SHIFTDATA
        ;ShiftData(255) '
            movlw   255
            movwf   DATAOUT
            call    SHIFTDATA
        ;ShiftData(255) '
            movlw   255
            movwf   DATAOUT
            call    SHIFTDATA
        ;ShiftData(247) '-
            movlw   247
            movwf   DATAOUT
            call    SHIFTDATA
        ;Let D_Lat  = 1                'End output data latch
            banksel LATC
            bsf LATC,4
            banksel STATUS
            return
        

        And with the "End Sub" included as normal I get:

        PRINTANIMA
        ;Let D_Lat  = 0                'Start output data latch
            banksel LATC
            bcf LATC,4
        ;ShiftData(254) '-
            movlw   254
            banksel DATAOUT
            movwf   DATAOUT
            call    SHIFTDATA
        ;ShiftData(255) '
            movlw   255
            movwf   DATAOUT
            call    SHIFTDATA
        ;ShiftData(255) '
            movlw   255
            movwf   DATAOUT
            call    SHIFTDATA
        ;ShiftData(247) '-
            movlw   247
            movwf   DATAOUT
            call    SHIFTDATA
        ;Let D_Lat  = 1                'End output data latch
            banksel LATC
            bsf LATC,4
            banksel STATUS
            return
        

        The only "Odd" errors I have had have been with my own "included" files. If I have made an error within one of my header files, the program fails to compile, throwing an unknown error:
        An error has been found: [With no further information shown]

        As I now know that this indicates an error in an "included" file, I know approximately where to look for this one.

         
        • mkstevo

          mkstevo - 2020-04-07

          Just spent a few hours returning the preprocessor options to the script. I did get the commands working to some degree. I have them reporting errors in the header files, though as I can't persuade the script to stop executing by the time the rest of the compilation has completed they are all but invisible, being way off the compiler output window.

          They still seem to not report where any error might be. Although they do if you scroll right to the top of the output window note an error of some sort in a header file. They still fail to make any note of any unterminated sub routines.

          I am far from an expert in shell scripting and I probably have not done things correctly, but I am struggling to see what, if anything, I've acheived?

           
    • bed

      bed - 2020-04-04

      In Linux build .. makehex.sh isn't html_file anaway.
      What does MAC do with it?

       
      • mkstevo

        mkstevo - 2020-04-07

        The script uses the "filename.html" file to extract the #Chip parameter from it on compile so that it can be passed to the command line of the NSDSP programmer

         
        • Anobium

          Anobium - 2020-04-07

          When we release 0.98.07 you may want to use the new compiler switch that outputs only the chipname and the config.

          Evan

           
          • mkstevo

            mkstevo - 2020-04-07

            But does that work in the macOS version, and it needs to be processed in a way that gives the result similar to:
            PIC16F1825

            From the #Chip 16F1829, 32 directive.

            This value then needs passing to the NSDSP programmer command line.

             
  • bed

    bed - 2020-04-04

    Ohh, My posted script has a typo $1 not $2 , sorry.
    My Script is ok. Wonder why here stands $1, I am a messy.
    (corrected in Post above)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.