-
-
11 Aug 2021 23:01:09 UTC
- Distribution: Unisyn-Parse
- Module version: 20210810
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (0)
- Testers (6 / 37 / 39)
- Kwalitee
Bus factor: 1- 14.41% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (30.32KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- Data::Dump
- Data::Table::Text
- Nasm::X86
- Test2::API
- Test::More
- Test::Most
- feature
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- Name
- Synopsis
- Description
- Parse
- Private Methods
- getAlpha($register, $address, $index)
- getLexicalCode($register, $address, $index)
- putLexicalCode($register, $address, $index, $code)
- loadCurrentChar()
- checkStackHas($depth)
- pushElement()
- pushEmpty()
- lexicalNameFromLetter($l)
- lexicalNumberFromLetter($l)
- new2($depth, $description)
- new($depth, $description)
- error($message)
- testSet($set, $register)
- checkSet($set)
- reduce($priority)
- reduceMultiple($priority)
- accept_a()
- accept_b()
- accept_B()
- accept_d()
- accept_p()
- accept_q()
- accept_s()
- accept_v()
- parseExpressionCode()
- parseExpression(@parameters)
- MatchBrackets(@parameters)
- ClassifyNewLines(@parameters)
- ClassifyWhiteSpace(@parameters)
- T($key, $expected, $countComments)
- Index
- Installation
- Author
- Copyright
Name
Unisyn::Parse - Parse a Unisyn expression.
Synopsis
Parse a Unisyn expression.
Description
Parse a Unisyn expression.
Version "20210810".
The following sections describe the methods in each functional area of this module. For an alphabetic listing of all methods by name see Index.
Parse
Parse Unisyn expressions
parseUtf8(@parameters)
Parse a unisyn expression encoded as utf8
Parameter Description 1 @parameters Parameters
Example:
parseUtf8 V(address, $address), $size, $fail, $parse; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
printParseTree()
Print the parse tree addressed by r15
Example:
my $l = $Lex->{sampleLexicals}{vav}; Mov $start, Rd(@$l); Mov $size, scalar(@$l); parseExpressionCode; PrintOutStringNL "Result:"; PrintOutRegisterInHex r15; printParseTree; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 ok Assemble(debug => 0, eq => <<END); Push Element: r13: 0000 0000 0000 0006 New: accept initial variable New: accept initial variable r8: 0000 0000 0000 0006 r13: 0000 0001 0000 0005 accept a Push Element: r13: 0000 0001 0000 0005 r13: 0000 0002 0000 0006 accept v Push Element: r13: 0000 0002 0000 0006 New: Variable New: Variable r8: 0000 0002 0000 0006 Reduce 3: r8: 0000 0098 0000 0009 r9: 0000 0001 0000 0005 r10: 0000 0118 0000 0009 New: Term infix term New: Term infix term r8: 0000 0118 0000 0009 r8: 0000 0098 0000 0009 r8: 0000 0001 0000 0005 Result: r15: 0000 0198 0000 0009 Tree at: r15: 0000 0000 0000 0198 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0003 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0118 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0005 data: 0000 0000 0000 0098 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0006 data: 0000 0000 0000 0005 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0007 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0098 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0000 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0118 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0002 depth: 0000 0000 0000 0001 END
Private Methods
getAlpha($register, $address, $index)
Load the position of a lexical item in its alphabet from the current character
Parameter Description 1 $register Register to load 2 $address Address of start of string 3 $index Index into string
getLexicalCode($register, $address, $index)
Load the lexical code of the current character in memory into the specified register.
Parameter Description 1 $register Register to load 2 $address Address of start of string 3 $index Index into string
putLexicalCode($register, $address, $index, $code)
Put the specified lexical code into the current character in memory.
Parameter Description 1 $register Register used to load code 2 $address Address of string 3 $index Index into string 4 $code Code to put
loadCurrentChar()
Load the details of the character currently being processed so that we have the index of the character in the upper half of the current character and the lexical type of the character in the lowest byte
checkStackHas($depth)
Check that we have at least the specified number of elements on the stack
Parameter Description 1 $depth Number of elements required on the stack
Example:
my @o = (Rb(reverse 0x10, 0, 0, 1), # Open bracket Rb(reverse 0x11, 0, 0, 2), # Close bracket Rb(reverse $Ascii, 0, 0, 27), # Ascii 'a' Rb(reverse $variable, 0, 0, 27), # Variable 'a' Rb(reverse $NewLineSemiColon, 0, 0, 0), # New line semicolon Rb(reverse $semiColon, 0, 0, 0)); # Semi colon for my $o(@o) # Try converting each input element {Mov $start, $o; Mov $index, 0; loadCurrentChar; PrintOutRegisterInHex $element; } ok Assemble(debug => 0, eq => <<END); r13: 0000 0000 0000 0000 r13: 0000 0000 0000 0001 r13: 0000 0000 0000 0006 r13: 0000 0000 0000 0006 r13: 0000 0000 0000 0008 r13: 0000 0000 0000 0008 END Push rbp; Mov rbp, rsp; Push rax; Push rax; checkStackHas 2; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 IfEq Then {PrintOutStringNL "ok"}, Else {PrintOutStringNL "fail"}; checkStackHas 2; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 IfGe Then {PrintOutStringNL "ok"}, Else {PrintOutStringNL "fail"}; checkStackHas 2; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 IfGt Then {PrintOutStringNL "fail"}, Else {PrintOutStringNL "ok"}; Push rax; checkStackHas 3; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 IfEq Then {PrintOutStringNL "ok"}, Else {PrintOutStringNL "fail"}; checkStackHas 3; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 IfGe Then {PrintOutStringNL "ok"}, Else {PrintOutStringNL "fail"}; checkStackHas 3; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 IfGt Then {PrintOutStringNL "fail"}, Else {PrintOutStringNL "ok"}; ok Assemble(debug => 0, eq => <<END); ok ok ok ok ok ok END
pushElement()
Push the current element on to the stack
pushEmpty()
Push the empty element on to the stack
Example:
Mov $index, 1; pushEmpty; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 Mov rax, "[rsp]"; PrintOutRegisterInHex rax; ok Assemble(debug => 0, eq => <<END); Push Empty rax: 0000 0001 0000 000A END
lexicalNameFromLetter($l)
Lexical name for a lexical item described by its letter
Parameter Description 1 $l Letter of the lexical item
Example:
is_deeply lexicalNameFromLetter('a'), q(assign); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 is_deeply lexicalNumberFromLetter('a'), $assign;
lexicalNumberFromLetter($l)
Lexical number for a lexical item described by its letter
Parameter Description 1 $l Letter of the lexical item
Example:
is_deeply lexicalNameFromLetter('a'), q(assign); is_deeply lexicalNumberFromLetter('a'), $assign; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
new2($depth, $description)
Create a new term and put it on the stack
Parameter Description 1 $depth Stack depth to be converted 2 $description Text reason why we are creating a new term
new($depth, $description)
Create a new term
Parameter Description 1 $depth Stack depth to be converted 2 $description Text reason why we are creating a new term
Example:
Mov $index, 1; Mov rax,-1; Push rax; Mov rax, 3; Push rax; Mov rax, 2; Push rax; Mov rax, 1; Push rax; new 3, 'test'; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 Pop rax; PrintOutRegisterInHex rax; Pop rax; PrintOutRegisterInHex rax; ok Assemble(debug => 0, eq => <<END); New: test r8: 0000 0000 0000 0001 r8: 0000 0000 0000 0002 r8: 0000 0000 0000 0003 rax: 0000 0000 0000 0009 rax: FFFF FFFF FFFF FFFF END
error($message)
Die
Parameter Description 1 $message Error message
Example:
error "aaa bbbb"; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 ok Assemble(debug => 0, eq => <<END); Error: aaa bbbb Element: r13: 0000 0000 0000 0000 Index : r12: 0000 0000 0000 0000 END
testSet($set, $register)
Test a set of items, setting the Zero Flag is one matches else clear the Zero flag
Parameter Description 1 $set Set of lexical letters 2 $register Register to test
Example:
Mov r15, -1; Mov r15b, $term; testSet("ast", r15); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 PrintOutZF; testSet("as", r15); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 PrintOutZF; ok Assemble(debug => 0, eq => <<END); ZF=1 ZF=0 END
checkSet($set)
Check that one of a set of items is on the top of the stack or complain if it is not
Parameter Description 1 $set Set of lexical letters
Example:
Mov r15, -1; Mov r15b, $term; Push r15; checkSet("ast"); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 PrintOutZF; checkSet("as"); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 PrintOutZF; ok Assemble(debug => 0, eq => <<END); ZF=1 Error: Expected one of: 'as' on the stack Element: r13: 0000 0000 0000 0000 Index : r12: 0000 0000 0000 0000 END
reduce($priority)
Convert the longest possible expression on top of the stack into a term at the specified priority
Parameter Description 1 $priority Priority of the operators to reduce
Example:
Mov r15, -1; Push r15; Mov r15, $term; Push r15; Mov r15, $assign; Push r15; Mov r15, $term; Push r15; reduce 1; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 Pop r15; PrintOutRegisterInHex r15; Pop r14; PrintOutRegisterInHex r14; ok Assemble(debug => 0, eq => <<END); Reduce 3: r8: 0000 0000 0000 0009 r9: 0000 0000 0000 0005 r10: 0000 0000 0000 0009 New: Term infix term r8: 0000 0000 0000 0009 r8: 0000 0000 0000 0009 r8: 0000 0000 0000 0005 r15: 0000 0000 0000 0009 r14: FFFF FFFF FFFF FFFF END
reduceMultiple($priority)
Reduce existing operators on the stack
Parameter Description 1 $priority Priority of the operators to reduce
Example:
Mov r15, -1; Push r15; Mov r15, $OpenBracket; Push r15; reduceMultiple 1; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 Pop r15; PrintOutRegisterInHex r15; Pop r14; PrintOutRegisterInHex r14; ok Assemble(debug => 0, eq => <<END); Reduce 2: r8: 0000 0000 0000 0010 r9: 0000 0000 0000 0000 r15: 0000 0000 0000 0000 r14: FFFF FFFF FFFF FFFF END
accept_a()
Assign
accept_b()
Open
accept_B()
Closing parenthesis
accept_d()
Infix but not assign or semi-colon
accept_p()
Prefix
accept_q()
Post fix
accept_s()
Semi colon
accept_v()
Variable
parseExpressionCode()
Parse the string of classified lexical items addressed by register $start of length $length. The resulting parse tree (if any) is returned in r15.
parseExpression(@parameters)
Create a parser for an expression described by variables
Parameter Description 1 @parameters Parameters describing expression
MatchBrackets(@parameters)
Replace the low three bytes of a utf32 bracket character with 24 bits of offset to the matching opening or closing bracket. Opening brackets have even codes from 0x10 to 0x4e while the corresponding closing bracket has a code one higher.
Parameter Description 1 @parameters Parameters
Example:
my $l = $Lex->{sampleLexicals}{brackets}; Mov $start, Rd(@$l); Mov $size, scalar(@$l); parseExpressionCode; PrintOutStringNL "Result:"; PrintOutRegisterInHex r15; printParseTree; ok Assemble(debug => 0, eq => <<END); Push Element: r13: 0000 0000 0000 0006 New: accept initial variable New: accept initial variable r8: 0000 0000 0000 0006 r13: 0000 0001 0000 0005 accept a Push Element: r13: 0000 0001 0000 0005 r13: 0000 0002 0000 0000 accept b Push Element: r13: 0000 0002 0000 0000 r13: 0000 0003 0000 0000 accept b Push Element: r13: 0000 0003 0000 0000 r13: 0000 0004 0000 0000 accept b Push Element: r13: 0000 0004 0000 0000 r13: 0000 0005 0000 0006 accept v Push Element: r13: 0000 0005 0000 0006 New: Variable New: Variable r8: 0000 0005 0000 0006 r13: 0000 0006 0000 0001 accept B Reduce 3: r8: 0000 0003 0000 0000 r9: 0000 0004 0000 0000 r10: 0000 0118 0000 0009 Reduce 2: r8: 0000 0000 0000 0030 r9: 0000 0004 0000 0000 Push Element: r13: 0000 0006 0000 0001 Reduce 3: r8: 0000 0004 0000 0000 r9: 0000 0118 0000 0009 r10: 0000 0006 0000 0001 New: Bracketed term New: Bracketed term r8: 0000 0118 0000 0009 New: Brackets for term New: Brackets for term r8: 0000 0198 0000 0009 r8: 0000 0004 0000 0000 Reduce by ( term ) Reduce 3: r8: 0000 0002 0000 0000 r9: 0000 0003 0000 0000 r10: 0000 0218 0000 0009 Reduce 2: r8: 0000 0000 0000 0028 r9: 0000 0003 0000 0000 r13: 0000 0007 0000 0001 accept B Reduce 3: r8: 0000 0002 0000 0000 r9: 0000 0003 0000 0000 r10: 0000 0218 0000 0009 Reduce 2: r8: 0000 0000 0000 0028 r9: 0000 0003 0000 0000 Push Element: r13: 0000 0007 0000 0001 Reduce 3: r8: 0000 0003 0000 0000 r9: 0000 0218 0000 0009 r10: 0000 0007 0000 0001 New: Bracketed term New: Bracketed term r8: 0000 0218 0000 0009 New: Brackets for term New: Brackets for term r8: 0000 0298 0000 0009 r8: 0000 0003 0000 0000 Reduce by ( term ) Reduce 3: r8: 0000 0001 0000 0005 r9: 0000 0002 0000 0000 r10: 0000 0318 0000 0009 Reduce 2: r8: 0000 0000 0000 0020 r9: 0000 0002 0000 0000 r13: 0000 0008 0000 0003 accept d Push Element: r13: 0000 0008 0000 0003 r13: 0000 0009 0000 0000 accept b Push Element: r13: 0000 0009 0000 0000 r13: 0000 000A 0000 0006 accept v Push Element: r13: 0000 000A 0000 0006 New: Variable New: Variable r8: 0000 000A 0000 0006 r13: 0000 000B 0000 0001 accept B Reduce 3: r8: 0000 0008 0000 0003 r9: 0000 0009 0000 0000 r10: 0000 0398 0000 0009 Reduce 2: r8: 0000 0000 0000 0038 r9: 0000 0009 0000 0000 Push Element: r13: 0000 000B 0000 0001 Reduce 3: r8: 0000 0009 0000 0000 r9: 0000 0398 0000 0009 r10: 0000 000B 0000 0001 New: Bracketed term New: Bracketed term r8: 0000 0398 0000 0009 New: Brackets for term New: Brackets for term r8: 0000 0418 0000 0009 r8: 0000 0009 0000 0000 Reduce by ( term ) Reduce 3: r8: 0000 0318 0000 0009 r9: 0000 0008 0000 0003 r10: 0000 0498 0000 0009 New: Term infix term New: Term infix term r8: 0000 0498 0000 0009 r8: 0000 0318 0000 0009 r8: 0000 0008 0000 0003 Reduce 3: r8: 0000 0001 0000 0005 r9: 0000 0002 0000 0000 r10: 0000 0518 0000 0009 Reduce 2: r8: 0000 0000 0000 0020 r9: 0000 0002 0000 0000 r13: 0000 000C 0000 0001 accept B Reduce 3: r8: 0000 0001 0000 0005 r9: 0000 0002 0000 0000 r10: 0000 0518 0000 0009 Reduce 2: r8: 0000 0000 0000 0020 r9: 0000 0002 0000 0000 Push Element: r13: 0000 000C 0000 0001 Reduce 3: r8: 0000 0002 0000 0000 r9: 0000 0518 0000 0009 r10: 0000 000C 0000 0001 New: Bracketed term New: Bracketed term r8: 0000 0518 0000 0009 New: Brackets for term New: Brackets for term r8: 0000 0598 0000 0009 r8: 0000 0002 0000 0000 Reduce by ( term ) Reduce 3: r8: 0000 0098 0000 0009 r9: 0000 0001 0000 0005 r10: 0000 0618 0000 0009 New: Term infix term New: Term infix term r8: 0000 0618 0000 0009 r8: 0000 0098 0000 0009 r8: 0000 0001 0000 0005 r13: 0000 000D 0000 0008 accept s Push Element: r13: 0000 000D 0000 0008 Result: r15: 0000 0698 0000 0009 Tree at: r15: 0000 0000 0000 0698 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0003 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0618 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0005 data: 0000 0000 0000 0098 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0006 data: 0000 0000 0000 0005 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0007 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0098 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0000 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0618 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0002 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0598 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0004 data: 0000 0000 0000 0000 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0005 data: 0000 0000 0000 0002 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0598 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0518 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0518 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0003 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0498 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0005 data: 0000 0000 0000 0318 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0006 data: 0000 0000 0000 0003 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0007 data: 0000 0000 0000 0008 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0318 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0002 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0298 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0004 data: 0000 0000 0000 0000 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0005 data: 0000 0000 0000 0003 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0298 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0218 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0218 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0002 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0198 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0004 data: 0000 0000 0000 0000 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0005 data: 0000 0000 0000 0004 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0198 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0118 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0118 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0005 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0498 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0002 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0418 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0004 data: 0000 0000 0000 0000 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0005 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0418 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 0398 depth: 0000 0000 0000 0001 Tree at: r15: 0000 0000 0000 0398 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006 depth: 0000 0000 0000 0001 key: 0000 0000 0000 0003 data: 0000 0000 0000 000A depth: 0000 0000 0000 0001 END
ClassifyNewLines(@parameters)
Scan input string looking for opportunities to convert new lines into semi colons
Parameter Description 1 @parameters Parameters
ClassifyWhiteSpace(@parameters)
Classify white space per: "lib/Unisyn/whiteSpace/whiteSpaceClassification.pl"
Parameter Description 1 @parameters Parameters
T($key, $expected, $countComments)
Test a parse
Parameter Description 1 $key Key of text to be parsed 2 $expected Expected result 3 $countComments Optionally print most frequent comments to locate most generated code
Index
1 accept_a - Assign
2 accept_B - Closing parenthesis
3 accept_b - Open
4 accept_d - Infix but not assign or semi-colon
5 accept_p - Prefix
6 accept_q - Post fix
7 accept_s - Semi colon
8 accept_v - Variable
9 checkSet - Check that one of a set of items is on the top of the stack or complain if it is not
10 checkStackHas - Check that we have at least the specified number of elements on the stack
11 ClassifyNewLines - Scan input string looking for opportunities to convert new lines into semi colons
12 ClassifyWhiteSpace - Classify white space per: "lib/Unisyn/whiteSpace/whiteSpaceClassification.
13 error - Die
14 getAlpha - Load the position of a lexical item in its alphabet from the current character
15 getLexicalCode - Load the lexical code of the current character in memory into the specified register.
16 lexicalNameFromLetter - Lexical name for a lexical item described by its letter
17 lexicalNumberFromLetter - Lexical number for a lexical item described by its letter
18 loadCurrentChar - Load the details of the character currently being processed so that we have the index of the character in the upper half of the current character and the lexical type of the character in the lowest byte
19 MatchBrackets - Replace the low three bytes of a utf32 bracket character with 24 bits of offset to the matching opening or closing bracket.
20 new - Create a new term
21 new2 - Create a new term and put it on the stack
22 parseExpression - Create a parser for an expression described by variables
23 parseExpressionCode - Parse the string of classified lexical items addressed by register $start of length $length.
24 parseUtf8 - Parse a unisyn expression encoded as utf8
25 printParseTree - Print the parse tree addressed by r15
26 pushElement - Push the current element on to the stack
27 pushEmpty - Push the empty element on to the stack
28 putLexicalCode - Put the specified lexical code into the current character in memory.
29 reduce - Convert the longest possible expression on top of the stack into a term at the specified priority
30 reduceMultiple - Reduce existing operators on the stack
31 T - Test a parse
32 testSet - Test a set of items, setting the Zero Flag is one matches else clear the Zero flag
Installation
This module is written in 100% Pure Perl and, thus, it is easy to read, comprehend, use, modify and install via cpan:
sudo cpan install Unisyn::Parse
Author
Copyright
Copyright (c) 2016-2021 Philip R Brenan.
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
Module Install Instructions
To install Unisyn::Parse, copy and paste the appropriate command in to your terminal.
cpanm Unisyn::Parse
perl -MCPAN -e shell install Unisyn::Parse
For more information on module installation, please visit the detailed CPAN module installation guide.