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
31local scripted = Cs { "start",
32 start = (V("csname") + V("nested") + V("lowfirst") + V("highfirst") + V("character"))^1,
33 rest = V("csname") + V("nested") + V("lowfirst") + V("highfirst"),
34 csname = csname,
35 character = utf8character,
36 nested = leftbrace * (V("rest") + (V("character")-rightbrace))^0 * rightbrace,
37
38
39
40
41 content = V("nested") + sign^-1 * (cardinal + V("character")) + sign,
42 lowfirst = (subscript /"") * ( Cc("\\lohi{") * V("content") * Cc("}{") * (superscript/"") + Cc("\\low{" ) ) * V("content") * Cc("}"),
43 highfirst = (superscript/"") * ( Cc("\\hilo{") * V("content") * Cc("}{") * (subscript /"") + Cc("\\high{") ) * V("content") * Cc("}"),
44 }
45
46cpatterns.csname = csname
47cpatterns.scripted = scripted
48cpatterns.nested = nested
49
50
51
52
53
54
55
56
57
58
59
60 |