node/lib/metasm/metasm/parse_c.rb
def parse(parser, scope, allow_coma = true)
			opstack = []
			stack = []

			return if not e = parse_value(parser, scope)

			stack << e

			while op = readop(parser)
				case op.value
				when :'?'
					# a, b ? c, d : e, f  ==  a, (b ? (c, d) : e), f
					until opstack.empty? or OP_PRIO[opstack.last][:'?:']
						parse_popstack(parser, stack, opstack)
					end
					stack << parse(parser, scope)
					raise op || parser, '":" expected' if not op = readop(parser) or op.value != :':'
					op = op.dup
					op.value = :'?:'
				when :':'
					parser.unreadtok op
					break
				else
					if not allow_coma and op.value == :','
						parser.unreadtok op
						break
					end
					until opstack.empty? or OP_PRIO[op.value][opstack.last]
						parse_popstack(parser, stack, opstack)
					end
				end

				raise op, 'need rhs' if not e = parse_value(parser, scope)
				stack << e
				opstack << op.value
			end

			until opstack.empty?
				parse_popstack(parser, stack, opstack)
			end

			CExpression[stack.first]
		end
# reads a binary operator from the parser, returns the corresponding symbol or nil
reads a binary operator from the parser, returns the corresponding symbol or nil
reads a binary operator from the parser returns the corresponding symbol or nil
def parse(parser, scope, allow_coma = true)
			opstack = []
			stack = []
			return if not e = parse_value(parser, scope)
			stack << e
			while op = readop(parser)
				case op.value
				when :'?'
					until opstack.empty? or OP_PRIO[opstack.last][:'?:']
						parse_popstack(parser, stack, opstack)
					end
					stack << parse(parser, scope)
					raise op || parser, '":" expected' if not op = readop(parser) or op.value != :':'
					op = op.dup
					op.value = :'?:'
				when :':'
					parser.unreadtok op
					break
				else
					if not allow_coma and op.value == :','
						parser.unreadtok op
						break
					end
					until opstack.empty? or OP_PRIO[op.value][opstack.last]
						parse_popstack(parser, stack, opstack)
					end
				end
				raise op, 'need rhs' if not e = parse_value(parser, scope)
				stack << e
				opstack << op.value
			end
			until opstack.empty?
				parse_popstack(parser, stack, opstack)
			end
			CExpression[stack.first]
		end
def parse ( parser , scope , allow_coma = true ) opstack = [ ] stack = [ ] return if not e = parse_value ( parser , scope ) stack << e while op = readop ( parser ) case op . value when :' ? ' until opstack . empty? or OP_PRIO [ opstack . last ] [ :' ?: ' ] parse_popstack ( parser , stack , opstack ) end stack << parse ( parser , scope ) raise op || parser , '":" expected' if not op = readop ( parser ) or op . value != :' : ' op = op . dup op . value = :' ?: ' when :' : ' parser . unreadtok op break else if not allow_coma and op . value == :' , ' parser . unreadtok op break end until opstack . empty? or OP_PRIO [ op . value ] [ opstack . last ] parse_popstack ( parser , stack , opstack ) end end raise op , 'need rhs' if not e = parse_value ( parser , scope ) stack << e opstack << op . value end until opstack . empty? parse_popstack ( parser , stack , opstack ) end CExpression [ stack . first ] end
reads a binary operator from the parser, returns the corresponding symbol or nil
reads a binary operator from the parser returns the corresponding symbol or nil
# a, b ? c, d : e, f  ==  a, (b ? (c, d) : e), f
parser
scope
allow_coma