Author: kkaempf Date: Tue Jul 17 17:53:05 2007 New Revision: 39476 URL: http://svn.opensuse.org/viewcvs/yast?rev=39476&view=rev Log: handle yeexpression put ( ) around triple condition fix term constant handling fix term output (incomplete !) Modified: trunk/yxmlconv/src/expressions.rb Modified: trunk/yxmlconv/src/expressions.rb URL: http://svn.opensuse.org/viewcvs/yast/trunk/yxmlconv/src/expressions.rb?rev=39476&r1=39475&r2=39476&view=diff ============================================================================== --- trunk/yxmlconv/src/expressions.rb (original) +++ trunk/yxmlconv/src/expressions.rb Tue Jul 17 17:53:05 2007 @@ -9,7 +9,13 @@ # class YConstant + def initialize + @listener = nil + @type = nil + end + def tag_start( name, attrs ) + return @listener.tag_start( name, attrs ) if @listener h = Helper.attrs2hash attrs debug "#{self}.tag_start(#{name}, #{h})" case h["type"] @@ -19,12 +25,21 @@ $output.o( '"' << h["value"] << '"' ) when "symbol" $output.o( ':' << h["value"] ) + when "term" + $output.o( [ ":", h["name"], :po ] ) + @listener = YExpression.new + @type = h["type"] else $output.o( h["value"] ) end end def tag_end( name ) + if (@listener) then + @listener = nil unless @listener.tag_end( name ) + return true + end debug "YConstant.tag_end(#{name})" + $output.o( :pc ) if @type == "term" return false if name == "const" raise "#{self}.tag_end(#{name}) UNKNOWN" end @@ -348,8 +363,7 @@ @pending = :expression when "yeterm" h = Helper.attrs2hash attrs - $output.o( h["name"] ) - $output.o( :po ) + $output.o( [ ":", h["name"], :po ] ) # FIXME else raise "#{self}.tag_start(#{name}) UNKNOWN" end @@ -442,7 +456,7 @@ @count += 1 if @pending == :block then @listener = YExpression.new - $output.o( [ :pc, ".", @name, " {", "|" ] ) + $output.o( [ :pc, ".", @name, " { ", "|" ] ) first = true @symbols.each { |sym| $output.o( :sep ) unless first @@ -855,6 +869,7 @@ case name when "yetriple" @pending = :cond + $output.o( :po ) when "cond", "true", "false" @listener = YExpression.new else @@ -874,9 +889,11 @@ raise "Unclosed yetriple, pending #{@pending}" unless @pending == nil debug "xx End of #{self}" return false - when "cond", "true" - $output.o( " ? " ) if name == "cond" - $output.o( " : " ) if name == "true" + when "cond" + $output.o( [ :pc, " ? " ] ) + @pending = nil + when "true" + $output.o( " : " ) @pending = nil when "false" @listener = nil @@ -889,6 +906,45 @@ #------------------------------------------------ +# Parse <yereference> ... +# +# +class YEReference + def initialize + @listener = nil + @type = nil + end + + def tag_start( name, attrs ) + debug "++ #{self}.tag_start(#{name}) @listener #{@listener}" + return @listener.tag_start( name, attrs ) if @listener + case name + when "yereference" + @listener = YEntry.new + $output.o( { :com => "!! reference" } ) + else + raise "#{self}.tag_start(#{name}) UNKNOWN" + end + end + + def tag_end( name ) + debug "-- #{self}.tag_end(#{name}) @listener #{@listener}" + if (@listener) then + @listener = nil unless @listener.tag_end( name ) + return true + end + case name + when "yereference" + return false + else + raise "#{self}.tag_end(#{name}) UNKNOWN" + end + return true + end +end + + +#------------------------------------------------ # # YExpression listener # Listens to tags specifying an expression @@ -947,6 +1003,8 @@ @listener = YcpCode.new when "yeis" @listener = YEIs.new + when "yereference" + @listener = YEReference.new else raise "#{self}.tag_start(#{name}) UNHANDLED" end -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org