File Manager
Current Path : /usr/share/crm114/ |
|
Current File : //usr/share/crm114/rewriteutil.crm |
#! /usr/bin/crm
#
# rewriteutil.crm - rewrite utility using rewrites.mfp
# Copyright 2009 William S. Yerazunis.
# This file is under GPLv3, as described in COPYING.
#
# do rewriting, based on rewrite rules in rewrites.mfp
{
isolate (:rewrites:)
input (:rewrites:) [:*:_arg2:]
# reset matching on rewrites to start of string
}
# Be sure we're at the start of the rewrites, and the start of the :_dw:
match [:rewrites:] //
{
# Grab the next regexturn the one-per-line patterns into a regex
# First, do the line-spanning regexes.
match //
match <fromend nomultiline> (:ch: :fr: :to:) [:rewrites:] /(.+)>-->(.*)/
output [/dev/tty] /:*:_nl: checking :*:ch: -- /
# see if the "fr" regex matches anywhere
{
match <fromcurrent> (:place:) /:*:fr:/
# Yep, it matched... alter it and do it again
#
alter (:place:) /:*:to:/
output [/dev/tty] /./
output [/dev/tty] /:*:_dw:\n/
liaf
}
# Nope, didn't match... grab the next regex and try again,
liaf
}
# reset back to the start of the rewrites, and the start of the :_dw:.
#
match [:rewrites:] //
# and do it again for non-line-spanners
{
# Go through and do it again, except this time do it for
# the non-line-spanning regexes.
match //
match <fromend nomultiline> (:ch: :fr: :to:) [:rewrites:] /(.+)>->(.*)/
output [/dev/tty] /:*:_nl:checking :*:ch: --/
# see if the "fr" regex matches anywhere
{
match <fromcurrent nomultiline> (:place:) /:*:fr:/
# Yep, it matched... alter it and do it again
#
alter (:place:) /:*:to:/
output [/dev/tty] /./
liaf
}
# Nope, didn't match... grab the next regex and try again,
liaf
}
output [/dev/tty] /:*:_nl:/
accept
File Manager Version 1.0, Coded By Lucas
Email: hehe@yahoo.com