Permalink
Browse files

value -- обертка для строчных скалярных выражений

  • Loading branch information...
1 parent 1a19283 commit e400d4d3e4981db6bbb14dff9e49f3babdd154ee @pasaran committed May 21, 2012
Showing with 57 additions and 27 deletions.
  1. +17 −3 lib/asts.js
  2. +20 −17 lib/grammar.js
  3. +1 −0 lib/yate.js
  4. +19 −7 templates/js.tmpl
View
20 lib/asts.js
@@ -498,6 +498,7 @@ asts.inline_expr.toResult = function(result) {
asts.inline_expr.inline = common.true;
+/*
asts.inline_expr.codedata$ = function(lang) {
if (this.AsType && lang !== 'yate') {
var cast = this.factory.make( 'cast', { to: this.AsType, expr: this } );
@@ -509,22 +510,23 @@ asts.inline_expr.codedata$ = function(lang) {
return this;
}
};
+*/
+/*
asts.inline_expr.code$output = function() {
return this.js('inline_output');
};
+*/
asts.inline_expr.closes = function() {
return ( this.type() != 'attr' ); // Если тип атрибут, то после него все еще могут быть другие атрибуты.
};
-/*
asts.inline_expr.transform = function() {
if (this.AsType) {
- return this.make( 'cast', { to: this.AsType, expr: this } );
+ return this.factory.make( 'cast', { to: this.AsType, expr: this } );
}
};
-*/
// --------------------------------------------------------------------------------------------------------------- //
@@ -1311,6 +1313,18 @@ asts.compound.setPrevOpened = function(prevOpened) {
// --------------------------------------------------------------------------------------------------------------- //
+asts.value = {};
+
+asts.value._getType = function() {
+ return this.Value.type();
+};
+
+asts.value.oncast = function(to) {
+ this.Value.cast(to);
+};
+
+// --------------------------------------------------------------------------------------------------------------- //
+
asts.string_content = {};
asts.string_content.options = {
View
37 lib/grammar.js
@@ -300,24 +300,26 @@ rules.var_ = function(ast) {
rules.block_expr = function() {
var r;
- if (this.test('if_')) {
+ if ( this.test('if_') ) {
r = this.match('if_');
- } else if (this.test('for_')) {
+ } else if ( this.test('for_') ) {
r = this.match('for_');
- } else if (this.test('apply')) {
+ } else if ( this.test('apply') ) {
r = this.match('apply');
- } else if (this.test('@')) {
+ } else if ( this.test('(') ) {
+ r = this.match('compound');
+ } else if ( this.test('@') ) {
r = this.match('attr');
- } else if (this.test('<')) {
+ } else if ( this.test('<') ) {
r = this.match('xml_line');
- } else if (this.test('[')) {
+ } else if ( this.test('[') ) {
r = this.match('array');
- } else if (this.test('{')) {
+ } else if ( this.test('{') ) {
r = this.match('object');
- } else if (this.test('pair')) {
+ } else if ( this.test('pair') ) {
r = this.match('pair');
} else {
- r = this.match('compound');
+ r = this.match('value');
}
return r;
@@ -432,18 +434,19 @@ rules.pair = function(ast) {
// --------------------------------------------------------------------------------------------------------------- //
-// compound := inline_expr | '(' block ')'
+// compound := '(' block ')'
rules.compound = function(ast) {
- if (this.test('inline_expr')) {
- return this.match('inline_expr');
- } else {
- this.match('(');
- ast.Block = this.match('block');
- this.match(')');
- }
+ this.match('(');
+ ast.Block = this.match('block');
+ this.match(')');
};
+// --------------------------------------------------------------------------------------------------------------- //
+
+rules.value = function(ast) {
+ ast.Value = this.match('inline_expr');
+};
// --------------------------------------------------------------------------------------------------------------- //
View
1 lib/yate.js
@@ -73,6 +73,7 @@ yate.walk = function(ast) {
});
ast.walkAfter(function(ast, params, pKey, pObject) {
+ console.error(ast.id, pKey);
if (pKey && pObject) {
var ast_ = ast.transform();
if (ast_) {
View
26 templates/js.tmpl
@@ -371,19 +371,31 @@ arglist_item :defaults [ this.Default ]
// inline expressions
// ----------------------------------------------------------------------------------------------------------------- //
+value :output [ ( this.type() === 'nodeset' || this.type() === 'boolean' ) && !this.AsType ]
+
+ r%{ Rid } = %{ Value };
+
+value :output [ this.type() === 'attr' ]
+
+ yater.copyAttrs( a%{ Rid }.attrs, %{ Value } );
+
+value :output
+
+ r%{ Rid } += %{ Value };
+
inline_var :inline_output [ this.type() === 'attr' && this.def.Lazy ]
yater.copyAttrs( a%{ Rid }.attrs, vars.get("v%{ def.Vid }", c%{ Cid }) );
inline_var :inline_output [ this.type() === 'attr' ]
yater.copyAttrs(a%{ Rid }.attrs, v%{ def.Vid });
-* :inline_output [ ( this.type() === 'nodeset' || this.type() === 'boolean' ) && !this.AsType ]
-
- r%{ Rid } = %{ . };
-
-* :inline_output
-
- r%{ Rid } += %{ . };
+//* :inline_output [ ( this.type() === 'nodeset' || this.type() === 'boolean' ) && !this.AsType ]
+//
+// r%{ Rid } = %{ . };
+//
+//* :inline_output
+//
+// r%{ Rid } += %{ . };
inline_or
%{ Left } || %{ Right }

0 comments on commit e400d4d

Please sign in to comment.