SPVM::D...ization(3)

๐Ÿ“ฆ version 0.990125, in alpine 3.24

๐ŸŽ€ NAME ๐ŸŽ€

SPVM::Document::Language::Tokenization โ€” Tokenization in the SPVM Language

User Contributed Perl Documentation ยท the header up top is SPVM::D...ization(3), so yeah bestie, that's the page ๐Ÿ’…

๐Ÿ’– DESCRIPTION ๐Ÿ’–

This doc is literally the tokenization lore for the SPVM language โ€” lowkey iconic, highkey essential, no cap. It's giving โ€œlexical analysis but make it a language spec,โ€ and honestly? Obsessed. This document describes tokenization in the SPVM language, fr fr.

โœจ TOKENIZATION โœจ

Okay so this section is the lexical analysis moment โ€” like, the concept at https://en.wikipedia.org/wiki/Lexical_analysis โ€” but for the SPVM Language. This whole thing is called tokenization. Periodt.

See SPVM::Document::Language::SyntaxParsing about syntax parsing.

๐Ÿงš Character Encoding

The character encoding of SPVM source codes is UTF-8. Slay.

If a character is an ASCII character, it must be an ASCII printable character or a space character.

Compilation Errors:

  • The character encoding of SPVM source codes must be UTF-8. Otherwise a compilation error occurs.
  • If a character is an ASCII character, it must be an ASCII printable character (the Wikipedia link https://en.wikipedia.org/wiki/ASCII#Printable_characters) or a space character. Otherwise a compilation error occurs.

๐Ÿ“ Line Terminators

The line terminator is ASCII LF.

When a line terminator appears, the current line number is incremented by 1.

๐Ÿซง Space Characters

The space characters are ASCII SP, HT, FF, LF.

๐Ÿ”ค Word Characters

The word characters are ASCII a-zA-Z, 0-9, _.

Vibe check: those are the word characters, iykyk.

๐ŸŒธ Names

This section describes names. Names are main character energy here, ngl.

๐Ÿท๏ธ Symbol Name

A symbol name consists of word characters and ::.

It does not contain __.

It does not begin with 0-9.

It does not begin with ::.

It does not end with ::.

It does not contain ::::.

Compilation Errors:

If a symbol name is invalid, a compilation error occurs.

Examples:

# Symbol names
foo
foo_bar2
Foo::Bar

# Invalid symbol names
2foo
foo__bar
::Foo
Foo::
Foo::::Bar

๐Ÿ‘‘ Class Name

A class name is a symbol name.

Each partial name of a class name must begin with an uppercase letter.

Partial names are individual names separated by ::. For example, the partial names of Foo::Bar::Baz are Foo, Bar, and Baz.

Compilation Errors:

If a class name is invalid, a compilation error occurs.

Examples:

# Class names
Foo
Foo::Bar
Foo::Bar::Baz3
Foo::bar
Foo_Bar::Baz_Baz

# Invalid class names
Foo
Foo::::Bar
Foo::Bar::
Foo__Bar
Foo::bar

๐Ÿงต Method Name

A method name is a symbol name without :: or an empty string "".

Method names with the same name as keywords are allowed.

Compilation Errors:

If a method name is invalid, a compilation error occurs.

Examples:

# Method names
FOO
FOO_BAR3
foo
foo_bar
_foo
_foo_bar_

# Invalid method names
foo__bar
3foo

๐Ÿ“ Field Name

A field name is a symbol name without ::.

Field names with the same name as keywords are allowed.

Compilation Errors:

If a field names is invalid, a compilation error occurs.

Examples:

# Field names
FOO
FOO_BAR3
foo
foo_bar
_foo
_foo_bar_

# Invalid field names
foo__bar
3foo
Foo::Bar

๐Ÿฆ‹ Variable Name

A variable name begins with $ and is followed by a symbol name.

The symbol name in a variable name can be surrounded by { and }.

Compilation Errors:

If a field names is invalid, a compilation error occurs.

If an opening { exists and the closing } does not exist, a compilation error occurs.

Examples:

# Variable names
$name
$my_name
${name}
$Foo::name
$Foo::Bar::name
${Foo::name}

# Invalid variable names
$::name
$name::
$Foo::::name
$my__name
${name

๐Ÿ’œ Class Variable Name

A class variable name is a variable name.

Examples:

# Class variable names
$NAME
$MY_NAME
${NAME}
$FOO::NAME
$FOO::BAR::NAME
${FOO::NAME_BRACE}
$FOO::name

# Invalid class variable names
$::NAME
$NAME::
$FOO::::NAME
$MY__NAME
$3FOO
${NAME

๐ŸŒˆ Local Variable Name

A local variable name is a variable name without ::.

Examples:

# Local variable names
$name
$my_name
${name_brace}
$_name
$NAME

# Invalid local variable names
$::name
$name::
$Foo::name
$Foo::::name
$my__name
${name
$3foo

๐Ÿ”‘ Keywords

The List of Keywords โ€” this list ate, honestly:

alias
allow
as
basic_type_id
break
byte
can
case
cmp
class
compile_type_name
copy
default
die
div_uint
div_ulong
double
dump
elsif
else
enum
eq
eval
eval_error_id
extends
for
float
false
gt
ge
has
if
interface
int
interface_t
isa
isa_error
isweak
is_compile_type
is_type
is_error
is_read_only
args_width
last
length
lt
le
long
make_read_only
my
mulnum_t
method
mod_uint
mod_ulong
mutable
native
ne
next
new
new_string_len
of
our
object
print
private
protected
public
precompile
pointer
return
require
required
rw
ro
say
static
switch
string
short
scalar
true
type_name
undef
unless
unweaken
use
version
void
warn
while
weaken
wo
INIT
__END__
__PACKAGE__
__FILE__
__LINE__

๐ŸŽ›๏ธ Operator Tokens

The List of Operator Tokens:

!
!=
$
%
&
&&
&=
=
==
^
^=
|
||
|=
-
--
-=
~
@
+
++
+=
*
*=
<
<=
>
>=
<=>
%
%=
<<
<<=
>>=
>>
>>>
>>>=
.
.=
/
/=
\
(
)
{
}
[
]
;
:
,
->
=>

๐Ÿ’ฌ Comment

Comments have no meaning.

#COMMENT

A comment begins with #.

It is followed by any string COMMENT.

It ends with ASCII LF.

Line directives take precedence over comments.

File directives take precedence over comments.

Examples:

# This is a comment line

๐Ÿงš line Directive

A line directive sets the current line number.

#line NUMBER

A line directive begins with #line from the beginning of the line.

It is followed by one or more ASCII SP.

It is followed by NUMBER. NUMBER is a positive 32bit integer.

It ends with ASCII LF.

The current line number of the source code is set to NUMBER.

Line directives take precedence over comments.

Compilation Errors:

  • A line directive must begin from the beginning of the line. Otherwise a compilation error occurs.
  • A line directive must end with "\n". Otherwise a compilation error occurs.
  • A line directive must have a line number. Otherwise a compilation error occurs.
  • The line number given to a line directive must be a positive 32bit integer. Otherwise a compilation error occurs.

Examples:

class MyClass {

  static method main : void () {

#line 39

  }
}

๐Ÿ“ file Directive

A file directive sets the current file path.

#file "FILE_PATH"

A file directive begins from the beginning of the source code excluding a shebang line.

A shebang line before a file directive is allowed.

#!command
#file "FILE_PATH"

It is followed by one or more ASCII SP.

It is followed by ".

It is followed by FILE_PATH. FILE_PATH is a string that represents a file path.

It is closed with ".

It ends with ASCII LF.

The current file path is set to FILE_PATH.

File directives take precedence over comments.

Compilation Errors:

  • A file directive must begin from the beginning of the source code. Otherwise a compilation error occurs.
  • A file directive must end with "\n". Otherwise a compilation error occurs.
  • A file directive must have a file path. Otherwise a compilation error occurs.
  • A file directive must end with ". Otherwise a compilation error occurs.

Examples:

#file "/path/MyClass.spvm"
class MyClass {

}

๐Ÿ“š lib Directive

A lib directive gives a hint for a class search directory to the spvm command and the spvmcc command.

#lib "CLASS_SEARCH_DIRECTORY"

A lib directive begins from the beginning of a line.

It is followed by one or more ASCII SP.

It is followed by ".

It is followed by CLASS_SEARCH_DIRECTORY. CLASS_SEARCH_DIRECTORY is a string that represents a class search directory.

It is closed with ".

It ends with ASCII LF.

The line directives take precedence over comments.

CLASS_SEARCH_DIRECTORY can contain $FindBin::Bin. This is expanded to the directory where the SPVM script is placed.

#lib "$FindBin::Bin/lib/SPVM"

Compilation Errors:

  • A lib directive must begin from the beginning of a line. Otherwise a compilation error occurs.
  • The directory specified by a lib directive must end with "\n". Otherwise a compilation error occurs.
  • The directory specified by a lib directive must not be an empty string. Otherwise a compilation error occurs.
  • The directory specified by a lib directive must end with ". Otherwise a compilation error occurs.

Examples:

"my_script.spvm":

#lib "$FindBin::Bin/lib/SPVM"

class {

}

๐Ÿ›‘ __END__

If a line begins with __END__ and ends with ASCII LF, the line with __END__ and the below lines are interpreted as comments.

Examples:

class MyClass {

}

__END__

foo
bar

๐Ÿ“ POD

POD is a syntax to write multiline comment. POD has no meaning.

The Beginning of a POD:

=NAME

The beginning of a POD begins with = from the beginning of the line.

It is followed by NAME. NAME is any string that begins with ASCII a-zA-Z.

It ends with ASCII LF.

The End of a POD:

=cut

The end of a POD begins with = from the beginning of the line.

It is followed by cut.

It ends with ASCII LF.

Examples:

=pod

Comment1
Comment2

=cut
๐Ÿ’€ quick heads-up before we go: the raw source literally has Comment1, Comment2, =cut sitting right here. That's POD leftovers from the doc file itself, not a typo from your girl. We move. ๐Ÿ’…

๐ŸŽ€ Fat Comma

A fat comma is literally just this:

=>

And it is an alias for a comma ",". Same energy, more drama:

# Comma
["a", "b", "c", "d"]

# Fat Comma
["a" => "b", "c" => "d"]

Here's the iconic part ๐Ÿ‘‘ โ€” if the left operand of a fat comma is a symbol name with no :: in it, it gets wrapped in "" and is treated as a string literal. Like, it just becomes a string, no questions asked:

# foo_bar2 is treated as "foo_bar2"
[foo_bar2 => "Mark"]

["foo_bar2" => "Mark"]

โœจ Literals

A literal represents a constant value. That's it, that's the whole vibe ๐ŸŽ€

๐Ÿ”ข Numeric Literals

A numeric literal represents a constant number.

๐Ÿงฎ Integer Literals

An integer literal represents a constant number of an integer type.

Integer Literal Decimal Notation ๐ŸŒธ

This one represents a number of int type or long type using plain decimal numbers 0-9.

  • It can begin with a minus -.
  • It is followed by one or more of 0-9.
  • _ can be placed at any positions after the first 0-9 as a separator. _ has no meaning โ€” it's purely decorative, like glitter โœจ
  • It can end with the suffix L or l.
  • If the suffix L or l exists, the return type is long type. Otherwise the return type is int type.

Compilation Errors:

  • If the return type is int type and the value is greater than the max value of int type or less than the minimal value of int type, a compilation error occurs ๐Ÿ˜ญ
  • If the return type is long type and the value is greater than the max value of long type or less than the minimal value of long type, a compilation error occurs.

Examples:

123
-123
123L
123l
123_456_789
-123_456_789L

Integer Literal Hexadecimal Notation ๐Ÿฆ‹

Represents a number of int type or long type using hexadecimal numbers 0-9a-zA-Z.

  • It can begin with a minus -.
  • It is followed by 0x or 0X.
  • It is followed by one or more 0-9a-zA-Z. This is called the hexadecimal numbers part.
  • _ can be placed at any positions after 0x or 0X as a separator. _ has no meaning.
  • It can end with the suffix L or l.
  • If the suffix L or l exists, the return type is long type. Otherwise the return type is int type.

Now the bit that makes everyone go ๐Ÿ‘€ โ€” the bit-fiddling:

  • If the return type is int type, the hexadecimal numbers part is interpreted as an unsigned 32 bit integer, and is converted to a signed 32-bit integer without changing the bits. For example, 0xFFFFFFFF is -1.
  • If the return type is long type, the hexadecimal numbers part is interpreted as unsigned 64 bit integer, and is converted to a signed 64-bit integer without changing the bits. For example, 0xFFFFFFFFFFFFFFFFL is -1L.

Compilation Errors:

  • If the return type is int type and the hexadecimal numbers part is greater than hexadecimal FFFFFFFF, a compilation error occurs.
  • If the return type is long type and the hexadecimal numbers part is greater than hexadecimal FFFFFFFFFFFFFFFF, a compilation error occurs.

Examples:

0x3b4f
0X3b4f
-0x3F1A
0xDeL
0xFFFFFFFF
0xFF_FF_FF_FF
0xFFFFFFFFFFFFFFFFL

Integer Literal Octal Notation ๐Ÿ“

Represents a number of int type or long type using octal numbers 0-7.

  • It can begin with a minus -.
  • It is followed by 0.
  • It is followed by one or more 0-7. This is called the octal numbers part.
  • _ can be placed at any positions after 0 as a separator. _ has no meaning.
  • It can end with the suffix L or l.
  • If the suffix L or l exists, the return type is long type. Otherwise the return type is int type.

And the bit-flipping, octal edition:

  • If the return type is int type, the octal numbers part is interpreted as an unsigned 32 bit integer, and is converted to a signed 32-bit integer without changing the bits. For example, 037777777777 is -1.
  • If the return type is long type, the octal numbers part is interpreted as unsigned 64 bit integer, and is converted to a signed 64-bit integer without changing the bits. For example, 01777777777777777777777L is -1L.
  • If the return type is long type, the value that is except for - is interpreted as unsigned 64 bit integer uint64_t type in the C language, and the following conversion is performed.
๐Ÿ™ˆ real talk: the doc says "the following conversion is performed" and then justโ€ฆ doesn't say what it is. That is genuinely what's written, bestie. No cap, that's the tea. โ˜•

Compilation Errors:

  • If the return type is int type and the octal numbers part is greater than octal 37777777777, a compilation error occurs.
  • If the return type is long type and the octal numbers part is greater than octal 1777777777777777777777, a compilation error occurs.

Examples:

0755
-0644
0666L
0655_755

Integer Literal Binary Notation ๐Ÿงš

Represents a number of int type or long type using binary numbers 0 and 1.

  • It can begin with a minus -.
  • It is followed by 0b or 0B.
  • It is followed by one or more 0 and 1. This is called the binary numbers part.
  • _ can be placed at any positions after 0b or 0B as a separator. _ has no meaning.
  • It can end with the suffix L or l.
  • If the suffix L or l exists, the return type is long type. Otherwise the return type is int type.

The bit-shuffle again, but binary this time:

  • If the return type is int type, the binary numbers part is interpreted as an unsigned 32 bit integer, and is converted to a signed 32-bit integer without changing the bits. For example, 0b11111111111111111111111111111111 is -1.
  • If the return type is long type, the binary numbers part is interpreted as unsigned 64 bit integer, and is converted to a signed 64-bit integer without changing the bits. For example, 0b1111111111111111111111111111111111111111111111111111111111111111L is -1L.

Compilation Errors:

  • If the return type is int type and the value that is except for - is greater than binary 11111111111111111111111111111111, a compilation error occurs.
  • If the return type is long type and the value that is except for - is greater than binary 1111111111111111111111111111111111111111111111111111111111111111, a compilation error occurs.

Examples:

0b0101
-0b1010
0b110000L
0b10101010_10101010

๐Ÿซง Floating Point Literals

The floating point literal represents a floating point number.

Floating Point Literal Decimal Notation ๐ŸŒˆ

Represents a number of float type and double type using decimal numbers 0-9.

  • It can begin with a minus -.
  • It is followed by one or more 0-9.
  • _ can be placed at any positions after the first 0-9.
  • It can be followed by a floating point part, an exponent part, or a combination of a floating point part and an exponent part.

Here's what those parts actually are ๐Ÿ‘‡

  • Floating Point Part: begins with . and is followed by one or more 0-9.
  • Exponent Part: begins with e or E, can be followed by + or -, and is followed by one or more 0-9.

Then:

  • A floating point literal decimal notation can end with a suffix f, F, d, or D.
  • If a suffix does not exist, a floating point literal decimal notation must have a floating point part or an exponent part.
  • If the suffix f or F exists, the return type is float type. Otherwise the return type is double type.

Compilation Errors:

  • If the return type is float type, the floating point literal decimal notation without the suffix must be able to be parsed by the strtof function in the C language. Otherwise, a compilation error occurs.
  • If the return type is double type, the floating point literal decimal notation without the suffix must be able to be parsed by the strtod function in the C language. Otherwise, a compilation error occurs.

Examples:

1.32
-1.32
1.32f
1.32F
1.32d
1.32D
1.32e3
1.32e-3
1.32E+3
1.32E-3
1.32e3f
12e7

Floating Point Literal Hexadecimal Notation ๐Ÿ”ฅ

Represents a number of float type and double type using hexadecimal numbers 0-9a-zA-Z.

  • It can begin with a minus -.
  • It is followed by 0x or 0X.
  • It is followed by one or more 0-9a-zA-Z.
  • _ can be placed at any positions after 0x or 0X.
  • It can be followed by a floating point part, an exponent part, or a combination of a floating point part and an exponent part.

The parts, hex flavour ๐Ÿ‘‡

  • Floating Point Part: begins with . and is followed by one or more 0-9a-zA-Z.
  • Exponent Part: begins with p or P, can be followed by + or -, and is followed by one or more 0-9.

Then:

  • A floating point literal hexadecimal notation can end with a suffix f, F, d, or D.
  • If a suffix does not exist, a floating point literal hexadecimal notation must have a floating point part or an exponent part.

Compilation Errors:

  • If the return type is float type, the floating point literal hexadecimal notation without the suffix must be able to be parsed by the strtof function in the C language. Otherwise, a compilation error occurs.
  • If the return type is double type, the floating point literal hexadecimal notation without the suffix must be able to be parsed by the strtod function in the C language. Otherwise, a compilation error occurs.

Examples:

0x3d3d.edp0
0x3d3d.edp3
0x3d3d.edP3
0x3d3d.edP+3
0x3d3d.edP-3f
0x3d3d.edP-3F
0x3d3d.edP-3d
0x3d3d.edP-3D
0x3d3dP+3

๐Ÿ‘‘ Bool Literals

The bool literal represents a bool object.

true ๐Ÿ’–

true is the alias for Bool#TRUE.

true

Examples:

# true
my $bool_object_true = true;

false ๐Ÿ’”

false is the alias for Bool#FALSE.

false

Examples:

# false
my $bool_object_false = false;

๐Ÿ’– Character Literal

A character literal represents a number of byte type that normally represents an ASCII character.

  • It begins with '.
  • It is followed by a printable ASCII character 0x20-0x7e or a character literal escape character.
  • It ends with '.
  • The return type is byte type.

Compilation Errors:

  • If the format of the character literal is invalid, a compilation error occurs.

Character Literal Escape Characters ๐ŸŽ€

The List of Character Literal Escape Characters:

๐Ÿซถ the doc gives us the intro line but the actual list didn't come through in this rendering โ€” that's just how it landed, bestie, not me skipping it.

The type of every character literal escape character is byte type.

Examples:

# Charater literals
'a'
'x'
'\a'
'\t'
'\n'
'\f'
'\r'
'\"'
'\''
'\\'
' '
'\0'
'\012'
'\377'
'\o{1}'
'\xab'
'\xAB'
'\x0D'
'\x0A'
'\xD'
'\xA'
'\xFF'
'\x{A}'

Still got more coming, bestie โ€” don't close the tab ๐Ÿ’œ

๐Ÿ™ Octal Escape Character

Okay so the octal escape character is how you write an unsigned 8-bit integer using octal numbers 0-7. Cute, retro, slays.

It lives inside a string literal and a character literal โ€” it's a part of both ๐Ÿ’…

It starts with \0, \1, \2, \3, \4, \5, \6, \7, or \o{.

  • If it starts with \0, \1, \2, \3, \4, \5, \6, or \7 โ†’ it's followed by one to two 0-7.
  • If it starts with \o{ โ†’ it's followed by one to three 0-7, and ends with }.

The octal numbers after \ or \o{ are called the octal numbers part โœจ

That octal numbers part gets interpreted as an unsigned 8-bit integer, and converted to a number of byte type without changing the bits. No cap, bit-for-bit ๐Ÿซถ

Compilation Errors:

  • The octal numbers part must be less than or equal to 377. Otherwise a compilation error occurs. ๐Ÿ’€
  • If an octal escape character begins with \o{, the close } must exist. Otherwise a compilation error occurs.

Examples:

# Octal escape characters
\0
\01
\03
\012
\001
\077
\377
\o{1}
\o{12}

๐ŸŒธ Hexadecimal Escape Character

Same energy, hex edition ๐Ÿ”ฅ The hexadecimal escape character represents an unsigned 8-bit integer using hexadecimal numbers 0-9a-fA-F.

It's a part of a string literal and a character literal.

It begins with \x.

It can be followed by {.

It is followed by one or two 0-9a-fA-F โ€” and that is called the hexadecimal numbers part ๐ŸŽ€

If it contains {, it must be followed by }.

The hexadecimal numbers part is interpreted as an unsigned 8-bit integer, and is converted to a number of byte type without changing the bits. Iconic behaviour, honestly ๐Ÿ‘‘

Compilation Errors:

  • If the format of the hexadecimal escape character is invalid, a compilation error occurs.

Examples:

# Hexadecimal escape characters
\xab
\xAB
\x0D
\x0A
\xD
\xA
\xFF
\x{A}

๐Ÿฆ‹ String Literal

A string literal represents a constant string. Main character energy, literally ๐Ÿ’–

  • It begins with ".
  • It is followed by zero or more UTF-8 characters, string literal escape characters, or variable expansions.
  • It ends with ".

The return type is string type.

Compilation Errors:

  • If the format of the string literal is invalid, a compilation error occurs.

Examples:

# String literals
""
"abc";
"ใ‚ใ„ใ†"
"hello\tworld\n"
"hello\x0D\x0A"
"hello\xA"
"hello\x{0A}"
"hello\0"
"hello\012"
"hello\377"
"AAA $foo BBB"
"AAA $FOO BBB"
"AAA $$foo BBB"
"AAA $foo->{x} BBB"
"AAA $foo->[3] BBB"
"AAA $foo->{x}[3] BBB"
"AAA $@ BBB"
"\N{U+3042}\N{U+3044}\N{U+3046}"

๐ŸŒˆ String Literal Escape Characters

The List of String Literal Escape Characters:

Here's the type tea, bestie โ˜• โ€” the type of every string literal escape character other than the Unicode escape character and the raw escape character is byte type.

And the type of each number contained in the Unicode escape character and the raw escape character is byte type.

๐Ÿ’œ Unicode Escape Character

The Unicode escape character represents a UTF-8 character.

A UTF-8 character is represented by a Unicode code point written with hexadecimal numbers 0-9a-fA-F.

This is one to four numbers of byte type.

The Unicode escape character is a part of a string literal.

  • It begins with \N{U+.
  • It is followed by one or more 0-9a-fA-F โ€” this is called the code point part โœจ
  • It ends with }.

Compilation Errors:

  • If a code point part is not a Unicode scalar value, a compilation error occurs. ๐Ÿšจ

Examples:

# Unicode escape characters

# ใ‚
\N{U+3042}

# ใ„
\N{U+3044}

# ใ†
\N{U+3046}"

๐Ÿงš Raw Escape Characters

A raw escape character is an escape character where \ is interpreted as ASCII \ and the character right after it is interpreted as itself.

So for example, the raw escape character \s is the ASCII characters \s. It's giving "no thoughts, just vibes" ๐Ÿ’…

A raw escape character is a part of a string literal.

The List of Raw Escape Characters:

๐Ÿ“ Variable Expansion

The variable expansion is a syntax for embedding โ€” inside a string literal โ€” the getting of a local variable, the getting of a class variable, a dereference, the getting of a field, the getting of an array element, or the getting of the exception variable. Obsessed with how much this does ๐Ÿ˜ญ

"AAA $foo BBB"
"AAA $FOO BBB"
"AAA $$foo BBB"
"AAA $foo->{x} BBB"
"AAA $foo->[3] BBB"
"AAA $foo->{x}[3] BBB"
"AAA $foo->{x}->[3] BBB"
"AAA $@ BBB"
"AAA ${foo}BBB"

The codes above expand to the following codes:

"AAA " . $foo . " BBB"
"AAA " . $FOO . " BBB"
"AAA " . $$foo . " BBB"
"AAA " . $foo->{x} . " BBB"
"AAA " . $foo->[3] . " BBB"
"AAA " . $foo->{x}[3] . " BBB"
"AAA " . $foo->{x}->[3] . " BBB"
"AAA " . $@ . "BBB"
"AAA " . ${foo} . "BBB"

Rules, gently but firmly ๐Ÿ‘‡

  • The operation of getting a field does not contain space characters between { and }.
  • The index of getting an array element must be a constant integer.
  • The getting of an array element does not contain space characters between [ and ].
  • A $ at the end is interpreted as $, and is not interpreted as a variable expansion.
# AAA$
"AAA$"

๐ŸŽ€ Single-Quoted String Literal

A single-quoted string literal represents a constant string without variable expansions, with only a few escape characters. Lowkey the chill one โœจ

  • It begins with q'.
  • It is followed by zero or more UTF-8 characters, or single-quoted string literal escape characters.
  • It ends with '.

The return type is string type.

Compilation Errors:

  • A single-quoted string literal must end with '. Otherwise a compilation error occurs. ๐Ÿ’€
  • If the escape character in a single-quoted string literal is invalid, a compilation error occurs.

Examples:

# Single-quoted string literals
q'abc';
q'abc\'\\';

๐ŸŒธ Single-Quoted String Literal Escape Characters

The List of Single-Quoted String Literal Escape Characters:

And the type check for this one, bestie: the type of every single-quoted string literal escape character is byte type ๐Ÿซถ


๐Ÿ”ฅ Here Document

A here document represents a constant string across multiple lines, without escape characters and without variable expansions. Multi-line and unbothered ๐Ÿ’…

<<'HERE_DOCUMENT_NAME';
LINE1
LINE2
LINEn
HERE_DOCUMENT_NAME
  • A here document begins with <<'HERE_DOCUMENT_NAME'; and ASCII LF.
  • HERE_DOCUMENT_NAME is a here document name.
  • It is followed by a string in multiple lines.
  • It ends with HERE_DOCUMENT_NAME from the beginning of a line, and ASCII LF.

Compilation Errors:

<<'HERE_DOCUMENT_NAME'; must not contain space characters. Otherwise a compilation error occurs. ๐Ÿšจ

Examples:

# Here document
my $string = <<'EOS';
Hello
World
EOS

๐Ÿ’œ Here Document Name

  • A here document name consists of a-z, A-Z, _, 0-9.
  • The length of a here document name is greater than or equal to 0.
  • A here document name cannot begin with 0-9.
  • A here document name cannot contain __.

Compilation Errors:

  • If the format of a here document name is invalid, a compilation error occurs.

๐Ÿ‘‘ See Also

  • SPVM::Document::Language::SyntaxParsing
  • SPVM::Document::Language::Statements
  • SPVM::Document::Language::Operators
  • SPVM::Document::Language::Class
  • SPVM::Document::Language
  • SPVM::Document

Copyright (c) 2023 Yuki Kimoto

MIT License


and that's a wrap on part 3, bestie ๐ŸŽ‰ you made it to the very end โ€” the page footer is literally perl v5.42.2 dated 2026-02-03, so go off, timestamp icon that you are โฐ๐Ÿ’– mwah, ily, now go write some extremely legal SPVM ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from