some prep:
var _SECTION_RE = /^(?:(repeated)\s+)?section\s+(@|[A-Za-z0-9_-]+)\s*
$/;
var _IF_RE = /^if\s+(@|[A-Za-z0-9_-]+)(?:\s+(.*?))?\s*$/;
var _CALL_RE = /^if\s+(@|[A-Za-z0-9_-]+)(?:\s+(.*?))?\s*$/;
...
in _Compile's main while loop:
var section_match = token.match(_SECTION_RE);
if (section_match) {
var section_name = section_match[2];
var repeated = !!section_match[1];
var func = repeated ? _DoRepeatedSection : _DoSection;
log('repeated ' + repeated + ' section_name ' + section_name);
var new_block = _Section(section_name,section_name,'true');
current_block.Append([func, new_block]);
stack.push(new_block);
current_block = new_block;
continue;
}
var section_match = token.match(_IF_RE);
if (section_match) {
var predicate_target = section_match[1];
var predicate = section_match[2] || 'true';
log('if predicate_target ' + predicate_target + ' predicate ' +
predicate);
var new_block = _Section('@',predicate_target,predicate);
current_block.Append([_DoSection, new_block]);
stack.push(new_block);
current_block = new_block;
continue;
}
.................................
function _Section(section_name,predicate_target,predicate) {
var current_clause = [];
var statements = {
'default': current_clause
};
if (!Ext.isDefined(predicate_target)) {
predicate_target = section_name;
}
if (!Ext.isDefined(predicate)) {
predicate = 'true';
}
predicate = GetPredicate(predicate);
return {
section_name: section_name, // public attribute
predicate_target: predicate_target, // public attribute
predicate: predicate, // public attribute
Statements: function(clause) {
clause = clause || 'default';
return statements[clause] || [];
},
NewClause: function(clause_name) {
var new_clause = [];
statements[clause_name] = new_clause;
current_clause = new_clause;
},
Append: function(statement) {
current_clause.push(statement);
}
};
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JSON
Template" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/json-template?hl=en
-~----------~----~----~----~------~----~------~--~---