The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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 CPU::Z80::Assembler::Stream of CPU::Z80::Assembler::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 CPU::Z80::Assembler::Stream of CPU::Z80::Assembler::Token objects that contain each of the input tokens of the input.

Each token contains a type string, a value and a CPU::Z80::Assembler::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 forms 0****H is replaced into 0x****, and the form 0****B into 0b****.

BUGS and FEEDBACK

See CPU::Z80::Assembler.

SEE ALSO

CPU::Z80::Assembler CPU::Z80::Assembler::Line CPU::Z80::Assembler::Token CPU::Z80::Assembler::Preprocessor CPU::Z80::Assembler::Macro CPU::Z80::Assembler::Stream

AUTHORS, COPYRIGHT and LICENCE

See CPU::Z80::Assembler.