Because the game doesn't check the characters being inserted in the name the grammar of
the logfile is not correct and not parseable thru a left to right parser. (not with 
this
'parse function).

This works fine if the plater does not have a name with the string {>"}

r-tag: [ ">" thru "<" ]
parse line [
    thru {"} copy name thru {>"}
    (
        ; parse the name in reverse.
        reverse name
        parse name [
            {"}
            copy won r-tag
            copy num r-tag
            copy name to end
            (reverse name reverse won reverse num)
        ]
    ) to end
]

You can add more rules to parse the ip-numer and date.

Daan Oosterveld

Shannon Baker schreef:

> Once again I realise it may be easier to do a find/last or some other
> trick but i'm more
> interested in understanding how parse works. It would also make my code
> cleaner since I
> use the select convention to choose rules, as in:
>
> REBOL ["CS Log Parser"]
>
> ; lines omited
>
> digits: charset "0123456789"
>
> search: func ["Returns matches for search item"
>               line [string!] "Line to search"
>               item [string!] {Valid types are "date", "time", "user",
> "won-id", "ip"} ]
> [
>     if not value? 'item [item: ask {Search for? ("date", "time", "user",
> "won-id", "ip"):
> }]
>     rules: [
>           "date"     [thru {L } copy match to { -} to end (print match)]
>           "time"     [thru { - } copy match to {: "} to end (print
> match)]
>           "user"     [thru {: "} copy match to {"} to end (print
> match)]     ; this line
> is wrong
>           "ip"         [thru {ip "} copy match to {"} to end]
>           "won-id" [thru {<WON:} copy match to {>} to end]
>     ]
>     parse line select rules item
> ]
>
> ;
> __________example_______________________________________________________
> log-line: {L 09/22/2000 - 15:49:22: "<Usyd> H4XX0R<124><WON:20007739>"
> connected, ip
> "160.34.64.112"}
> search log-line "user"
>
> SpliFF
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to