Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (28 sloc) 1.06 KB
var K = require('../krasota'),
KrasotaJSIdentity = K.KrasotaJSIdentity;
ometa KrasotaJS <: KrasotaJSIdentity {
ifStmt = stmtWithExprAndStmt(#if):i
needForSemicolonStmtEnd:se
t:s2 t:e -> i.concat(se, [s2, e])
| ^ifStmt,
needForSemicolonStmtEnd = [#stmtEnd stmtEnd]:e t:s -> {
if(e.length == 3 && e[2] != ';') {
s[1].unshift([#spaces, e[2]]); // NOTE: возможно не безопасно модифицировать, а надо создавать новый
e = [e[0], e[1], ';']
}
[e, s]
},
needForSemicolonStmtName = #exprStmt
| #varStmt
| #returnStmt
| #breakStmt
| #continueStmt
| #throwStmt
| #whileStmt
| #withStmt
| #ifStmt,
needForSemicolonStmtContent = [needForSemicolonStmtName:n apply(n):c]
needForSemicolonStmtEnd:e -> [c].concat(e),
needForSemicolonStmt = t:s1 needForSemicolonStmtContent:c -> [#stmt, s1].concat(c),
stmt = needForSemicolonStmt | ^stmt
}