World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
Tomc 12-Mar-2005 [53] | yes , my rule was for a single lin as in your first code sample |
Graham 12-Mar-2005 [54] | is ^J the line feed ? |
Tomc 12-Mar-2005 [55x2] | copy header ti ["^J^J" | "^M^M" | "^M^J^M^J"] |
^J same as ^/ | |
Graham 12-Mar-2005 [57] | >> header-rule: [copy header thru ["^J^J" | "^M^M" | "^M^J^M^J"] (write-client header)] == [copy header thru ["^/^/" | "^M^M" | {^M ^M }] (write-client header)] >> parse m header-rule ** Script Error: Invalid argument: | ** Near: parse m header-rule |
Tomc 12-Mar-2005 [58x2] | try {^M^/^M^/} |
not that it shoulf matter | |
Graham 12-Mar-2005 [60] | same problem |
Tomc 12-Mar-2005 [61x3] | it is interperting the third newline ... odd buggy odd |
parse all? | |
os use | 2 CRLF | |
Graham 12-Mar-2005 [64] | >> unix: [ copy header thru "^J^J" ] == [copy header thru "^/^/"] >> msdos: [ copy header thru "^/^/" ] == [copy header thru "^/^/"] >> parse m [ [ unix | msdos ] ( write-client header ) ] |
Tomc 12-Mar-2005 [65] | ms dos not correct |
Graham 12-Mar-2005 [66] | is that correct rule for unix ? |
Tomc 12-Mar-2005 [67] | yes |
Graham 12-Mar-2005 [68] | what's msdos ? |
Tomc 12-Mar-2005 [69x3] | mac ^M^M dod ^M^J unix ^J |
mac is a single ^M for a single line | |
[2 "^/" | 2 "^M" | 2 CLRF] | |
Graham 12-Mar-2005 [72x2] | >> parse m [ [2 "^/" | 2 "^M" | 2 crlf ] ( write-client header ) ] == false |
dos is : join crlf crlf .. isn't it ? | |
Tomc 12-Mar-2005 [74] | ... copy haader theu ... |
Graham 12-Mar-2005 [75] | parse m [ copy header thru [2 "^/" | 2 "^M" | 2 crlf ] ( write-client header ) ] ** Script Error: Invalid argument: 2 | 2 crlf |
Tomc 12-Mar-2005 [76x2] | copy header [thru 2 "^/" | thru 1 "^M" | thru 2 crlf] |
it annoys me the to/thru does not distribure over the block of ORs | |
Graham 12-Mar-2005 [78] | me too ... |
Tomc 12-Mar-2005 [79] | off to the coast for the weekend, got to pack |
Graham 12-Mar-2005 [80x3] | ok. |
This rule seems to now work for me ... header-rule: [ [ copy header thru {^M^J^M^J} | copy header thru {^/^/} ] (write-client header )] | |
not sure if the second rule is needed ... | |
Chris 12-Mar-2005 [83x2] | ;I tend to use charsets as a way of skipping 'thru while looking for multiple possibilities: line-end: charset [#"^/" #"^M"] ; etc line: complement newlines parse m [copy header [some [some line line-end]]] |
a way of skipping -> "an alternative to" | |
Graham 12-Mar-2005 [85] | is it faster? |
Chris 12-Mar-2005 [86] | It's hard to compare when 'thru doesn't fork. |
Graham 12-Mar-2005 [87] | or is it slower ? |
Chris 12-Mar-2005 [88] | For what it's worth, my benchmarks show it to be quick, but my benchmarks tend to be crude... |
Graham 12-Mar-2005 [89] | line: complement line-end |
Chris 12-Mar-2005 [90] | That means any character that isn't a line-ending... |
Graham 12-Mar-2005 [91] | yes, you have comlement newlines |
Chris 12-Mar-2005 [92x2] | Sorry, changing names as I go :o) |
line-end: charset [#"^/" #"^M" #"^J"] line: complement line-end parse m [copy header [some [some line line-end]] to end] ; Note that 'line-end in the parse line should be replaced with permutations of what a line-ending can be, without describing any permutation of a double line-ending. | |
Brett 13-Mar-2005 [94] | Graham, I'd probably use parse/all rather than parse. Also don't forget the parse-header function and all the associated bug fixing work related to it in view 1.3 project. May or may not be of use to you. |
Anton 13-Mar-2005 [95x2] | I don't think you need to distribute the thru. eg: |
parse "..abab..." [".." copy header ["aa" | "bb" | "abab"] (?? header) to end] header: "abab" == true | |
Graham 13-Mar-2005 [97x2] | I'll give this one a go as well. |
But I wanted the line endings in the "header" variable as I send it on to the client. | |
Anton 14-Mar-2005 [99] | The second line is the print out from (?? header) |
Tomc 20-Mar-2005 [100] | Joe: What do you need a perl comatible regular expression to do? |
BrianW 20-Mar-2005 [101x2] | He could hand it off to developers that are familiar with pcre but not parse, for starters. |
It wouldn't have to be industrial-strength, but it would like a security blanket for developers experimenting with the new language. PCRE is found all over the place in languages on Linux machines, and the absence makes some developers uncomfortable - despite the fact that Parse is better. | |
older newer | first last |