node/lib/metasm/metasm/parse.rb
# parses the argument list and the body from lexer
# recognize the local labels
# XXX add eax,
#      toto db 42	; zomg h4x
parses the argument list and the body from lexer
recognize the local labels
XXX add eax,
toto db 42        ; zomg h4x
parses the argument list and the body from lexer recognize the local labels XXX add eax toto db 42 ; zomg h4x
def parse_definition(lexer)
			lexer.skip_space
			while tok = lexer.nexttok and tok.type != :eol
				raise @name, 'invalid arg definition' if not tok = lexer.readtok or tok.type != :string
				@args << tok
				lexer.skip_space
				raise @name, 'invalid arg separator' if not tok = lexer.readtok or ((tok.type != :punct or tok.raw != ',') and tok.type != :eol)
				break if tok.type == :eol
				lexer.skip_space
			end
			lexer.skip_space_eol
			while tok = lexer.readtok and (tok.type != :string or tok.raw != 'endm')
				@body << tok
				if @body[-2] and @body[-2].type == :string and @body[-1].raw == ':' and (not @body[-3] or @body[-3].type == :eol) and @body[-2].raw !~ /^[1-9][0-9]*$/
					@labels << @body[-2].raw
				elsif @body[-3] and @body[-3].type == :string and @body[-2].type == :space and Data::DataSpec.include?(@body[-1].raw) and (not @body[-4] or @body[-4].type == :eol)
					@labels << @body[-3].raw
				end
			end
		end
def parse_definition ( lexer ) lexer . skip_space while tok = lexer . nexttok and tok . type != :eol raise @name , 'invalid arg definition' if not tok = lexer . readtok or tok . type != :string @args << tok lexer . skip_space raise @name , 'invalid arg separator' if not tok = lexer . readtok or ( ( tok . type != :punct or tok . raw != ',' ) and tok . type != :eol ) break if tok . type == :eol lexer . skip_space end lexer . skip_space_eol while tok = lexer . readtok and ( tok . type != :string or tok . raw != 'endm' ) @body << tok if @body [ - 2 ] and @body [ - 2 ] . type == :string and @body [ - 1 ] . raw == ':' and ( not @body [ - 3 ] or @body [ - 3 ] . type == :eol ) and @body [ - 2 ] . raw !~ / ^[1-9][0-9]*$ / @labels << @body [ - 2 ] . raw elsif @body [ - 3 ] and @body [ - 3 ] . type == :string and @body [ - 2 ] . type == :space and Data :: DataSpec . include? ( @body [ - 1 ] . raw ) and ( not @body [ - 4 ] or @body [ - 4 ] . type == :eol ) @labels << @body [ - 3 ] . raw end end end
parses the argument list and the body from lexer
recognize the local labels
XXX add eax,
toto db 42        ; zomg h4x
parses the argument list and the body from lexer recognize the local labels XXX add eax toto db 42 ; zomg h4x
# no preprocess argument list
lexer