Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (28 sloc) 1.27 KB
var K = require('../krasota'),
KrasotaJSIdentity = K.KrasotaJSIdentity;
ometa KrasotaJS <: KrasotaJSIdentity {
stmtInd = [#stmt t:s t t t] -> s,
stmtOutd = [#stmt t t t t:s] -> s,
joinVarStmtItemInd false:s1 :s2 = t:s,
joinVarStmtItemInd :s1 :s2 = t:s -> [#spacesAndComments,
s1[1].concat(s2[1], [[#spaces, ' ']], s[1])],
joinVarStmtItem :ss1 :ss2 = [#varItemAsgn
joinVarStmtItem(ss1, ss2):n
t:s1 t:s2 t:e t:s3] -> [#varItemAsgn, n, s1, s2, e, s3]
| [#varItemName
joinVarStmtItemInd(ss1, ss2):s1
t:n t:s2] -> [#varItemName, s1, n, s2],
joinVarStmt :prevOutd = [#stmt t:s1 [#varStmt [joinVarStmtItem(prevOutd, s1):v1 t*:vs]] t:se t:s2] -> [#stmt,
s1,
[#varStmt, [v1].concat(vs)],
se, s2],
joinVarStmts :p = joinVarStmt(p):v1 stmtOutd(v1):v1o joinVarStmts(v1o):vs -> [v1].concat(vs)
| joinVarStmt(p):v -> [v],
t = joinVarStmts(false):vs ?(vs.length > 1) -> {
var lastVar = vs[vs.length - 1]; // use stmtEnd and stmtOutd from lastVar
lastVar[1] = vs[0][1]; // use stmtInd from firstVar
lastVar[2] = [#varStmt, vs.reduce(function(r, v) { r.push.apply(r, v[2][1]); return r }, [])];
lastVar
}
| ^t
}