Re: Managing custom words [Re: "Back & Forth" is back!]

Liste des GroupesRevenir à cl forth 
Sujet : Re: Managing custom words [Re: "Back & Forth" is back!]
De : mhx (at) *nospam* iae.nl (mhx)
Groupes : comp.lang.forth
Date : 02. Dec 2024, 21:40:25
Autres entêtes
Organisation : novaBBS
Message-ID : <cd465c66efca71557414235266b368ed@www.novabbs.com>
References : 1 2 3 4 5 6
User-Agent : Rocksolid Light
On Mon, 2 Dec 2024 18:14:14 +0000, Hans Bezemer wrote:
[..]
I've ported a couple of members from the FFL, but they're HUGE!
Over 600 lines for an XML library. For comparison: my 4tH preprocessor
is a 100 lines LESS!
Who cares. My program using the lib is only 60 lines long.
-marcel
(*
 * LANGUAGE    : ANS Forth with extensions
 * PROJECT     : Forth Environments
 * DESCRIPTION : Mag_Tool utility
 * CATEGORY    : Example
 * AUTHOR      : Marcel Hendrix
 * LAST CHANGE : May 28, 2019, Marcel Hendrix
 *)
NEEDS -miscutil
[UNDEFINED] -ffl [IF]  S" ffl/xis.fs" INCLUDED  [THEN]
REVISION -readxml "--- XML reader          Version 0.00 ---"
PRIVATES
DOC
(*
  Mag_Tool output files contain useful data between the tag
  <inductance> and the tag <Windings>.
*)
ENDDOC
-- Setup the reader callback word for reading from file
-- We know the Mag_Tool output files are > 100kbytes in size (no spaces)
:NONAME ( fileid -- c-addr u | 0 )
PAD #1024000 ROT READ-FILE ?FILE
DUP IF PAD SWAP  ENDIF ; =: file-reader PRIVATE
: DISPLAY-XML ( c-addr u -- )
0 LOCAL start?
0 LOCAL finished?
R/O OPEN-FILE ?FILE LOCAL handle \ Open the file
XIS-NEW LOCAL xis \ Create a XML input
                                                \ stream on the heap
handle file-reader xis XIS-SET-READER \ Use the xml reader
                                                \ with a file
TRUE xis XIS-STRIP! \ Strip leading and
                                                \ trailing whitespace
                                                \ in the text
\ parse the file
BEGIN
  xis XIS-READ \ Read the next token
      DUP XIS.ERROR <> OVER XIS.DONE <> AND \ Done when ready/error
WHILE
  DUP XIS.START-TAG
   = IF   2 PICK 2 PICK S" inductance"  COMPARE-NC
                    0= IF  TRUE TO start? CLEAR finished?   ENDIF
     2 PICK 2 PICK S" L_row"       COMPARE-NC
                    0= IF  TRUE TO start? CLEAR finished?   ENDIF
    2 PICK 2 PICK S" Windings"    COMPARE-NC
                    0= IF  CLEAR   start? TRUE TO finished? ENDIF
    2 PICK 2 PICK S" Layouts"     COMPARE-NC
                    0= IF  CLEAR   start? TRUE TO finished? ENDIF
  start? IF  >S CR 2DUP TYPE S>  ENDIF
   ELSE   DUP XIS.TEXT = finished? 0= AND ( print all text )
  IF  ."  = " >S 2DUP TYPE S>  ENDIF
  ENDIF
  XIS+REMOVE-READ-PARAMETERS \ remove the tokens
REPEAT
XIS.ERROR = IF  CR ." Error parsing the file."  ENDIF
handle CLOSE-FILE ?FILE
xis XIS-FREE ;
: do-job ( -- )
S~ MagApplication "Output.xml" out.xml~ SYSTEM
S" out.xml" DISPLAY-XML ;
:ABOUT CR .~ Try: S" out.xml" DISPLAY-XML~ ;

Date Sujet#  Auteur
18 Nov 24 * "Back & Forth" is back!22Hans Bezemer
19 Nov 24 +* Managing custom words [Re: "Back & Forth" is back!]19Buzz McCool
20 Nov 24 i+- Re: Managing custom words [Re: "Back & Forth" is back!]1albert
22 Nov 24 i`* Re: Managing custom words [Re: "Back & Forth" is back!]17Buzz McCool
22 Nov 24 i +* Re: Managing custom words [Re: "Back & Forth" is back!]2minforth
25 Nov 24 i i`- Re: Managing custom words [Re: "Back & Forth" is back!]1Buzz McCool
25 Nov 24 i `* Re: Managing custom words [Re: "Back & Forth" is back!]14dxf
25 Nov 24 i  +* Re: Managing custom words [Re: "Back & Forth" is back!]7mhx
2 Dec 24 i  i+* Re: Managing custom words [Re: "Back & Forth" is back!]5Hans Bezemer
2 Dec 24 i  ii+* Re: Managing custom words [Re: "Back & Forth" is back!]2mhx
3 Dec 24 i  iii`- Re: Managing custom words [Re: "Back & Forth" is back!]1Hans Bezemer
3 Dec 24 i  ii`* Re: Managing custom words [Re: "Back & Forth" is back!]2albert
3 Dec 24 i  ii `- Re: Managing custom words [Re: "Back & Forth" is back!]1Hans Bezemer
3 Dec 24 i  i`- Re: Managing custom words [Re: "Back & Forth" is back!]1albert
25 Nov 24 i  +* Re: Managing custom words [Re: "Back & Forth" is back!]5albert
25 Nov 24 i  i`* Re: Managing custom words [Re: "Back & Forth" is back!]4mhx
26 Nov 24 i  i `* Re: Managing custom words [Re: "Back & Forth" is back!]3albert
26 Nov 24 i  i  `* Re: Managing custom words [Re: "Back & Forth" is back!]2mhx
27 Nov 24 i  i   `- Re: Managing custom words [Re: "Back & Forth" is back!]1dxf
3 Dec 24 i  `- Re: Managing custom words [Re: "Back & Forth" is back!]1Hans Bezemer
21 Nov 24 +- Re: "Back & Forth" is back!1Stephen Pelc
22 Nov 24 `- Re: "Back & Forth" is back!1albert

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal