; $Header: /usr/local/cvs/www.xmeta.net/omlette/WebContent/doug/xompost.xom,v 1.1 2006/08/17 14:25:34 geimer Exp $ ; ; File Name: ; xompost.xom ; ; Syntax: ; omnimark | omle ; -s xompre.xom ; ; -of ; [-submit ]* ; -brief ; ; Description: ; This omnimark application post-processes the output of both the omnimark ; preprocessor and an Omnimark compilation to reconcile file names and line ; numbers and producing error and warning messages in a sinlge line format ; capable of being used by many programmers eiditors. ; ; The format of the warning/error messages is: ; filename(line number): [Error | Warning][Warning or Error number]: one line message ; ; $Author: geimer $ ; ; $Log: xompost.xom,v $ ; $Header: $ ; ; File Name: ; xompost.xom ; ; Syntax: ; omnimark | omle ; -s xompre.xom ; ; -of ; [-submit ]* ; -brief ; ; Description: ; This omnimark application post-processes the output of both the omnimark ; preprocessor and an Omnimark compilation to reconcile file names and line ; numbers and producing error and warning messages in a sinlge line format ; capable of being used by many programmers eiditors. ; ; The format of the warning/error messages is: ; filename(line number): [Error | Warning][Warning or Error number]: one line message ; ; $Author: $ ; ; Revision 1.1 2006/08/17 14:25:34 geimer ; $Header: $ ; ; File Name: ; xompost.xom ; ; Syntax: ; omnimark | omle ; -s xompre.xom ; ; -of ; [-submit ]* ; -brief ; ; Description: ; This omnimark application post-processes the output of both the omnimark ; preprocessor and an Omnimark compilation to reconcile file names and line ; numbers and producing error and warning messages in a sinlge line format ; capable of being used by many programmers eiditors. ; ; The format of the warning/error messages is: ; filename(line number): [Error | Warning][Warning or Error number]: one line message ; ; $Author: $ ; ; Moved omlette from xmeta.com to xmeta.net. ; $Header: $ ; ; File Name: ; xompost.xom ; ; Syntax: ; omnimark | omle ; -s xompre.xom ; ; -of ; [-submit ]* ; -brief ; ; Description: ; This omnimark application post-processes the output of both the omnimark ; preprocessor and an Omnimark compilation to reconcile file names and line ; numbers and producing error and warning messages in a sinlge line format ; capable of being used by many programmers eiditors. ; ; The format of the warning/error messages is: ; filename(line number): [Error | Warning][Warning or Error number]: one line message ; ; $Author: $ ; ; ; ;------------------------------------------------------------------------------- CROSS-TRANSLATE ;=============================================================================== ; static include files ;=============================================================================== INCLUDE "xomc.xin" ;=============================================================================== ; global variable declarations ;=============================================================================== GLOBAL STREAM sErrFile SIZE 1 GLOBAL STREAM sIFile SIZE 1 GLOBAL STREAM sCompilerMsgs VARIABLE INITIAL-SIZE 0 GLOBAL COUNTER ctActualLineNbr SIZE 1 INITIAL { 1 } GLOBAL COUNTER ctCurLineNbr SIZE 1 INITIAL { 0 } GLOBAL STREAM sCurFile SIZE 1 INITIAL { "" } GLOBAL STREAM gsProjectName SIZE 1 INITIAL { "" } ;=============================================================================== ; macros and functions ;=============================================================================== MACRO MSG_SEP IS "%187#" MACRO-END MACRO fi_Success IS 0 MACRO-END DEFINE ; @METAGS StoreCompilerErrorMessage FUNCTION StoreCompilerErrorMessage ( VALUE STREAM sFileName, VALUE STREAM sLineNbr, VALUE STREAM sErrorMsg, VALUE STREAM sErrorNbr OPTIONAL ) ;--------------------------------------------------------------------------- ; Description: ; this function outputs a formatted compiler error message as follows: ; filename(line_number):Error error_number:error_message ;--------------------------------------------------------------------------- AS ; local variable declarations ; function body DO WHEN sCompilerMsgs HAS KEY sLineNbr REOPEN sCompilerMsgs KEY sLineNbr AS BUFFER PUT sCompilerMsgs KEY sLineNbr MSG_SEP ELSE NEW sCompilerMsgs KEY sLineNbr OPEN sCompilerMsgs KEY sLineNbr AS BUFFER DONE USING OUTPUT AS sCompilerMsgs KEY sLineNbr DO OUTPUT "Error" OUTPUT "%s_" || sErrorNbr WHEN sErrorNbr IS SPECIFIED OUTPUT ": " || sErrorMsg DONE CLOSE sCompilerMsgs ;--------------------------------------------------------------------------- ; end of function StoreCompilerErrorMessage() ;--------------------------------------------------------------------------- DEFINE ; @METAGS StoreCompilerWarningMessage FUNCTION StoreCompilerWarningMessage ( VALUE STREAM sFileName, VALUE STREAM sLineNbr, VALUE STREAM sWarningMsg, VALUE STREAM sWarningNbr OPTIONAL ) ;--------------------------------------------------------------------------- ; Description: ; this function outputs a formatted compiler warning message as follows: ; filename(line_number):Warning warning_number:warning_message ;--------------------------------------------------------------------------- AS ; local variable declarations ; function body DO WHEN sCompilerMsgs HAS KEY sLineNbr REOPEN sCompilerMsgs KEY sLineNbr AS BUFFER PUT sCompilerMsgs KEY sLineNbr MSG_SEP ELSE NEW sCompilerMsgs KEY sLineNbr OPEN sCompilerMsgs KEY sLineNbr AS BUFFER DONE USING OUTPUT AS sCompilerMsgs KEY sLineNbr DO OUTPUT "Warning" OUTPUT "%s_" || sWarningNbr WHEN sWarningNbr IS SPECIFIED OUTPUT ": " || sWarningMsg DONE CLOSE sCompilerMsgs ;--------------------------------------------------------------------------- ; end of function StoreCompilerWarningMessage() ;--------------------------------------------------------------------------- DEFINE ; @METAGS GetStreamItemsFromString COUNTER ; OUT: status code FUNCTION GetStreamItemsFromString ( MODIFIABLE STREAM sTokens, VALUE STREAM sSrc, VALUE STREAM sTokenSepartors OPTIONAL INITIAL { " " } ) ;--------------------------------------------------------------------------- ; Function Name: ; GetStreamItemsFromString ; ; Description: ; gets individual "tokens" from a sStr, where "tokens" are separated by ; sTokenseparators and creates a new item on stream shelf sTokens for ; each found ; ; Arguments: ; sTokens multi-item stream shelf to hold found "tokens" ; sSrc string expression containing "tokens" ; sTokenSeparators an optional string expression containing one or more ; characters that delimit "tokens" within sStr. ; Defaults to a single space. ; ; Returns: ; if no errors occur, GetStreamItemsFromString returns 0. ; if any error occurs, GetStreamItemsFromString returns -1. ; ; History: ; NED 5/22/97 10:56AM initial version ;--------------------------------------------------------------------------- AS ; clear the shelf that will receive the tokens ; and create a single default item CLEAR sTokens NEW sTokens ; repeat over the string containing the tokens one character at a ; time. REPEAT SCAN sSrc MATCH ANY => ch ; test to see if the character matched is one of the token ; separators DO WHEN sTokenSepartors MATCHES UNANCHORED ch ; create a new item on the token shelf to receive ; text NEW sTokens ELSE ; append the character to the last item on the tkns ; shelf USING sTokens LASTMOST DO REOPEN sTokens AS BUFFER PUT sTokens ch CLOSE sTokens DONE DONE AGAIN ; everything went OK so return 0 RETURN fi_Success ;--------------------------------------------------------------------------- ; end of GetStreamItemsFromStream() ;--------------------------------------------------------------------------- DEFINE ; @METAGS OutputCompilerMsg FUNCTION OutputCompilerMsg ( VALUE COUNTER ctMsgLineNbr, VALUE STREAM sFile, VALUE COUNTER ctFileLineNbr ) ;--------------------------------------------------------------------------- ; Description: ; ;--------------------------------------------------------------------------- AS ; local variable declarations LOCAL STREAM sMsgs VARIABLE INITIAL-SIZE 0 LOCAL COUNTER nRetVal SIZE 1 ; function body SET nRetVal TO GetStreamItemsFromString(sMsgs, sCompilerMsgs KEY "%d(ctMsgLineNbr)", MSG_SEP) REPEAT OVER sMsgs OUTPUT sFile || "(%d(ctFileLineNbr)): " || sMsgs || "%n" AGAIN ;--------------------------------------------------------------------------- ; end of function OutputCompilerMsg() ;--------------------------------------------------------------------------- FIND-START PUT #ERROR "compiling " || gsProjectName || " ...%n" USING GROUP FindErrors SUBMIT FILE sErrFile USING GROUP ReconcileErrorLines SUBMIT FILE sIFile HALT WITH gnExitVal ;=============================================================================== GROUP FindErrors ;=============================================================================== FIND ; error message1 ;--------------------------------------------------------------------------- ; Description ; matches an omnimark error message with a line number specified ;--------------------------------------------------------------------------- ; start of pattern "omnimark --" WHITE-SPACE* "OmniMark Error on line " DIGIT+ => ErrLineNbr " in file " [ ANY EXCEPT ":" ]+ => FileName ":" WHITE-SPACE* ANY-TEXT+ => ErrMsg1 WHITE-SPACE* [ ANY-TEXT EXCEPT "." ]+ => ErrMsg2_1 WHITE-SPACE* ([ ANY-TEXT EXCEPT "." ]* "." ) => ErrMsg2_2 ; end of pattern StoreCompilerErrorMessage(FileName, ErrLineNbr, ErrMsg1 || "%s_" || ErrMsg2_1 || "%s_" || ErrMsg2_2) ;--------------------------------------------------------------------------- ; end of rule ;--------------------------------------------------------------------------- FIND ; warning message1 ;--------------------------------------------------------------------------- ; Description ; matches an omnimark warning message with a line number specified ;--------------------------------------------------------------------------- ; start of pattern "omnimark --" WHITE-SPACE* "OmniMark Warning on line " DIGIT+ => ErrLineNbr " in file " [ ANY EXCEPT ":" ]+ => FileName ":" WHITE-SPACE* ANY-TEXT+ => ErrMsg1 WHITE-SPACE* [ ANY-TEXT EXCEPT "." ]+ => ErrMsg2_1 WHITE-SPACE* ([ ANY-TEXT EXCEPT "." ]* "." ) => ErrMsg2_2 ; end of pattern StoreCompilerWarningMessage(FileName, ErrLineNbr, ErrMsg1 || "%s_" || ErrMsg2_1 || "%s_" || ErrMsg2_2) ;--------------------------------------------------------------------------- ; end of rule ;--------------------------------------------------------------------------- FIND ; error message2 ;--------------------------------------------------------------------------- ; Description ; matches an omnimark error message with a line number specified ;--------------------------------------------------------------------------- ; start of pattern "omnimark --" WHITE-SPACE* "OmniMark Error:" WHITE-SPACE* ANY-TEXT+ => ErrMsg1 WHITE-SPACE* ANY-TEXT+ => ErrMsg2 ; end of pattern StoreCompilerErrorMessage(sIFile, "1", ErrMsg1 || "%s_" || ErrMsg2) ;--------------------------------------------------------------------------- ; end of rule ;--------------------------------------------------------------------------- FIND ; warning message2 ;--------------------------------------------------------------------------- ; Description ; matches an omnimark warning message with a line number specified ;--------------------------------------------------------------------------- ; start of pattern "omnimark --" WHITE-SPACE* "OmniMark Warning:" WHITE-SPACE* ANY-TEXT+ => ErrMsg1 WHITE-SPACE* ANY-TEXT+ => ErrMsg2 ; end of pattern StoreCompilerWarningMessage(sIFile, "1", ErrMsg1 || "%s_" || ErrMsg2) ;--------------------------------------------------------------------------- ; end of rule ;--------------------------------------------------------------------------- ;=============================================================================== GROUP ReconcileErrorLines ;=============================================================================== FIND ;--------------------------------------------------------------------------- ; Description: ; ;--------------------------------------------------------------------------- ; start of pattern LINE-START BLANK* LINE-END "%n" ; end of pattern ; local variable declarations ; rule body INCREMENT ctActualLineNbr INCREMENT ctCurLineNbr ;--------------------------------------------------------------------------- ; end of rule ;--------------------------------------------------------------------------- FIND ;--------------------------------------------------------------------------- ; Description: ; ;--------------------------------------------------------------------------- ; start of pattern (LINE-START ANY-TEXT+ LINE-END "%n") => LineOfText ; end of pattern ; local variable declarations ; rule body USING GROUP ProcessLine SUBMIT LineOfText DO WHEN sCompilerMsgs HAS KEY "%d(ctActualLineNbr)" OutputCompilerMsg(ctActualLineNbr, sCurFile, ctCurLineNbr) DONE INCREMENT ctActualLineNbr LASTMOST ;--------------------------------------------------------------------------- ; end of rule ;--------------------------------------------------------------------------- ;=============================================================================== GROUP ProcessLine ;=============================================================================== FIND ;--------------------------------------------------------------------------- ; Description: ; ;--------------------------------------------------------------------------- ; start of pattern ( ";#line " DIGIT+ => NewLineNbr ", " ANY-TEXT+ => NewFileName ANY* ) => MatchedText ; end of pattern ; local variable declarations ; body of rule SET ctCurLineNbr TO +(NewLineNbr) - 1 SET sCurFile TO NewFileName ;--------------------------------------------------------------------------- ; end of rule ;--------------------------------------------------------------------------- FIND ;--------------------------------------------------------------------------- ; Description: ; ;--------------------------------------------------------------------------- ; start of pattern ANY+ => ch ; end of pattern ; local variable declarations ; body of rule INCREMENT ctCurLineNbr ;--------------------------------------------------------------------------- ; end of rule ;--------------------------------------------------------------------------- ;=============================================================================== GROUP #IMPLIED ;=============================================================================== FIND ; discard rest ;--------------------------------------------------------------------------- ; Description ; matches and removes the rest of the input file ;--------------------------------------------------------------------------- ; start of pattern ANY => ch ; end of pattern ;--------------------------------------------------------------------------- ; end of rule ;---------------------------------------------------------------------------