node/lib/metasm/metasm/preprocessor.rb
# returns the next value from lexer (parenthesised expression, immediate, variable, unary operators)
# single-line only, and does not handle multibyte char string
returns the next value from lexer (parenthesised expression, immediate, variable, unary operators)
single-line only, and does not handle multibyte char string
returns the next value from lexer ( parenthesised expression immediate variable unary operators ) single - line only and does not handle multibyte char string
def parse_value(lexer)
			nil while tok = lexer.readtok and tok.type == :space
			return if not tok
			case tok.type
			when :string
				parse_intfloat(lexer, tok)
				val = tok.value || tok.raw
			when :quoted
				if tok.raw[0] != ?' or tok.value.length > 1	
					lexer.unreadtok tok
					return
				end
				val = tok.value[0]
			when :punct
				case tok.raw
				when '('
					val = parse(lexer)
					nil while ntok = lexer.readtok and ntok.type == :space
					raise tok, "')' expected after #{val.inspect} got #{ntok.inspect}" if not ntok or ntok.type != :punct or ntok.raw != ')'
				when '!', '+', '-', '~'
					nil while ntok = lexer.readtok and ntok.type == :space
					lexer.unreadtok ntok
					raise tok, 'need expression after unary operator' if not val = parse_value(lexer)
					val = Expression[tok.raw.to_sym, val]
				when '.'
					parse_intfloat(lexer, tok)
					if not tok.value
						lexer.unreadtok tok
						return
					end
					val = tok.value
				else
					lexer.unreadtok tok
					return
				end
			else
				lexer.unreadtok tok
				return
			end
			nil while tok = lexer.readtok and tok.type == :space
			lexer.unreadtok tok
			val
		end
def parse_value ( lexer ) nil while tok = lexer . readtok and tok . type == :space return if not tok case tok . type when :string parse_intfloat ( lexer , tok ) val = tok . value || tok . raw when :quoted if tok . raw [ 0 ] != ?' or tok . value . length > 1 lexer . unreadtok tok return end val = tok . value [ 0 ] when :punct case tok . raw when '(' val = parse ( lexer ) nil while ntok = lexer . readtok and ntok . type == :space raise tok , "')' expected after #{val.inspect} got #{ntok.inspect}" if not ntok or ntok . type != :punct or ntok . raw != ')' when '!' , '+' , '-' , '~' nil while ntok = lexer . readtok and ntok . type == :space lexer . unreadtok ntok raise tok , 'need expression after unary operator' if not val = parse_value ( lexer ) val = Expression [ tok . raw . to_sym , val ] when '.' parse_intfloat ( lexer , tok ) if not tok . value lexer . unreadtok tok return end val = tok . value else lexer . unreadtok tok return end else lexer . unreadtok tok return end nil while tok = lexer . readtok and tok . type == :space lexer . unreadtok tok val end
returns the next value from lexer (parenthesised expression, immediate, variable, unary operators)
single-line only, and does not handle multibyte char string
returns the next value from lexer ( parenthesised expression immediate variable unary operators ) single - line only and does not handle multibyte char string
# allow single-char
lexer