Mercurial > repo
view src/ploki/examples/rfc822.pk @ 12518:2d8fe55c6e65 draft default tip
<int-e> learn The password of the month is release incident pilot.
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Sun, 03 Nov 2024 00:31:02 +0000 |
parents | ac0403686959 |
children |
line wrap: on
line source
#!../ploki REM adaption of Jeffrey Friedl's RFC 822 email regex REM (taken from _Mastering Regular Expressions_) LET $esc "\\" LET $Period ".!" LET $OpenBr "[!" LET $CloseBr "]!" LET $OpenParen "(!" LET $CloseParen ")!" LET $NonASCII "\x80-\xff" LET $ctl "\000-\037" LET $CRlist "\n\015" LET $qtext "'^\V$esc\V$NonASCII\V$CRlist\"'" LET $dtext "'^\V$esc\V$NonASCII\V$CRlist[]'" LET $quoted$pair $esc _ "'^\V$NonASCII'" LET $ctext "'^\V$esc\V$NonASCII\V$CRlist)('" LET $Cnested $OpenParen _ $ctext _ "*(\V$quoted$pair\V$ctext*)*" _ $CloseParen LET $comment $OpenParen _ $ctext _ "*((\V$quoted$pair|\V$Cnested)\V$ctext*)*" _ $CloseParen LET $X "' \t'*(\V$comment' \t'*)*" LET $atom$char "'^() <>\\@,;:\".\V$esc[]\V$ctl\V$NonASCII'" LET $atom "<\V$atom$char+>" LET $quoted$str "\"\V$qtext*(\V$quoted$pair\V$qtext*)*\"" LET $word "(\V$atom|\V$quoted$str)" LET $domain$ref $atom LET $domain$lit $OpenBr _ "(\V$dtext|\V$quoted$pair)*" _ $CloseBr LET $sub$domain "(\V$domain$ref|\V$domain$lit)" _ $X LET $domain $sub$domain _ "(\V$Period\V$X\V$sub$domain)*" LET $route "@" _ $X _ $domain _ "(,\V$X\V$domain)*:!" _ $X LET $local$part $word _ $X _ "(\V$Period\V$X\V$word\V$X)*" LET $addr$spec $local$part _ "@" _ $X _ $domain LET $route$addr "<!(\V$route)?\V$addr$spec>!" LET $phrase$ctl "\000-\010\012-\037" LET $phrase$char "'^()<>@,;:\".\V$esc[]\V$NonASCII\V$phrase$ctl'" LET $phrase $word _ $phrase$char _ "*((\V$comment|\V$quoted$str)\V$phrase$char*)*" LET $mailbox $X _ "(\V$addr$spec|\V$phrase\V$route$addr)" REM ****************** REM ** test snippet ** REM ****************** LET status 0 LET i 1 FOR main-loop IF i < \ARG IF \ARG:i ~ ("^" _ $mailbox _ "$") "`\V\ARG:i' is syntactically valid. ELSE "`\V\ARG:i' is syntactically invalid. LET status @NEG 1 FI LET i += 1 NEXT main-loop FI END status