Browse Source

initial commit

python3
Volker Birk 5 years ago
commit
7fbba95cc1
89 changed files with 6964 additions and 0 deletions
  1. +2
    -0
      .hgignore
  2. +20
    -0
      Makefile
  3. +815
    -0
      backend.py
  4. +1090
    -0
      features.en.yhtml2
  5. +90
    -0
      format.css
  6. +339
    -0
      gpl-2.0.txt
  7. +66
    -0
      heading.en.yhtml2
  8. +12
    -0
      hello.en.yhtml2
  9. +24
    -0
      homepage.en.yhtml2
  10. +206
    -0
      index.en.yhtml2
  11. +1
    -0
      manpage.yml2
  12. +413
    -0
      programming.en.yhtml2
  13. +351
    -0
      pyPEG.py
  14. +10
    -0
      samples/Customer.java
  15. +13
    -0
      samples/address.yml2
  16. +7
    -0
      samples/addresslistenhtml.ysl2
  17. +12
    -0
      samples/adressliste.yml2
  18. +9
    -0
      samples/backend.ysl2
  19. +61
    -0
      samples/blub.svg
  20. +1
    -0
      samples/blub.yml2
  21. +6
    -0
      samples/browse.ysl2
  22. +9
    -0
      samples/bumens.yml2
  23. +6
    -0
      samples/clike.yml2
  24. +3
    -0
      samples/ctest.yml2
  25. +27
    -0
      samples/customer.java.target
  26. +10
    -0
      samples/customer.xml
  27. +1
    -0
      samples/customer.xsl
  28. +15
    -0
      samples/customer.ysl2
  29. +15
    -0
      samples/ddl.ysl2
  30. +9
    -0
      samples/debug_test.ysl2
  31. +2
    -0
      samples/delta.yml2
  32. +16
    -0
      samples/demo.xmi
  33. +20
    -0
      samples/dingens.idl
  34. +6
    -0
      samples/dingens.sql
  35. +1
    -0
      samples/dingens.xml
  36. +3
    -0
      samples/dingens.yml2
  37. +9
    -0
      samples/dml.ysl2
  38. +3
    -0
      samples/double.yml2
  39. +3
    -0
      samples/double.ysl2
  40. +1
    -0
      samples/empty.xml
  41. +22
    -0
      samples/empty.ysl2
  42. +5
    -0
      samples/errortest.ysl2
  43. +3
    -0
      samples/f.yml2
  44. +19
    -0
      samples/f.ysl2
  45. +1
    -0
      samples/function.xml
  46. +1
    -0
      samples/function.yml2
  47. +13
    -0
      samples/gen_addr_html.ysl2
  48. +33
    -0
      samples/gen_again_java.ysl2
  49. +60
    -0
      samples/gen_java.ysl2
  50. +2
    -0
      samples/hello.xsl
  51. +11
    -0
      samples/hello.yml2
  52. +3
    -0
      samples/hello.ysl2
  53. +1
    -0
      samples/i.yml2
  54. +3
    -0
      samples/idl.yml2
  55. +8
    -0
      samples/indention.ysl2
  56. +8
    -0
      samples/list.yml2
  57. +4
    -0
      samples/macros_test.yml2
  58. +15
    -0
      samples/model.ymi
  59. +5
    -0
      samples/namespace.ysl2
  60. +5
    -0
      samples/opertest.ysl2
  61. +14
    -0
      samples/rechner.ysl2
  62. +7
    -0
      samples/sample.yml2
  63. +11
    -0
      samples/simple.ysl2
  64. +8
    -0
      samples/table.yml2
  65. +50
    -0
      samples/table2ddl.ysl2
  66. +6
    -0
      samples/text_test.yml2
  67. +5
    -0
      samples/textest.xml
  68. +1
    -0
      samples/types.xml
  69. +4
    -0
      samples/types.yml2
  70. +46
    -0
      samples/uml.yml2
  71. +22
    -0
      samples/uml2idl.yml2
  72. +20
    -0
      samples/uml2sql.yml2
  73. +19
    -0
      samples/union.ysl2
  74. +185
    -0
      samples/vorlesung.xmi
  75. +11
    -0
      samples/webseite.ysl2
  76. +23
    -0
      samples/xmi2ddl.uml2
  77. +34
    -0
      samples/xmi2ddl.ysl2
  78. +21
    -0
      samples/xmi2idl.uml2
  79. +2
    -0
      samples/xml2.yml2
  80. +23
    -0
      samples/ydl2idl.ysl2
  81. +55
    -0
      standardlib.ysl2
  82. +380
    -0
      toolchain.en.yhtml2
  83. +375
    -0
      vim/syntax/yml2.vim
  84. +87
    -0
      xml2yml.ysl2
  85. +108
    -0
      yml2.py
  86. +102
    -0
      yml2c
  87. +248
    -0
      yml2proc
  88. +1069
    -0
      yslt.en.yhtml2
  89. +99
    -0
      yslt.yml2

+ 2
- 0
.hgignore View File

@ -0,0 +1,2 @@
syntax: glob
*.pyc

+ 20
- 0
Makefile View File

@ -0,0 +1,20 @@
YML_PATH=
YML2C=yml2c
all: homepage
homepage: index.html features.html yslt.html toolchain.html programming.html hello.html
update: homepage format.css gpl-2.0.txt
rsync -avC *.html *.yml2 format.css *.yhtml2 gpl-2.0.txt samples dragon:fdik.org/yml2/
update-all: update yml2c yml2.py pyPEG.py backend.py yml2proc
if test -z $(VERSION) ; then echo VERSION not set ; exit 1 ; fi
rsync -avC *.py yml2c Makefile yml2proc xml2yml.ysl2 standardlib.ysl2 samples dragon:fdik.org/yml2/
ssh dragon bash -c "cd ; cd fdik.org/; tar cvjf yml-$(VERSION).tar.bz2 yml2/{*.py,*.yml2,*.yhtml2,format.css,gpl-2.0.txt,yml2c,Makefile,yml2proc,xml2yml.ysl2,standardlib.ysl2,samples} ; rm yml2.tar.bz2 ; ln -s yml-$(VERSION).tar.bz2 yml2.tar.bz2"
%.html: %.en.yhtml2 heading.en.yhtml2 homepage.en.yhtml2
$(YML2C) $< -o $@
clean:
rm -f *.html *.pyc *.pyo

+ 815
- 0
backend.py View File

@ -0,0 +1,815 @@
# 2.5.0 backend
# written by VB.
import re, codecs
import fileinput
import sys, traceback, exceptions, os
from xml.sax.saxutils import escape, quoteattr
from copy import deepcopy
from glob import glob
from pyPEG import code, parse, parseLine, u, Symbol
from yml2 import ymlCStyle, comment, _inner
ymlFunc, pointers, pythonFunc = {}, {}, {}
in_ns = u""
operator = []
included = u""
includePath = []
emitlinenumbers = False
encoding = "utf-8"
first = True
enable_tracing = False
ymlFunc["decl"] = "#error"
ymlFunc["define"] = "#error"
ymlFunc["operator"] = "#error"
def clearAll():
global ymlFunc, pointers, pythonFunc, in_ns, operator, included
ymlFunc, pointers, pythonFunc = {}, {}, {}
in_ns = u""
operator = []
included = u""
lq = re.compile(r"\|(\>*)(.*)")
sq = re.compile(r"(\d*)\>(.*)")
ts = re.compile(r'(\|\|(?P<inds>\>*)\s*\n(?P<text1>.*?)\n(?P<base>\s*)\|\|)|("""(?P<text2>.*?)""")|(\>\>(?P<text3>.*?)\>\>)', re.S)
tq = re.compile(r"(\]|\<)\s*(.*)")
bq = re.compile(r"\`(.*?)\`", re.S)
bqq = re.compile(r"\s*\`\`(.*)")
all = re.compile(r".*", re.S)
line = 1
def pointer(name):
try:
return u(pointers[name[1:]])
except:
if name == "*_trace_info":
return u'""'
if included:
raise LookupError(u"in " + included + u":" + u(line) + u": pointer " + name)
else:
raise LookupError(u"in " + u(line) + u": pointer " + name)
def evalPython(expr):
try:
result = eval(u(expr), pythonFunc)
if type(result) is str:
return codecs.decode(result, encoding)
else:
return result
except:
name, parm, tb = sys.exc_info()
msg = u"in python expression: " + u(parm)
if name is exceptions.SyntaxError:
tbl = traceback.format_exception(name, parm, tb)
msg += u"\n" + tbl[-3] + tbl[-2]
else:
msg += u": " + expr + u"\n"
if included:
raise name(u"in " + included + u":" + u(line) + u": " + msg)
else:
raise name(u"in " + u(line) + u": " + msg)
def execPython(script):
try:
if type(script) is unicode:
exec script in pythonFunc
else:
exec codecs.decode(script, encoding) in pythonFunc
except:
name, parm, tb = sys.exc_info()
msg = u"in python script: " + u(parm)
if name is exceptions.SyntaxError:
tbl = traceback.format_exception(name, parm, tb)
msg += u"\n" + tbl[-3] + tbl[-2]
else:
msg += u": " + expr + u"\n"
if included:
raise name(u"in " + included + u":" + u(line) + u": " + msg)
else:
raise name(u"in " + u(line) + u": " + msg)
def textOut(text):
if not text:
return u""
if type(text) is not unicode:
text = codecs.decode(text, encoding)
text = text.replace(r'\"', r'\\"')
text = u'u"""' + text.replace('"', r'\"') + u'"""'
try:
textFunc = ymlFunc["text"]
parms = ['text', ('parm', [text])]
c, result = textFunc(parms)
if c:
if type(textFunc.alias) is unicode:
result += u"</" + textFunc.alias + u">"
else:
result += u"</" + codecs.decode(textFunc.alias, encoding) + u">"
return result
except:
return escape(eval(text))
def strRepl(text):
if not text:
return u""
if type(text) is not unicode:
text = codecs.decode(text, encoding)
text = text.replace(r'\"', r'\\"')
text = u'u"""' + text.replace('"', r'\"') + u'"""'
if type(text) is unicode:
return escape(eval(text))
def applyMacros(macros, text):
result = text
for key, value in macros.iteritems():
result = result.replace(key, value)
return result
class YF:
def __init__(self, name):
self.name = name
self.parms = []
self.descends = []
self.values = {}
self.content = None
self.pointers = {}
self.macros = {}
if in_ns:
self.alias = in_ns + u":" + name.replace("_", "-")
else:
self.alias = name.replace("_", "-")
pythonFunc["yml_" + name] = self
if emitlinenumbers:
self.values["yml:declared"] = u(line)
def copy(self, newName):
yf = YF(newName)
yf.parms.extend(self.parms)
yf.descends.extend(self.descends)
yf.values = self.values.copy()
yf.content = self.content
yf.pointers = self.pointers.copy()
yf.macros = self.macros.copy()
yf.alias = self.alias
return yf
def patch(self, second):
self.parms.extend(second.parms)
self.descends.extend(second.descends)
self.values.update(second.values)
if second.content:
self.content = second.content
self.pointers.update(second.pointers)
self.macros.update(second.macros)
def __call__(self, called_with, hasContent = False, avoidTag = False):
global pointers
parms = []
vals = {}
if self.pointers:
pointers.update(self.pointers)
for data in called_with:
if type(data) is tuple or type(data) is Symbol:
if data[0] == "parm":
l = data[1]
parm = l[0]
if parm[0] == "*":
parm = pointer(parm)
if len(l) == 1:
if type(parm) is tuple or type(parm) is Symbol:
if parm[0] == "pyExp":
val = evalPython(parm[1][0])
parms.append(val)
else:
parms.append(evalPython((parm)))
else:
if type(parm) is tuple or type(parm) is Symbol:
if parm[0] == "pyExp":
parm = evalPython(parm[1][0])
val = l[1]
if type(val) is tuple or type(val) is Symbol:
if val[0] == "pyExp":
val = evalPython(val[1][0])
if val[0] == "*":
val = pointer(val)
if u(val)[0] == '"' or u(val)[0] == "'":
vals[parm] = evalPython(u(val))
else:
vals[parm] = u(val)
elif data[0] == "content":
hasContent = True
if enable_tracing:
text = u(parms) + u", " + u(vals)
pointers["_trace_info"] = u'"' + u(line) + u": " + u(self.name) + u" " + text.replace(u'"', u'#') + u'"'
if emitlinenumbers:
global first
if first:
vals["xmlns:yml"] = u"http://fdik.org/yml"
first = False
vals["yml:called"] = u(line)
return self.xml(parms, vals, hasContent, avoidTag)
def addParm(self, parm):
if parm[0] == "%":
for i in range(len(self.parms)):
if self.parms[i][0] != "%":
self.parms.insert(i, parm)
return
self.parms.append(parm)
def addDescend(self, desc):
if desc[0] == "+" or desc[0] == "@":
self.descends.append(desc[1:])
else:
self.descends.append(desc)
def addValue(self, parm, value):
if type(value) is str or type(value) is unicode:
self.values[parm] = u(evalPython(value))
else:
self.values[parm] = u(evalPython(u(value)))
def xml(self, callParms, callValues, hasContent, avoidTag = False):
global pointers
extraContent = u""
if self.content:
hasContent = True
resultParms = self.values.copy()
macros = self.macros.copy()
toDelete = resultParms.keys()
for key in toDelete:
if key[0] == "*":
del resultParms[key]
for key, value in callValues.iteritems():
if key[0] == "%":
macros[key] = value
else:
resultParms[key] = value
i = 0
for cp in callParms:
if i < len(self.parms):
if self.parms[i][0] == "*":
cp = u(cp)
if "'" in cp:
pointers[self.parms[i][1:]] = u'"' + cp + u'"'
else:
pointers[self.parms[i][1:]] = u"'" + cp + u"'"
elif self.parms[i][0] == "%":
macros[self.parms[i]] = u(cp)
else:
resultParms[self.parms[i]] = cp
else:
extraContent += u(cp)
hasContent = True
i += 1
result = u""
for p, v in resultParms.iteritems():
if p[0] == "'" or p[0] == '"':
p = eval(p)
result += u" "+ p + u"=" + quoteattr(applyMacros(macros, u(v)))
if hasContent:
if avoidTag:
return True, strRepl(extraContent)
else:
return True, u"<" + self.alias + result + u">" + strRepl(extraContent)
else:
if avoidTag:
return False, u""
else:
return False, u"<" + self.alias + result + u"/>"
def replaceContent(tree, subtree):
n = 0
while n < len(tree):
obj = tree[n]
if obj[0] == "func":
l = obj[1]
if l[0] == "content":
d = 1
if subtree:
for el in subtree:
tree.insert(n+d, el)
d += 1
del tree[n]
n += d
else:
try:
if l[-1][0] == "content":
replaceContent(l[-1][1], subtree)
except: pass
elif obj[0] == "funclist":
replaceContent(obj[1], subtree)
n += 1
return tree
def executeCmd(text):
if type(text) is not unicode:
text = codecs.decode(text, encoding)
for (regex, pattern) in operator:
match = re.search(regex, text)
while match:
cmd = pattern
opt = match.groups()
for i in range(len(opt)):
cmd = cmd.replace(u"%" + u(i+1), opt[i])
text = text[:match.start()] + u"`" + cmd + u"`"+ text[match.end():]
match = re.search(regex, text)
result = u""
m = re.search(bq, text)
while text and m:
cmd = m.group(1)
head = textOut(text[:m.start()])
text = text[m.end():]
try:
r, rest = parseLine(cmd, _inner, [], True, comment)
if rest: raise SyntaxError(cmd)
except SyntaxError:
if included:
raise SyntaxError(u"in " + included + u":" + u(line) + u": syntax error in executing command: " + cmd.strip())
else:
raise SyntaxError(u"in " + u(line) + u": syntax error in executing command: " + cmd.strip())
inner = _finish(r)
result += head + inner
m = re.search(bq, text)
result += textOut(text)
return result
def codegen(obj):
global in_ns, pointers, line, included
ctype = obj[0]
if type(obj) is code:
return obj
try:
if ctype.line: line = ctype.line
except: pass
if ctype == "empty":
return code(u"")
if ctype == "in_ns":
in_ns = obj[1][0]
subtree = obj[1]
for sel in subtree:
codegen(sel)
in_ns = u""
return code(u"")
elif ctype == "decl":
name = u""
for data in obj[1]:
if type(data) is unicode or type(data) is str:
name = data
try:
yf = ymlFunc[name]
yf.alias
except:
ymlFunc[name] = YF(name)
yf = ymlFunc[name]
if in_ns:
yf.alias = in_ns + u":" + name
if not enable_tracing:
if in_ns == "xsl" and (name == "debug" or name=="assert" or name[:7]=="_trace_"):
yf.alias = "-"
yf.addParm("skip1")
yf.addParm("skip2")
break
elif type(data) is tuple or type(data) is Symbol:
if data[0] == "base":
base = data[1][0]
try:
yf = ymlFunc[name] = ymlFunc[base].copy(name)
except KeyError:
if included:
raise KeyError(u"in " + included + u":" + u(line) + u": " + base + u" as base for " + name)
else:
raise KeyError(u"in " + u(line) + u": " + base + u" as base for " + name)
elif data[0] == "shape":
shape = ymlFunc[data[1]]
try:
yf = ymlFunc[name]
yf.patch(shape)
except KeyError:
if included:
raise KeyError(u"in " + included + u":" + u(line) + u": " + base + u" as shape for " + name)
else:
raise KeyError(u"in " + u(line) + u": " + base + u" as shape for " + name)
elif data[0] == "descend":
yf.addDescend(data[1])
elif data[0] == "declParm":
l = data[1]
parmName = l[0]
if len(l)==1:
yf.addParm(parmName)
else:
value = l[1]
if parmName[0] != "%":
yf.addValue(parmName, value)
if parmName[0] == "*":
yf.pointers[parmName[1:]] = value
yf.addParm(parmName)
elif parmName[0] == "%":
if type(value) is unicode or type(value) is str:
yf.macros[parmName] = u(evalPython(value))
else:
yf.macros[parmName] = u(evalPython(u(value)))
yf.addParm(parmName)
elif data[0] == "alias":
if in_ns:
yf.alias = in_ns + u":" + data[1][0]
else:
yf.alias = data[1][0]
elif data[0] == "content":
yf.content = data[1]
return code(u"")
elif ctype == "funclist":
result = u""
for f in obj[1]:
result += codegen(f)
return code(result)
elif ctype == "parentheses":
if len(obj[1]):
return codegen(('func', ['_parentheses', ('content', [obj[1][0]])]))
else:
return u""
elif ctype == "fparm":
if len(obj[1]):
return codegen(('func', ['_parm', ('content', [obj[1][0]])]))
else:
return u""
elif ctype == "generic":
return codegen(('func', ['_generic', ('content', [obj[1][0]])]))
elif ctype == "xbase":
return codegen(('func', ['_base', ('content', [obj[1][0]])]))
elif ctype == "func":
avoidTag = False
name = obj[1][0]
if name == "decl":
if ymlFunc[name] == "#error":
if included:
raise SyntaxError(u"in " + included + u":" + u(line) + u": syntax error in decl statement")
else:
raise SyntaxError(u"in " + u(line) + u": syntax error in decl statement")
if name == "define" or name == "operator":
if ymlFunc[name] == "#error":
if included:
raise SyntaxError(u"in " + included + u":" + u(line) + u": syntax error in define statement")
else:
raise SyntaxError(u"in " + u(line) + u": syntax error in define statement")
if name[0] == "&":
avoidTag = True
name = name[1:]
hasContent = False
if len(name) > 2:
if name[0:2] == "**":
return code(eval('u'+pointer(name[1:])))
if name[0] == "*":
name = eval(pointer(name))
if name[0] == "&":
avoidTag = True
name = name[1:]
try:
ymlFunc[name]
except:
try:
ymlFunc["_"]
return codegen(('func', ['_', ('content', [('funclist', [obj])])]))
except:
ymlFunc[name] = YF(name)
if ymlFunc[name].alias == "-": avoidTag = True
to_add = []
if len(ymlFunc[name].descends):
if obj[1][-1][0] != 'content':
if included:
raise KeyError(u"in " + included + u":" + u(line) + u": " + name + u" has descending attributes, but no descendants are following")
else:
raise KeyError(u"in " + u(line) + u": " + name + u" has descending attributes, but no descendants are following")
def first_func(obj):
if type(obj) is tuple or type(obj) is Symbol:
if obj[0] == 'func':
return obj
elif obj[0] == 'funclist':
return first_func(obj[1])
elif obj[0] == 'content':
return first_func(obj[1])
else:
return None
elif type(obj) == list:
for e in obj:
f = first_func(e)
if f: return f
return None
def copy_without_first_func(o, found = False):
c = []
for obj in o:
if found:
c.append(obj)
else:
if obj[0] == 'func':
if obj[1][-1][0] == 'content':
c.extend( obj[1][-1][1] )
found = True
else:
c.append( ( obj[0], copy_without_first_func(obj[1], False ) ) )
return c
def get_parms(obj):
result = []
for e in obj[1]:
if type(e) is tuple or type(e) is Symbol:
if e[0] == "parm":
result.append( e )
return result
try:
add_params = get_parms(obj)
for e in obj[1][-1][1]:
c = e[1]
for dname in ymlFunc[name].descends:
f, c = first_func(c), copy_without_first_func(c)
if dname[0] == "*":
pointers[dname[1:]] = "'" + f[1][0] + "'"
else:
add_params.append( ('parm', [dname, u"'" + f[1][0] + u"'"]) )
try:
add_params.extend( get_parms(f) )
except: pass
new_things = [ e[1][0] ]
new_things.extend( add_params )
new_things.append( ('content', c) )
to_add.append( ('func', new_things ) )
except:
if included:
raise KeyError(u"in " + included + u":" + u(line) + u": " + name + u" has descending attributes, and too less descendants are following")
else:
raise KeyError(u"in " + u(line) + u": " + name + u" has descending attributes, and too less descendants are following")
if not to_add:
to_add = ( obj, )
complete = u""
for obj in to_add:
subtree = None
try:
if obj[1][-1][0] == "content":
subtree = obj[1][-1][1]
except: pass
if ymlFunc[name].content:
hasContent = True
treetemplate = deepcopy(ymlFunc[name].content)
subtree = replaceContent(treetemplate, subtree)
if subtree:
hasContent = True
hasContent, result = ymlFunc[name](obj[1], hasContent, avoidTag)
if subtree:
for sel in subtree:
result += codegen(sel)
if hasContent and not(avoidTag):
result += u"</" + ymlFunc[name].alias + u">"
complete += result
return code(complete)
elif ctype == "textsection":
result = u''
ll = obj[1].splitlines()
space = len(ll[-1]) - 2
for l in ll[1:-1]:
m = re.match(bqq, l)
if m:
cmd = m.group(1)
try:
r, x = parseLine(cmd, _inner, [], True, comment)
if x: raise SyntaxError(cmd)
result += _finish(r)
except SyntaxError:
if included:
raise SyntaxError(u"in " + included + u":" + u(line) + u": syntax error in executing command: " + cmd.strip())
else:
raise SyntaxError(u"in " + u(line) + u": syntax error in executing command: " + cmd.strip())
else:
result += codegen(Symbol(u'lineQuote', u'| ' + l[space:]))
return code(result)
elif ctype == "lineQuote" or ctype == "quote":
m, text, base, inds = None, u"", 0, 0
if ctype == "lineQuote":
text = obj[1]
m = lq.match(text)
if m:
inds = len(m.group(1))
text = m.group(2)[1:]
else: inds = 0
elif ctype == "quote":
inds = -1
text = obj[1][0]
m = sq.match(text)
if m:
if m.group(1):
inds = int(m.group(1))
text = m.group(2)[1:]
else:
if type(text) is unicode or type(text) is str:
text = u(evalPython(text))
ind = u""
if inds > -1:
try:
cmd = evalPython(u"indent(" + u(inds) + u")")
result, rest = parseLine(u(cmd), _inner, [], True, comment)
if rest:
raise SyntaxError()
ind = _finish(result)
except: pass
if ctype == "lineQuote": text += u"\n"
hasTextFunc = False
try:
ymlFunc["text"]
hasTextFunc = True
except: pass
text = executeCmd(text)
return code(ind + text)
elif ctype == "tagQuote":
m = tq.match(obj[1])
if m.group(1) == "<":
return code(u"<" + m.group(2))
else:
return code(m.group(2))
elif ctype == "operator":
operator.append((re.compile(evalPython(obj[1][0])), obj[1][1]))
return code(u"")
elif ctype == "constant":
name = obj[1][0]
if name[0] == "*":
name = name[1:]
value = obj[1][1]
pointers[name] = value
return code(u"")
elif ctype == "include":
reverse = False
ktext, kxml = False, False
for arg in obj[1]:
if type(arg) is tuple or type(arg) is Symbol:
if arg[0] == "reverse":
reverse = True
elif arg[0] == "ktext":
ktext = True
elif arg[0] == "kxml":
kxml = True
elif type(arg) is unicode or type(arg) is str:
filemask = arg
if filemask[0] == '/' or filemask[0] == '.':
files = glob(filemask)
else:
files = []
for directory in includePath:
path = os.path.join(directory, filemask)
files.extend(glob(path))
if reverse:
files = files[-1::-1]
if not(files):
if included:
raise IOError(u"in " + included + ":" + u(line) + u": include file(s) '" + filemask + u"' not found")
else:
raise IOError(u"in " + u(line) + u": include file(s) '" + filemask + u"' not found")
includeFile = fileinput.input(files, mode="rU", openhook=fileinput.hook_encoded(encoding))
_included = included
if ktext or kxml:
text = u""
for line in includeFile:
included = includeFile.filename()
if kxml:
if (not line[:6] == '<?xml ') and (not line[:6] == '<?XML '):
text += line
else:
text += executeCmd(line)
included = _included
return code(text)
else:
result = parse(ymlCStyle(), includeFile, True, comment)
included = u(filemask)
x = _finish(result)
included = _included
return code(x)
elif ctype == "pyExp":
exp = obj[1][0]
cmd = evalPython(exp)
result, rest = parseLine(u(cmd), _inner, [], True, comment)
if rest:
raise SyntaxError(cmd)
return code(_finish(result))
elif ctype == "pythonCall":
parms = []
data = obj[1]
for p in data:
if type(p) is unicode or type(p) is str:
name = p
elif type(p) is tuple or type(p) is Symbol:
ptype = p[0]
if ptype == "parm":
if p[1][0][0] == "*":
parms.append(pointer(p[1][0]))
else:
parms.append(p[1][0])
if len(parms) == 0:
exp = name + u"()"
elif len(parms) == 1:
exp = name + u"(" + u(parms[0]) + u")"
else:
exp = name + u(tuple(parms))
cmd = evalPython(exp)
result, rest = parseLine(u(cmd), _inner, [], True, comment)
if rest:
raise SyntaxError()
return code(_finish(result))
else:
return code(u"")
def _finish(tree):
result = u""
python = u""
for el in tree:
if el[0] == "python":
if el[1][0][:2] == "!!":
python += el[1][0][2:-2]
else:
python += el[1][0][1:] + u"\n"
continue
else:
if python:
execPython(python)
python = u""
try:
result += codegen(el)
except RuntimeError:
if included:
raise RuntimeError(u"in " + included + u":" + u(line))
else:
raise RuntimeError(u"in " + u(line))
if python:
execPython(python)
return result
def finish(tree):
global first
first = True
return _finish(tree)
ymlFunc["_parentheses"] = YF("parms")
ymlFunc["_parm"] = YF("parm")
ymlFunc["_generic"] = YF("generic")
ymlFunc["_base"] = YF("base")

+ 1090
- 0
features.en.yhtml2
File diff suppressed because it is too large
View File


+ 90
- 0
format.css View File

@ -0,0 +1,90 @@
html {
background-color: lightgrey;
}
body {
margin-left: auto;
margin-right: auto;
margin-top: 0;
width: 900px;
min-height: 768px;
background-color: white;
font-family: Arial,Helvetica,FreeSans
}
em {
color: darkblue;
font-weight: bold;
font-style: normal;
}
#headline {
color: black;
font-size: x-large;
font-weight: normal;
border-bottom-width: 1px;
border-bottom-style: solid;
padding: 10px;
}
td {
vertical-align: top;
}
#navigation {
position: relative;
float: right;
width: 200px;
border-left-width: 1px;
border-left-style: dotted;
padding: 10px;
font-size: small;
}
#entries {
width: 569px;
padding: 10px;
}
.statusline {
width: 569px;
padding-left: 10px;
padding-right: 10px;
font-size: small;
}
#bottom {
clear: both;
color: grey;
padding: 10px;
}
h1, h2 {
font-size: medium;
color: darkblue;
}
h3 {
font-size: medium;
color: black;
}
h4 {
font-size: medium;
font-weight: normal;
font-style: italic;
}
.subscript {
font-size: small;
border-bottom-width: 1px;
border-bottom-style: dotted;
margin-bottom: 1em;
padding-bottom: 1em;
}
.small {
font-size: small;
margin-bottom: 1em;
padding-bottom: 1em;
}

+ 339
- 0
gpl-2.0.txt View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

+ 66
- 0
heading.en.yhtml2 View File

@ -0,0 +1,66 @@
decl a(href);
decl Code alias pre {
code
content;
};
decl ne is a {
content;
br;
};
div id=headline {
p > YML – Why a Markup Language?!
div class=small {
"YML 2.5.4 of We Apr 10 2013 – Copyleft 2007-2013, "
a "http://blog.fdik.org", "Volker Birk";
" – "
a "http://fdik.org/yml2.tar.bz2", "Download YML 2";
}
}
div id=navigation {
h1 a "index", "Introduction";
ne "index#xml", "XML";
ne "index#motivation", "Motivation";
ne "index#howitworks", "How it works";
ne "index#ylanguages", "Y Languages";
h1 a "programming", "Using YML 2";
ne "programming#wiki", "A Wiki like language";
ne "programming#how", "How does that work?";
ne "programming#details", "Details, please!";
ne "programming#using", "Using it";
h1 a "features", "Features";
ne "features#text", "Text";
ne "features#functioncalls", "Function Calls";
ne "features#decl", "Declaring Functions";
ne "features#quoting", "Quoting Operators";
ne "features#including", "Including YML Files";
ne "features#python", "Escaping into Python";
ne "features#comments", "Comments";
h1 a "yslt", "YSLT";
ne "yslt#intro", "Introduction into YSLT";
ne "yslt#hello", "Hello, World";
ne "yslt#programming", "Programming in YSLT";
ne "yslt#htmlgen", "Generating HTML out of a DSL";
ne "yslt#codegen", "Generating Java code out of a DSL";
ne "yslt#ddlgen", "Generating SQL DDL out of UML in XMI";
ne "yslt#features", "YSLT Features";
h1 a "toolchain", "Tool Chain";
ne "toolchain#compiler", "YML compiler";
ne "toolchain#processor", "YML/YSLT processor";
ne "toolchain#recommended", "Recommended external tools";
ne "http://www.auchdieserschwachsinnmussinsinternet.de/2009-03/#s1236859037", "Windows tool chain";
ne "http://fdik.org/yml2.tar.bz2", "Download YML 2";
ne "toolchain#downloads", "Download different versions";
h1 "Misc";
ne "gpl-2.0.txt", "License for YML";
ne "http://www.pibit.ch/", "Commercial support for YML";
ne "http://fdik.org/pyPEG", "YML is using pyPEG";
}

+ 12
- 0
hello.en.yhtml2 View File

@ -0,0 +1,12 @@
include homepage.en.yhtml2
page "Hello, world" {
p >>
Hello, world! I can link here, say:
¬http://en.wikipedia.org to Wikipedia¬
>>
p >>
This is ƒemphasized. And this is «code».
>>
}

+ 24
- 0
homepage.en.yhtml2 View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
decl pageContent alias body {
a name=top;
include heading.en.yhtml2;
div id=entries
content;
};
decl page(*title, lang="en", xml:lang="en", xmlns="http://www.w3.org/1999/xhtml") alias html {
head {
title *title;
meta http-equiv="Content-Type", content="text/html;charset=UTF-8";
link rel=stylesheet, type="text/css", href="format.css";
}
pageContent
content;
};
define operator "¬\s*(.*?)\s+(.*?)\s*¬" as a href="%1" > %2
define operator "«(.*?)»" as code > %1
define operator "ƒ(\S+)" as em > %1

+ 206
- 0
index.en.yhtml2 View File

@ -0,0 +1,206 @@
// the YML homepage
include homepage.en.yhtml2
page "YML – Why a Markup Language?!" {
h1 > Introduction
h2 > What is YML?
p >>
Well, it's the idea not to need to define a grammar first when you want to use a
¬http://en.wikipedia.org/wiki/Domain_Specific_Language Domain Specific Language¬.
For that purpose, YML is being translated into XML. Let's make an example.
>>
p >>
Everything which comes close to a C like language, parses without a grammar
definition:
>>
p > This:
Code
||
template< class T > T max(T a, T b);
||
p > Parses to:
Code
||
<?xml version='1.0' encoding='UTF-8'?>
<template>
<generic>
<class/>
<T/>
</generic>
<T>
<max>
<parm>
<T/>
<a/>
</parm>
<parm>
<T/>
<b/>
</parm>
</max>
</T>
</template>
||
p >>
Instead of defining grammars, you test out and play around until the
results are matching your needs. If the resulting tree does not fit
what you're expecting, change it by patching the grammar with `code > decl`:
>>
p > This:
Code
||
module A {
interface B {
attribute long n;
};
};
||
p > Parses to:
Code
||
<?xml version='1.0' encoding='UTF-8'?>
<module>
<A>
<interface>
<B>
<attribute>
<long>
<n/>
</long>
</attribute>
</B>
</interface>
</A>
</module>
||
p >>
This does not look like what we want. So we tell YML that
we have a module name after the module, an interface name after
the interface and type and name after the attribute:
>>
p > This:
Code
||
decl module @name;
decl interface @name;
decl attribute @type @name;
module A {
interface B {
attribute long n;
};
};
||
p > Parses to:
Code
||
<?xml version='1.0' encoding='UTF-8'?>
<module name="A">
<interface name="B">
<attribute type="long" name="n"/>
</interface>
</module>
||
h2 id=what > What can I do with YML?
p > With YML you can:
ul {
li p > use a C-like ¬http://en.wikipedia.org/wiki/Domain-specific_language DSL¬ without writing a grammar first
li p > generate code out of this ¬http://en.wikipedia.org/wiki/Domain-specific_language DSL¬ using ¬yslt YSLT¬
li p > generate code out of ¬http://en.wikipedia.org/wiki/Unified_Modeling_Language UML¬ using ¬yslt YSLT¬ on ¬http://en.wikipedia.org/wiki/XML_Metadata_Interchange XMI¬
li p > generate code out of any XML based language like ¬http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG¬ using ¬yslt YSLT¬
li p > define a ¬http://en.wikipedia.org/wiki/Wiki wiki¬ like language in just a few lines like ¬http://fdik.org/yml/programming#wiki YHTML¬ does
li p > replace bad designed and complicated XML languages with simpler C-like ones
li p > ... and much more.
}
h2 id=howitworks > How it works: Replacing angle brackets with some Python
p > Just writing down what I wanted to have instead of XML for a sample:
Code ||
<list name="List of goods">
<head>
<columTitle>
Goods
</columnTitle>
<columnTitle>
Price
</columnTitle>
</head>
<row>
<value>
Beer
</value>
<value>
20
</value>
</row>
<row>
<value>
Wine
</value>
<value>
30
</value>
</row>
</list>
||
p > Something like that should be more easy, say, like this:
Code ||
list "List of goods" {
head title "Goods", title "Price";
row value "Beer", value 20;
row value "Wine", value 30;
}
||
h2 id=ylanguages > Y Languages
p >>
The latter is what I call an Y language – a language specified in YML. How could this be
achieved? Well, what's to do? To have the required information, how to build XML from the
script above, we need:
>>
ul {
li >>
the information, that “list of goods” is an attribute named «name», while «Goods» is
the text value of a tag
>>
li > «title» shout be written out as «columnTitle»
}
p > How to do that? Let's invent a simple definition language for that information:
Code ||
decl list(name);
decl title alias columnTitle;
||
p > Here you can ¬samples/list.yml2 download the complete list sample¬.
div id=bottom > ¬#top ^Top^¬ ¬programming >> Using YML 2¬ ¬index.en.yhtml2 (source)¬
}

+ 1
- 0
manpage.yml2 View File

@ -0,0 +1 @@
decl manpage(xmlns="http://docbook.org/ns/docbook", version="5.0", *title) alias article { title *title; content; };

+ 413
- 0
programming.en.yhtml2 View File

@ -0,0 +1,413 @@
include homepage.en.yhtml2
page "Using YML 2" {
p >>
YML 2 is a smart ¬http://en.wikipedia.org/wiki/Template_processor template language¬ and
¬http://en.wikipedia.org/wiki/Domain-specific_language DSL concept¬. This guide will give
you a feeling, for what it's worth.
>>
h2 id=wiki > Creating a Wiki like language for writing documentation
p >>
Let's say, we want to define a small Wiki system, which should be translated from a Wiki
like language into HTML. This guide is written in one using YML 2. I call it ƒYHTML. You can
view the ¬homepage.en.yhtml2 source code of what you're reading now¬. It's about writing
web pages like that:
>>
Code {
||
page "Hello, world" {
p ¬features#blockquote >>¬
Hello, world! I can link here, say:
||
>
] ¬http://en.wikipedia.org to Wikipedia¬
> \n
||
¬features#blockquote >>¬
p ¬features#blockquote >>¬
||
>
] This is ƒemphasized. And this is «code».
> \n
||
¬features#blockquote >>¬
}
||
}
p >>
Prerequisite: knowing how ¬http://en.wikipedia.org/wiki/Html#Markup HTML¬ works.
>>
h2 id=how > How does that work?
p >>