1if not modules then modules = { } end modules ['cldf-bas'] = {
2 version = 1.001,
3 comment = "companion to cldf-ini.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9
10
11local lpegmatch, patterns = lpeg.match, lpeg.patterns
12local P, R, V, Cc, Cs = lpeg.P, lpeg.R, lpeg.V, lpeg.Cc, lpeg.Cs
13local format = string.format
14
15local cpatterns = patterns.context or { }
16patterns.context = cpatterns
17
18local utf8character = patterns.utf8character
19local cardinal = patterns.cardinal
20
21local leftbrace = P("{")
22local rightbrace = P("}")
23local backslash = P("\\")
24local csname = backslash * P(1) * (1-backslash-leftbrace)^0 * P(" ")^0
25local sign = P("+") / "\\textplus "
26 + P("-") / "\\textminus "
27local nested = P { leftbrace * (V(1) + (1-rightbrace))^0 * rightbrace }
28local subscript = P("_")
29local superscript = P("^")
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47local scripted = Cs { "start",
48 start = (V("csname") + V("nested") + V("lowfirst") + V("highfirst") + V("character"))^1,
49 rest = V("csname") + V("nested") + V("lowfirst") + V("highfirst"),
50 csname = csname,
51 character = utf8character,
52
53 nested = leftbrace * (V("start") -rightbrace)^0 * rightbrace,
54
55 content = V("nested") + sign^-1 * (cardinal + V("character")) + sign,
56 lowfirst = (subscript /"") * ( Cc("\\lohi{") * V("content") * Cc("}{") * (superscript/"") + Cc("\\low{" ) ) * V("content") * Cc("}"),
57 highfirst = (superscript/"") * ( Cc("\\hilo{") * V("content") * Cc("}{") * (subscript /"") + Cc("\\high{") ) * V("content") * Cc("}"),
58 }
59
60cpatterns.csname = csname
61cpatterns.scripted = scripted
62cpatterns.nested = nested
63
64
65
66
67
68
69
70
71
72
73 |