Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
must provide own lenses to ensure accuracy of tests
- Loading branch information
Pedro Padron
committed
Nov 18, 2009
1 parent
63b0989
commit 69147a1
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(* Parsing /etc/hosts *) | ||
|
||
module Hosts = | ||
autoload xfm | ||
|
||
let sep_tab = Util.del_ws_tab | ||
let sep_spc = Util.del_ws_spc | ||
|
||
let eol = del /[ \t]*\n/ "\n" | ||
let indent = del /[ \t]*/ "" | ||
|
||
let comment = Util.comment | ||
let empty = [ del /[ \t]*#?[ \t]*\n/ "\n" ] | ||
|
||
let word = /[^# \n\t]+/ | ||
let record = [ seq "host" . indent . | ||
[ label "addr" . store word ] . sep_tab . | ||
[ label "canonical" . store word ] . | ||
[ label "alias" . sep_spc . store word ]* | ||
. (comment|eol) ] | ||
|
||
let lns = ( empty | comment | record ) * | ||
|
||
let xfm = transform lns (incl "/etc/hosts") |