File: configParser_interp_lexer.mll

package info (click to toggle)
missinglib 0.4.10.debian-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 476 kB
  • ctags: 326
  • sloc: ml: 1,726; makefile: 161
file content (23 lines) | stat: -rw-r--r-- 508 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(* arch-tag: config parser lexer for interpolation
*)
{
  open Lexing;;
  open Strutil;;
  exception Eof;;
}

let interp_var_pat = [^ ')']+
let interp_start = '%' '('
let interp_end = ')' 's'
let interp_string = interp_start (interp_var_pat as interpvar) interp_end
let std_string = [^ '\\' '%']+

let escaped_pct = "\\%"

rule loken interpfunc = parse
  escaped_pct   { ("%") }
| interp_string { interpfunc(interpvar) }
| std_string as x  { (x) }
| eof { raise Eof }
| _ as x        { (string_of_char x) }