NAME
CPU::Z80::Assembler::Lexer - Scanner for the Z80 assembler
SYNOPSIS
use CPU::Z80::Assembler::Lexer;
open($fh, $file1) or die;
my $stream = z80lexer(sub {<$fh>}, "#include 'file2'");
DESCRIPTION
This module provides a scanner to split the input source into tokens for the assembler. The scanner calls z80preprocessor from CPU::Z80::Assembler::Preprocessor to handle file includes, and CPU::Z80::Assembler::Macro to handle macro pre-processing
The tokens are returned as a Asm::Preproc::Stream of Asm::Preproc::Token. The tokens returned from the scanner are already the result of file inclusion and macro expansion.
EXPORTS
By default the 'z80lexer' subroutine is exported.
FUNCTIONS
z80lexer
This takes as parameter a list of either text lines to parse, or iterators that return text lines to parse.
The result is a Asm::Preproc::Stream of Asm::Preproc::Token objects that contain each of the input tokens of the input.
Each token contains a type string, a value and a Asm::Preproc::Line object pointing at the input line where the token was found.
TOKENS
The following tokens are returned by the stream:
type => 'reserved', value => reserved, line => ...
All the reserved words and symbols are returned in lower case letters, e.g. (type => "nop", value => "nop"), or (type => "+", value => "+").
type => "STRING", value => $string, line => ...
Single or double quoted strings are returned, without the quotes. The quote character cannot be used inside the string.
type => "NAME", value => $name, line => ...
All program identifiers, including '$'. The case is preserved, i.e. case-sensitive for labels, insensitive for assembly reserved words.
type => "NUMBER", value => $number, line => ...
Numbers are returned either in decimal, hexadecimal in the form 0x****, or binary in the form 0b****. The other forms are converted to these base forms.
BUGS and FEEDBACK
See CPU::Z80::Assembler.
SEE ALSO
CPU::Z80::Assembler CPU::Z80::Assembler::Macro Asm::Preproc Asm::Preproc::Stream Asm::Preproc::Line Asm::Preproc::Token
AUTHORS, COPYRIGHT and LICENCE
See CPU::Z80::Assembler.