blib/lib/Unisyn/Parse.pm

filter: Statementstmt 68.5% 24 / 35 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod n/a totaltotal 69.5% 32 / 46 CC 2 SCAR 6.9
CC
2
Cov
65%
create
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Build ↑ Summary
1 #!/usr/bin/perl -I/home/phil/perl/cpan/DataTableText/lib/ -I/home/phil/perl/cpan/NasmX86/lib/ -I/home/phil/perl/cpan/AsmC/lib/
2 #-------------------------------------------------------------------------------
3 # Parse a Unisyn expression.
4 # Philip R Brenan at appaapps dot com, Appa Apps Ltd Inc., 2021
5 #-------------------------------------------------------------------------------
6 # podDocumentation
7 # Finished in 13.14s, bytes: 2,655,008, execs: 465,858
8 package Unisyn::Parse;
9 our $VERSION = "20210826";
10 1 ▶use warnings FATAL => qw(all);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp qw(confess cluck);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Data::Dump qw(dump);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Data::Table::Text qw(:all !parse);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Nasm::X86 qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use feature qw(say current_sub);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 makeDieConfess;
20  
21 my $develop = -e q(/home/phil/); # Developing
22 my $arena; # We always reload the actual arena address from rax and so this is permissible
23 our $debug = 0; # Include debug code if true - the tests will fail if you do
24  
25 #D1 Create # Create a Unisyn parse of a utf8 string.
26  
27 sub create($$) # Create a new unisyn parse from a utf8 string
28 0 ▶ {my ($address, $size) = @_; # Address of utf8 source string to parse as a variable, length of string as a variable
Subroutine create: not called CC=2 SCAR=17.9
29 0 ▶ @_ == 2 or confess;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess() 0 0 0
30  
31 0 my $a = $arena = CreateArena; # Arena to hold parse tree - every parse tree gets its own arena so that we can free parses separately
32  
33 0 my $fail = V('fail');
34 0 my $parse = V('parse');
35  
36 0 $address->setReg(rax);
37 0 $size ->setReg(rdi);
38 0 Shl rdi, 3;
39  
40 0 my $p = genHash(__PACKAGE__, # Description of parse
41 arena => $a, # Arena containing tree
42 size8 => $size, # Size of source string as utf8
43 address8 => $address, # Address of source string as utf8
44 source32 => V(source32), # Source text as utf32
45 sourceSize32 => V(sourceSize32), # Size of utf32 allocation
46 sourceLength32 => V(sourceLength32), # Length of utf32 string
47 parse => $parse, # Offset to the head of the parse tree
48 fails => $fail, # Number of failures encountered in this parse
49 );
50  
51 0 $p->parseUtf8; # Parse utf8 source string
52  
53 0 $p
54 }
55  
56 #D1 Parse # Parse Unisyn expressions
57  
58 our $Lex = &lexicalData; # Lexical table definitions
59  
60 our $ses = RegisterSize rax; # Size of an element on the stack
61 our ($w1, $w2, $w3) = (r8, r9, r10); # Work registers
62 our $prevChar = r11; # The previous character parsed
63 our $index = r12; # Index of current element
64 our $element = r13; # Contains the item being parsed
65 our $start = r14; # Start of the parse string
66 our $size = r15; # Length of the input string
67 our $parseStackBase = rsi; # The base of the parsing stack in the stack
68 our $arenaReg = rax; # The arena in which we are building the parse tree
69 our $indexScale = 4; # The size of a utf32 character
70 our $lexCodeOffset = 3; # The offset in a classified character to the lexical code.
71 our $bitsPerByte = 8; # The number of bits in a byte
72  
73 our $Ascii = $$Lex{lexicals}{Ascii} {number}; # Ascii
74 our $assign = $$Lex{lexicals}{assign} {number}; # Assign
75 our $CloseBracket = $$Lex{lexicals}{CloseBracket} {number}; # Close bracket
76 our $empty = $$Lex{lexicals}{empty} {number}; # Empty element
77 our $NewLineSemiColon = $$Lex{lexicals}{NewLineSemiColon}{number}; # New line semicolon
78 our $OpenBracket = $$Lex{lexicals}{OpenBracket} {number}; # Open bracket
79 our $prefix = $$Lex{lexicals}{prefix} {number}; # Prefix operator
80 our $semiColon = $$Lex{lexicals}{semiColon} {number}; # Semicolon
81 our $suffix = $$Lex{lexicals}{suffix} {number}; # Suffix
82 our $term = $$Lex{lexicals}{term} {number}; # Term
83 our $variable = $$Lex{lexicals}{variable} {number}; # Variable
84 our $WhiteSpace = $$Lex{lexicals}{WhiteSpace} {number}; # Variable
85 our $firstSet = $$Lex{structure}{first}; # First symbols allowed
86 our $lastSet = $$Lex{structure}{last}; # Last symbols allowed
87 our $asciiNewLine = ord("\n"); # New line in ascii
88 our $asciiSpace = ord(' '); # Space in ascii
89  
90 sub getAlpha($$$) #P Load the position of a lexical item in its alphabet from the current character.
91 {my ($register, $address, $index) = @_; # Register to load, address of start of string, index into string
92 Mov $register, "[$address+$indexScale*$index]"; # Load lexical code
93 }
94  
95 sub getLexicalCode($$$) #P Load the lexical code of the current character in memory into the specified register.
96 {my ($register, $address, $index) = @_; # Register to load, address of start of string, index into string
97 Mov $register, "[$address+$indexScale*$index+$lexCodeOffset]"; # Load lexical code
98 }
99  
100 sub putLexicalCode($$$$) #P Put the specified lexical code into the current character in memory.
101 {my ($register, $address, $index, $code) = @_; # Register used to load code, address of string, index into string, code to put
102 defined($code) or confess;
103 Mov $register, $code;
104 Mov "[$address+$indexScale*$index+$lexCodeOffset]", $register; # Save lexical code
105 }
106  
107 sub loadCurrentChar() #P 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.
108 {my $r = $element."b"; # Classification byte
109  
110 Mov $element, $index; # Load index of character as upper dword
111 Shl $element, $indexScale * $bitsPerByte; # Save the index of the character in the upper half of the register so that we know where the character came from.
112 getLexicalCode $r, $start, $index; # Load lexical classification as lowest byte
113  
114 Cmp $r, $$Lex{bracketsBase}; # Brackets , due to their frequency, start after 0x10 with open even and close odd
115 IfGe # Brackets
116 Then
117 {And $r, 1 # Bracket: 0 - open, 1 - close
118 },
119 Else
120 {Cmp $r, $Ascii; # Ascii is a type of variable
121 IfEq
122 Then
123 {Mov $r, $variable;
124 },
125 Else
126 {Cmp $r, $NewLineSemiColon; # New line semicolon is a type of semi colon
127 IfEq
128 Then
129 {Mov $r, $semiColon;
130 };
131 };
132 };
133 }
134  
135 sub checkStackHas($) #P Check that we have at least the specified number of elements on the stack.
136 {my ($depth) = @_; # Number of elements required on the stack
137 Mov $w1, $parseStackBase;
138 Sub $w1, rsp;
139 Cmp $w1, $ses * $depth;
140 }
141  
142 sub pushElement() #P Push the current element on to the stack.
143 {Push $element;
144 if ($debug)
145 {PrintOutStringNL "Push Element:";
146 PrintOutRegisterInHex $element;
147 }
148 }
149  
150 sub pushEmpty() #P Push the empty element on to the stack.
151 {Mov $w1, $index;
152 Shl $w1, $indexScale * $bitsPerByte;
153 Or $w1, $empty;
154 Push $w1;
155 if ($debug)
156 {PrintOutStringNL "Push Empty";
157 }
158 }
159  
160 sub lexicalNameFromLetter($) #P Lexical name for a lexical item described by its letter.
161 {my ($l) = @_; # Letter of the lexical item
162 my %l = $Lex->{treeTermLexicals}->%*;
163 my $n = $l{$l};
164 confess "No such lexical: $l" unless $n;
165 $n->{short}
166 }
167  
168 sub lexicalNumberFromLetter($) #P Lexical number for a lexical item described by its letter.
169 {my ($l) = @_; # Letter of the lexical item
170 my $n = lexicalNameFromLetter $l;
171 my $N = $Lex->{lexicals}{$n}{number};
172 confess "No such lexical named: $n" unless defined $N;
173 $N
174 }
175  
176 sub new($$) #P Create a new term in the parse tree rooted on the stack.
177 {my ($depth, $description) = @_; # Stack depth to be converted, text reason why we are creating a new term
178 PrintOutStringNL "New: $description" if $debug;
179  
180 $arena->bs->getReg($arenaReg); # Address arena
181 my $t = $arena->CreateTree; # Create a tree in the arena to hold the details of the lexical elements on the stack
182 my $d = V(data);
183 $t->insert(V(key, 0), V(data, $term)); # Create a term - we only have terms at the moment in the parse tee - but that might change in the future
184 $t->insert(V(key, 1), V(data, $depth)); # The number of elements in the term
185  
186 for my $i(1..$depth) # Each term,
187 {my $j = $depth + 1 - $i;
188 Pop $w1;
189 PrintOutRegisterInHex $w1 if $debug;
190 $d->getReg($w1);
191 $t->insert( V(key, 2 * $j ), $d); # The lexical type of each operand on the even keys below 16- which actually only takes 4 bits so this could be improved on.
192  
193 Mov $w2, $w1;
194 Shr $w2, 32; # Offset in source
195 $d->getReg($w2); # Offset in source in lower dword
196 Cmp $w1."b", $term; # Check whether the lexical item on the stack is a term
197  
198 IfEq # Insert a sub tree if we are inserting a term
199 Then
200 {$t->insertTree(V(key, 2 * $j + 1), $d); # A reference to another term
201 },
202 Else # Insert the offset in the utf32 source if we are not on a term
203 {$t->insert (V(key, 2 * $j + 1), $d); # Offset in source
204 }
205 }
206 $t->first->setReg($w1); # Term
207 Shl $w1, 32; # Push offset to tree into the upper dword
208 Or $w1."b", $term; # Mark as a term tree
209 Push $w1; # Place simulated term on stack
210 }
211  
212 sub error($) #P Die.
213 {my ($message) = @_; # Error message
214 PrintOutStringNL "Error: $message";
215 PrintOutString "Element: ";
216 PrintOutRegisterInHex $element;
217 PrintOutString "Index : ";
218 PrintOutRegisterInHex $index;
219 Exit(0);
220 }
221  
222 sub testSet($$) #P Test a set of items, setting the Zero Flag is one matches else clear the Zero flag.
223 {my ($set, $register) = @_; # Set of lexical letters, Register to test
224 my @n = map {sprintf("0x%x", lexicalNumberFromLetter $_)} split //, $set; # Each lexical item by number from letter
225 my $end = Label;
226 for my $n(@n)
227 {Cmp $register."b", $n;
228 Je $end
229 }
230 ClearZF;
231 SetLabel $end;
232 }
233  
234 sub checkSet($) #P Check that one of a set of items is on the top of the stack or complain if it is not.
235 {my ($set) = @_; # Set of lexical letters
236 my @n = map {lexicalNumberFromLetter $_} split //, $set;
237 my $end = Label;
238  
239 for my $n(@n)
240 {Cmp "byte[rsp]", $n;
241 Je $end
242 }
243 error("Expected one of: '$set' on the stack");
244 ClearZF;
245 SetLabel $end;
246 }
247  
248 sub reduce($) #P Convert the longest possible expression on top of the stack into a term at the specified priority.
249 {my ($priority) = @_; # Priority of the operators to reduce
250 $priority =~ m(\A(1|3)\Z); # Level: 1 - all operators, 2 - priority 2 operators
251 my ($success, $end) = map {Label} 1..2; # Exit points
252  
253 checkStackHas 3; # At least three elements on the stack
254 IfGe
255 Then
256 {my ($l, $d, $r) = ($w1, $w2, $w3);
257 Mov $l, "[rsp+".(2*$ses)."]"; # Top 3 elements on the stack
258 Mov $d, "[rsp+".(1*$ses)."]";
259 Mov $r, "[rsp+".(0*$ses)."]";
260  
261 if ($debug)
262 {PrintOutStringNL "Reduce 3:";
263 PrintOutRegisterInHex $l, $d, $r;
264 }
265  
266 testSet("t", $l); # Parse out infix operator expression
267 IfEq
268 Then
269 {testSet("t", $r);
270 IfEq
271 Then
272 {testSet($priority == 1 ? "ads" : 'd', $d); # Reduce all operators or just reduce infix priority 3 operators
273 IfEq
274 Then
275 {Add rsp, 3 * $ses; # Reorder into polish notation
276 Push $_ for $d, $l, $r;
277 new(3, "Term infix term");
278 Jmp $success;
279 };
280 };
281 };
282  
283 testSet("b", $l); # Parse parenthesized term
284 IfEq
285 Then
286 {testSet("B", $r);
287 IfEq
288 Then
289 {testSet("t", $d);
290 IfEq
291 Then
292 {Add rsp, $ses;
293 new(1, "Bracketed term");
294 new(2, "Brackets for term");
295 PrintOutStringNL "Reduce by ( term )" if $debug;
296 Jmp $success;
297 };
298 };
299 };
300 # KeepFree $l, $d, $r;
301 };
302  
303 checkStackHas 2; # At least two elements on the stack
304 IfGe # Convert an empty pair of parentheses to an empty term
305 Then
306 {my ($l, $r) = ($w1, $w2);
307  
308 if ($debug)
309 {PrintOutStringNL "Reduce 2:";
310 PrintOutRegisterInHex $l, $r;
311 }
312  
313 # KeepFree $l, $r; # Why ?
314 Mov $l, "[rsp+".(1*$ses)."]"; # Top 3 elements on the stack
315 Mov $r, "[rsp+".(0*$ses)."]";
316 testSet("b", $l); # Empty pair of parentheses
317 IfEq
318 Then
319 {testSet("B", $r);
320 IfEq
321 Then
322 {Add rsp, 2 * $ses; # Pop expression
323 Push $l; # Bracket as operator
324 new(1, "Empty brackets");
325 Jmp $success;
326 };
327 };
328 testSet("s", $l); # Semi-colon, close implies remove unneeded semi
329 IfEq
330 Then
331 {testSet("B", $r);
332 IfEq
333 Then
334 {Add rsp, 2 * $ses; # Pop expression
335 Push $r;
336 PrintOutStringNL "Reduce by ;)" if $debug;
337 Jmp $success;
338 };
339 };
340 testSet("p", $l); # Prefix, term
341 IfEq
342 Then
343 {testSet("t", $r);
344 IfEq
345 Then
346 {new(2, "Prefix term");
347 Jmp $success;
348 };
349 };
350 # KeepFree $l, $r;
351 };
352  
353 ClearZF; # Failed to match anything
354 Jmp $end;
355  
356 SetLabel $success; # Successfully matched
357 SetZF;
358  
359 SetLabel $end; # End
360 } # reduce
361  
362 sub reduceMultiple($) #P Reduce existing operators on the stack.
363 {my ($priority) = @_; # Priority of the operators to reduce
364 K('count',99)->for(sub # An improbably high but finite number of reductions
365 {my ($index, $start, $next, $end) = @_; # Execute body
366 reduce($priority);
367 Jne $end; # Keep going as long as reductions are possible
368 });
369 }
370  
371 sub accept_a() #P Assign.
372 {checkSet("t");
373 reduceMultiple 2;
374 PrintOutStringNL "accept a" if $debug;
375 pushElement;
376 }
377  
378 sub accept_b #P Open.
379 {checkSet("abdps");
380 PrintOutStringNL "accept b" if $debug;
381 pushElement;
382 }
383  
384 sub accept_B #P Closing parenthesis.
385 {checkSet("bst");
386 PrintOutStringNL "accept B" if $debug;
387 reduceMultiple 1;
388 pushElement;
389 reduceMultiple 1;
390 checkSet("bst");
391 }
392  
393 sub accept_d #P Infix but not assign or semi-colon.
394 {checkSet("t");
395 PrintOutStringNL "accept d" if $debug;
396 pushElement;
397 }
398  
399 sub accept_p #P Prefix.
400 {checkSet("abdps");
401 PrintOutStringNL "accept p" if $debug;
402 pushElement;
403 }
404  
405 sub accept_q #P Post fix.
406 {checkSet("t");
407 PrintOutStringNL "accept q" if $debug;
408 IfEq # Post fix operator applied to a term
409 Then
410 {Pop $w1;
411 pushElement;
412 Push $w1;
413 new(2, "Postfix");
414 }
415 }
416  
417 sub accept_s #P Semi colon.
418 {checkSet("bst");
419 PrintOutStringNL "accept s" if $debug;
420 Mov $w1, "[rsp]";
421 testSet("s", $w1);
422 IfEq # Insert an empty element between two consecutive semicolons
423 Then
424 {pushEmpty;
425 };
426 reduceMultiple 1;
427 pushElement;
428 }
429  
430 sub accept_v #P Variable.
431 {checkSet("abdps");
432 PrintOutStringNL "accept v" if $debug;
433 pushElement;
434 new(1, "Variable");
435 V(count,99)->for(sub # Reduce prefix operators
436 {my ($index, $start, $next, $end) = @_;
437 checkStackHas 2;
438 Jl $end;
439 my ($l, $r) = ($w1, $w2);
440 Mov $l, "[rsp+".(1*$ses)."]";
441 Mov $r, "[rsp+".(0*$ses)."]";
442 testSet("p", $l);
443 Jne $end;
444 new(2, "Prefixed variable");
445 });
446 }
447  
448 sub parseExpressionCode() #P Parse the string of classified lexical items addressed by register $start of length $length. The resulting parse tree (if any) is returned in r15.
449 {my $end = Label;
450 my $eb = $element."b"; # Contains a byte from the item being parsed
451  
452 Cmp $size, 0; # Check for empty expression
453 Je $end;
454  
455 loadCurrentChar; # Load current character
456 ### Need test for ignorable white space as first character
457 testSet($firstSet, $element);
458 IfNe
459 Then
460 {error(<<END =~ s(\n) ( )gsr);
461 Expression must start with 'opening parenthesis', 'prefix
462 operator', 'semi-colon' or 'variable'.
463 END
464 };
465  
466 testSet("v", $element); # Single variable
467 IfEq
468 Then
469 {pushElement;
470 new(1, "accept initial variable");
471 },
472 Else
473 {testSet("s", $element); # Semi
474 IfEq
475 Then
476 {pushEmpty;
477 new(1, "accept initial semicolon");
478 };
479 pushElement;
480 };
481  
482 Inc $index; # We have processed the first character above
483 Mov $prevChar, $element; # Initialize the previous lexical item
484  
485 For # Parse each utf32 character after it has been classified
486 {my ($start, $end, $next) = @_; # Start and end of the classification loop
487 loadCurrentChar; # Load current character
488  
489 PrintOutRegisterInHex $element if $debug;
490  
491 Cmp $eb, $WhiteSpace;
492 Je $next; # Ignore white space
493  
494 Cmp $eb, 1; # Brackets are singular but everything else can potential be a plurality
495 IfGt
496 Then
497 {Cmp $prevChar."b", $eb; # Compare with previous element known not to be white space or a bracket
498 Je $next
499 };
500 Mov $prevChar, $element; # Save element to previous element now we know we are on a different element
501  
502 for my $l(sort keys $Lex->{lexicals}->%*) # Each possible lexical item after classification
503 {my $x = $Lex->{lexicals}{$l}{letter};
504 next unless $x; # Skip characters that do not have a letter defined for Tree::Term because the lexical items needed to layout a file of lexical items are folded down to the actual lexical items required to represent the language independent of the textual layout with white space.
505  
506 my $n = $Lex->{lexicals}{$l}{number};
507 Comment "Compare to $n for $l";
508 Cmp $eb, $n;
509  
510 IfEq
511 Then
512 {eval "accept_$x";
513 Jmp $next
514 };
515 }
516 error("Unexpected lexical item"); # Not selected
517 } $index, $size;
518  
519 testSet($lastSet, $prevChar); # Last lexical element
520 IfNe # Incomplete expression
521 Then
522 {error("Incomplete expression");
523 };
524  
525 K('count', 99)->for(sub # Remove trailing semicolons if present
526 {my ($index, $start, $next, $end) = @_; # Execute body
527 checkStackHas 2;
528 Jl $end; # Does not have two or more elements
529 Pop $w1;
530 testSet("s", $w1); # Check that the top most element is a semi colon
531 IfNe # Not a semi colon so put it back and finish the loop
532 Then
533 {Push $w1;
534 Jmp $end;
535 };
536 });
537  
538 reduceMultiple 1; # Final reductions
539  
540 checkStackHas 1;
541 IfNe # Incomplete expression
542 Then
543 {error("Multiple expressions on stack");
544 };
545  
546 Pop r15; # The resulting parse tree
547 Shr r15, 32; # The offset of the resulting parse tree
548 SetLabel $end;
549 } # parseExpressionCode
550  
551 sub parseExpression(@) #P Create a parser for an expression described by variables.
552 {my (@parameters) = @_; # Parameters describing expression
553  
554 my $s = Subroutine
555 {my ($p) = @_; # Parameters
556 PushR $parseStackBase, map {"r$_"} 8..15;
557 $$p{source}->setReg($start); # Start of expression string after it has been classified
558 $$p{size} ->setReg($size); # Number of characters in the expression
559  
560 Mov $parseStackBase, rsp; # Set base of parse stack
561  
562 parseExpressionCode;
563  
564 $$p{parse}->getReg(r15); # Number of characters in the expression
565  
566 Mov rsp, $parseStackBase; # Remove parse stack
567 # Remove new frame
568 PopR;
569 } [qw(source size parse)], name => q(Unisyn::Parse::parse);
570  
571  
572 $s->call(@parameters);
573 } # parse
574  
575 sub MatchBrackets(@) #P 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.
576 {my (@parameters) = @_; # Parameters
577 @_ >= 1 or confess;
578  
579 my $s = Subroutine
580 {my ($p) = @_; # Parameters
581 Comment "Match brackets in utf32 text";
582  
583 my $finish = Label;
584 PushR xmm0, k7, r10, r11, r12, r13, r14, r15, rsi; # R15 current character address. r14 is the current classification. r13 the last classification code. r12 the stack depth. r11 the number of opening brackets found. r10 address of first utf32 character.
585  
586 Mov rsi, rsp; # Save stack location so we can use the stack to record the brackets we have found
587 ClearRegisters r11, r12, r15; # Count the number of brackets and track the stack depth, index of each character
588 K(three, 3)->setMaskFirst(k7); # These are the number of bytes that we are going to use for the offsets of brackets which limits the size of a program to 24 million utf32 characters
589 $$p{fail} ->getReg(r11); # Clear failure indicator
590 $$p{opens} ->getReg(r11); # Clear count of opens
591 $$p{address}->setReg(r10); # Address of first utf32 character
592 my $w = RegisterSize eax; # Size of a utf32 character
593  
594 $$p{size}->for(sub # Process each utf32 character in the block of memory
595 {my ($index, $start, $next, $end) = @_;
596 my $continue = Label;
597  
598 Mov r14b, "[r10+$w*r15+3]"; # Classification character
599  
600 Cmp r14, 0x10; # First bracket
601 Jl $continue; # Less than first bracket
602 Cmp r14, 0x4f; # Last bracket
603 Jg $continue; # Greater than last bracket
604  
605 Test r14, 1; # Zero means that the bracket is an opener
606 IfZ sub # Save an opener then continue
607 {Push r15; # Save position in input
608 Push r14; # Save opening code
609 Inc r11; # Count number of opening brackets
610 Inc r12; # Number of brackets currently open
611 Jmp $continue;
612 };
613 Cmp r12, 1; # Check that there is a bracket to match on the stack
614 IfLt sub # Nothing on stack
615 {Not r15; # Minus the offset at which the error occurred so that we can fail at zero
616 $$p{fail}->getReg(r15); # Position in input that caused the failure
617 Jmp $finish; # Return
618 };
619 Mov r13, "[rsp]"; # Peek at the opening bracket code which is on top of the stack
620 Inc r13; # Expected closing bracket
621 Cmp r13, r14; # Check for match
622 IfNe sub # Mismatch
623 {Not r15; # Minus the offset at which the error occurred so that we can fail at zero
624 $$p{fail}->getReg(r15); # Position in input that caused the failure
625 Jmp $finish; # Return
626 };
627 Pop r13; # The closing bracket matches the opening bracket
628 Pop r13; # Offset of opener
629 Dec r12; # Close off bracket sequence
630 Vpbroadcastq xmm0, r15; # Load offset of opener
631 Vmovdqu8 "[r10+$w*r13]\{k7}", xmm0; # Save offset of opener in the code for the closer - the classification is left intact so we still know what kind of bracket we have
632 Vpbroadcastq xmm0, r13; # Load offset of opener
633 Vmovdqu8 "[r10+$w*r15]\{k7}", xmm0; # Save offset of closer in the code for the openercloser - the classification is left intact so we still know what kind of bracket we have
634 SetLabel $continue; # Continue with next character
635 Inc r15; # Next character
636 });
637  
638 SetLabel $finish;
639 Mov rsp, rsi; # Restore stack
640 $$p{opens}->getReg(r11); # Number of brackets opened
641 PopR;
642 } [qw(address size fail opens)], name => q(Unisyn::Parse::MatchBrackets);
643  
644 $s->call(@parameters);
645 } # MatchBrackets
646  
647 sub ClassifyNewLines(@) #P Scan input string looking for opportunities to convert new lines into semi colons.
648 {my (@parameters) = @_; # Parameters
649 @_ >= 1 or confess;
650  
651 my $s = Subroutine
652 {my ($p) = @_; # Parameters
653 my $current = r15; # Index of the current character
654 my $middle = r14; # Index of the middle character
655 my $first = r13; # Index of the first character
656 my $address = r12; # Address of input string
657 my $size = r11; # Length of input utf32 string
658 my($c1, $c2) = (r8."b", r9."b"); # Lexical codes being tested
659  
660 PushR r8, r9, r10, r11, r12, r13, r14, r15;
661  
662 $$p{address}->setReg($address); # Address of string
663 $$p{size} ->setReg($size); # Size of string
664 Mov $current, 2; Mov $middle, 1; Mov $first, 0;
665  
666 For # Each character in input string
667 {my ($start, $end, $next) = @_; # Start, end and next labels
668  
669  
670 getLexicalCode $c1, $address, $middle; # Lexical code of the middle character
671 Cmp $c1, $WhiteSpace;
672 IfEq
673 Then
674 {getAlpha $c1, $address, $middle;
675  
676 Cmp $c1, $asciiNewLine;
677 IfEq # Middle character is a insignificant new line and thus could be a semicolon
678 Then
679 {getLexicalCode $c1, $address, $first;
680  
681 my sub makeSemiColon # Make a new line into a new line semicolon
682 {putLexicalCode $c2, $address, $middle, $NewLineSemiColon;
683 }
684  
685 my sub check_bpv # Make new line if followed by 'b', 'p' or 'v'
686 {getLexicalCode $c1, $address, $current;
687 Cmp $c1, $OpenBracket;
688  
689 IfEq
690 Then
691 {makeSemiColon;
692 },
693 Else
694 {Cmp $c1, $prefix;
695 IfEq
696 Then
697 {makeSemiColon;
698 },
699 Else
700 {Cmp $c1, $variable;
701 IfEq
702 Then
703 {makeSemiColon;
704 };
705 };
706 };
707 }
708  
709 Cmp $c1, $CloseBracket; # Check first character of sequence
710 IfEq
711 Then
712 {check_bpv;
713 },
714 Else
715 {Cmp $c1, $suffix;
716 IfEq
717 Then
718 {check_bpv;
719 },
720 Else
721 {Cmp $c1, $variable;
722 IfEq
723 Then
724 {check_bpv;
725 };
726 };
727 };
728 };
729 };
730  
731 Mov $first, $middle; Mov $middle, $current; # Find next lexical item
732 getLexicalCode $c1, $address, $current; # Current lexical code
733 Mov $middle, $current;
734 Inc $current; # Next possible character
735 For
736 {my ($start, $end, $next) = @_;
737 getLexicalCode $c2, $address, $current; # Lexical code of next character
738 Cmp $c1, $c2;
739 Jne $end; # Terminate when we are in a different lexical item
740 } $current, $size;
741 } $current, $size;
742  
743 PopR;
744 } [qw(address size)], name => q(Unisyn::Parse::ClassifyNewLines);
745  
746 $s->call(@parameters);
747 } # ClassifyNewLines
748  
749 sub ClassifyWhiteSpace(@) #P Classify white space per: "lib/Unisyn/whiteSpace/whiteSpaceClassification.pl".
750 {my (@parameters) = @_; # Parameters
751 @_ >= 1 or confess;
752  
753 my $s = Subroutine
754 {my ($p) = @_; # Parameters
755 my $eb = r15."b"; # Lexical type of current char
756 my $s = r14; # State of white space between 'a'
757 my $S = r13; # State of white space before 'a'
758 my $cb = r12."b"; # Actual character within alphabet
759 my $address = r11; # Address of input string
760 my $index = r10; # Index of current char
761 my ($w1, $w2) = (r8."b", r9."b"); # Temporary work registers
762  
763 my sub getAlpha($;$) # Load the position of a lexical item in its alphabet from the current character
764 {my ($register, $indexReg) = @_; # Register to load, optional index register
765 getAlpha $register, $address, $index // $indexReg # Supplied index or default
766 };
767  
768 my sub getLexicalCode() # Load the lexical code of the current character in memory into the current character
769 {getLexicalCode $eb, $address, $index; # Supplied index or default
770 };
771  
772 my sub putLexicalCode($;$) # Put the specified lexical code into the current character in memory.
773 {my ($code, $indexReg) = @_; # Code, optional index register
774 putLexicalCode $w1, $address, ($indexReg//$index), $code;
775 };
776  
777 PushR r8, r9, r10, r11, r12, r13, r14, r15;
778  
779 $$p{address}->setReg($address); # Address of string
780 Mov $s, -1; Mov $S, -1; Mov $index, 0; # Initial states, position
781  
782 $$p{size}->for(sub # Each character in expression
783 {my ($indexVariable, $start, $next, $end) = @_;
784  
785 $indexVariable->setReg($index);
786 getLexicalCode; # Current lexical code
787  
788 Block # Trap space before new line and detect new line after ascii
789 {my ($start, $end) = @_;
790 Cmp $index, 0; Je $end; # Start beyond the first character so we can look back one character.
791 Cmp $eb, $Ascii; Jne $end; # Current is ascii
792  
793 Mov $w1, "[$address+$indexScale*$index-$indexScale+$lexCodeOffset]"; # Previous lexical code
794 Cmp $w1, $Ascii; Jne $end; # Previous is ascii
795  
796 if (1) # Check for 's' followed by 'n' and 'a' followed by 'n'
797 {Mov $w1, "[$address+$indexScale*$index-$indexScale]"; # Previous character
798 getAlpha $w2; # Current character
799  
800 Cmp $w1, $asciiSpace; # Check for space followed by new line
801 IfEq
802 Then
803 {Cmp $w2, $asciiNewLine;
804 IfEq # Disallow 's' followed by 'n'
805 Then
806 {PrintErrStringNL "Space detected before new line at index:";
807 PrintErrRegisterInHex $index;
808 PrintErrTraceBack;
809 Exit(1);
810 };
811 };
812  
813 Cmp $w1, $asciiSpace; Je $end; # Check for 'a' followed by 'n'
814 Cmp $w1, $asciiNewLine; Je $end; # Current is 'a' but not 'n' or 's'
815 Cmp $w2, $asciiNewLine; Jne $end; # Current is 'n'
816  
817 putLexicalCode $WhiteSpace; # Mark new line as significant
818 }
819 };
820  
821 Block # Spaces and new lines between other ascii
822 {my ($start, $end) = @_;
823 Cmp $s, -1;
824 IfEq # Looking for opening ascii
825 Then
826 {Cmp $eb, $Ascii; Jne $end; # Not ascii
827 getAlpha $cb; # Current character
828 Cmp $cb, $asciiNewLine; Je $end; # Skip over new lines
829 Cmp $cb, $asciiSpace; Je $end; # Skip over spaces
830 IfEq
831 Then
832 {Mov $s, $index; Inc $s; # Ascii not space nor new line
833 };
834 Jmp $end;
835 },
836 Else # Looking for closing ascii
837 {Cmp $eb, $Ascii;
838 IfNe # Not ascii
839 Then
840 {Mov $s, -1;
841 Jmp $end
842 };
843 getAlpha $cb; # Current character
844 Cmp $cb, $asciiNewLine; Je $end; # Skip over new lines
845 Cmp $cb, $asciiSpace; Je $end; # Skip over spaces
846  
847 For # Move over spaces and new lines between two ascii characters that are neither of new line or space
848 {my ($start, $end, $next) = @_;
849 getAlpha $cb, $s; # Check for 's' or 'n'
850 Cmp $cb, $asciiSpace;
851 IfEq
852 Then
853 {putLexicalCode $WhiteSpace, $s; # Mark as significant white space.
854 Jmp $next;
855 };
856 Cmp $cb, $asciiNewLine;
857 IfEq
858 Then
859 {putLexicalCode $WhiteSpace; # Mark as significant new line
860 Jmp $next;
861 };
862 } $s, $index;
863  
864 Mov $s, $index; Inc $s;
865 };
866 };
867  
868 Block # Note: 's' preceding 'a' are significant
869 {my ($start, $end) = @_;
870 Cmp $S, -1;
871 IfEq # Looking for 's'
872 Then
873 {Cmp $eb, $Ascii; # Not 'a'
874 IfNe
875 Then
876 {Mov $S, -1;
877 Jmp $end
878 };
879 getAlpha $cb; # Actual character in alphabet
880 Cmp $cb, $asciiSpace; # Space
881 IfEq
882 Then
883 {Mov $S, $index;
884 Jmp $end;
885 };
886 },
887 Else # Looking for 'a'
888 {Cmp $eb, $Ascii; # Not 'a'
889 IfNe
890 Then
891 {Mov $S, -1;
892 Jmp $end
893 };
894 getAlpha $cb; # Actual character in alphabet
895 Cmp $cb, $asciiSpace; Je $end; # Skip 's'
896  
897 Cmp $cb, $asciiNewLine;
898 IfEq # New lines prevent 's' from preceding 'a'
899 Then
900 {Mov $s, -1;
901 Jmp $end
902 };
903  
904 For # Move over spaces to non space ascii
905 {my ($start, $end, $next) = @_;
906 putLexicalCode $WhiteSpace, $S; # Mark new line as significant
907 } $S, $index;
908 Mov $S, -1; # Look for next possible space
909 }
910 };
911 });
912  
913 $$p{size}->for(sub # Invert white space so that significant white space becomes ascii and the remainder is ignored
914 {my ($indexVariable, $start, $next, $end) = @_;
915  
916 $indexVariable->setReg($index);
917 getLexicalCode; # Current lexical code
918  
919 Block # Invert non significant white space
920 {my ($start, $end) = @_;
921 Cmp $eb, $Ascii;
922 Jne $end; # Ascii
923  
924 getAlpha $cb; # Actual character in alphabet
925 Cmp $cb, $asciiSpace;
926 IfEq
927 Then
928 {putLexicalCode $WhiteSpace;
929 Jmp $next;
930 };
931 Cmp $cb, $asciiNewLine;
932 IfEq
933 Then
934 {putLexicalCode $WhiteSpace; # Mark new line as not significant
935 Jmp $next;
936 };
937 };
938  
939 Block # Mark significant white space
940 {my ($start, $end) = @_;
941 Cmp $eb, $WhiteSpace; Jne $end; # Not significant white space
942 putLexicalCode $Ascii; # Mark as ascii
943 };
944 });
945  
946 PopR;
947 } [qw(address size)], name => q(Unisyn::Parse::ClassifyWhiteSpace);
948  
949 $s->call(@parameters);
950 } # ClassifyWhiteSpace
951  
952 sub parseUtf8($@) #P Parse a unisyn expression encoded as utf8 and return the parse tree.
953 {my ($p, @parameters) = @_; # Parse, parameters
954 @_ >= 1 or confess;
955  
956 my $s = Subroutine
957 {my ($p) = @_; # Parameters
958  
959 PrintOutStringNL "ParseUtf8" if $debug;
960  
961 PushR $arenaReg; PushZmm 0..1; # Used to hold arena and classifiers
962  
963 my $source32 = $$p{source32};
964 my $sourceSize32 = $$p{sourceSize32};
965 my $sourceLength32 = $$p{sourceLength32};
966  
967 ConvertUtf8ToUtf32 u8 => $$p{address}, size8 => $$p{size}, # Convert to utf32
968 u32 => $source32, size32 => $sourceSize32,
969 count => $sourceLength32;
970  
971 if ($debug)
972 {PrintOutStringNL "After conversion from utf8 to utf32";
973 $sourceSize32 ->outNL("Output Length: "); # Write output length
974 PrintUtf32($sourceLength32, $source32); # Print utf32
975 }
976  
977 Vmovdqu8 zmm0, "[".Rd(join ', ', $Lex->{lexicalLow} ->@*)."]"; # Each double is [31::24] Classification, [21::0] Utf32 start character
978 Vmovdqu8 zmm1, "[".Rd(join ', ', $Lex->{lexicalHigh}->@*)."]"; # Each double is [31::24] Range offset, [21::0] Utf32 end character
979  
980 ClassifyWithInRangeAndSaveOffset address=>$source32, size=>$sourceLength32; # Alphabetic classification
981 if ($debug)
982 {PrintOutStringNL "After classification into alphabet ranges";
983 PrintUtf32($sourceLength32, $source32); # Print classified utf32
984 }
985  
986 Vmovdqu8 zmm0, "[".Rd(join ', ', $Lex->{bracketsLow} ->@*)."]"; # Each double is [31::24] Classification, [21::0] Utf32 start character
987 Vmovdqu8 zmm1, "[".Rd(join ', ', $Lex->{bracketsHigh}->@*)."]"; # Each double is [31::24] Range offset, [21::0] Utf32 end character
988  
989 ClassifyWithInRange address=>$source32, size=>$sourceLength32; # Bracket classification
990 if ($debug)
991 {PrintOutStringNL "After classification into brackets";
992 PrintUtf32($sourceLength32, $source32); # Print classified brackets
993 }
994  
995 my $opens = V(opens, -1);
996 MatchBrackets address=>$source32, size=>$sourceLength32, $opens, $$p{fail}; # Match brackets
997 if ($debug)
998 {PrintOutStringNL "After bracket matching";
999 PrintUtf32($sourceLength32, $source32); # Print matched brackets
1000 }
1001  
1002 ClassifyWhiteSpace address=>$source32, size=>$sourceLength32; # Classify white space
1003 if ($debug)
1004 {PrintOutStringNL "After white space classification";
1005 PrintUtf32($sourceLength32, $source32);
1006 }
1007  
1008 ClassifyNewLines address=>$source32, size=>$sourceLength32; # Classify new lines
1009 if ($debug)
1010 {PrintOutStringNL "After classifying new lines";
1011 PrintUtf32($sourceLength32, $source32);
1012 }
1013  
1014 $$p{arena}->setReg($arenaReg); # Rather than passing the arena as a parameter to all the parsing routines we put it in rax and access it from there when needed
1015 parseExpression source=>$source32, size=>$sourceLength32, $$p{parse};
1016  
1017 $$p{parse}->outNL if $debug;
1018  
1019 PopZmm; PopR;
1020 } [qw(arena address size parse fail source32 sourceSize32 sourceLength32)],
1021 name => q(Unisyn::Parse::parseUtf8);
1022  
1023 $s->call(arena => $p->arena->bs,
1024 address => $p->address8,
1025 size => $p->size8,
1026 source32 => $p->source32,
1027 sourceSize32 => $p->sourceSize32,
1028 sourceLength32 => $p->sourceLength32,
1029 parse => $p->parse,
1030 fail => $p->fails);
1031 } # parseUtf8
1032  
1033 #D1 Print # Print a parse tree
1034  
1035 sub printLexicalItem($$$) # Print the utf8 string corresponding to a lexical item at a variable offset
1036 {my ($parse, $source32, $offset) = @_; # Parse tree, variable address of utf32 source representation, variable offset to lexical item in utf32
1037 my $t = $parse->arena->DescribeTree;
1038  
1039 my $s = Subroutine
1040 {my ($p, $s) = @_; # Parameters
1041 PushR zmm0, zmm1, rax, r14, r15;
1042 my $success = Label;
1043  
1044 $$p{source32}->setReg(r14);
1045 $$p{offset}->setReg(r15);
1046 Vmovdqu8 zmm0, "[r14+4*r15]";
1047  
1048 Pextrw rax, xmm0, 1; # Extract lexical type of first element
1049 Vpbroadcastw zmm1, ax; # Broadcast
1050 Vpcmpeqw k0, zmm0, zmm1; # Check extent of first lexical item up to 16
1051 Shr rax, 8; # Lexical type in lowest byte
1052  
1053 Mov r15, 0x55555555; # Set odd positions to one where we know the match will fail
1054 Kmovq k1, r15;
1055 Korq k2, k0, k1; # Fill in odd positions
1056  
1057 Kmovq r15, k2;
1058 Not r15; # Swap zeroes and ones
1059 Tzcnt r14, r15; # Trailing zero count is a factor two too big
1060 Shr r14, 1; # Normalized count of number of characters int name
1061  
1062 Mov r15, 0xffff; # Zero out lexical type
1063 Vpbroadcastd zmm1, r15d; # Broadcast
1064 Vpandd zmm1, zmm0, zmm1; # Remove lexical type to leave index into alphabet
1065  
1066 Cmp rax, $variable; # Test for variable
1067 IfEq
1068 Then
1069 {my $a = Rutf8 "\x{1D5D4}\x{1D5D5}\x{1D5D6}\x{1D5D7}\x{1D5D8}\x{1D5D9}\x{1D5DA}\x{1D5DB}\x{1D5DC}\x{1D5DD}\x{1D5DE}\x{1D5DF}\x{1D5E0}\x{1D5E1}\x{1D5E2}\x{1D5E3}\x{1D5E4}\x{1D5E5}\x{1D5E6}\x{1D5E7}\x{1D5E8}\x{1D5E9}\x{1D5EA}\x{1D5EB}\x{1D5EC}\x{1D5ED}\x{1D5EE}\x{1D5EF}\x{1D5F0}\x{1D5F1}\x{1D5F2}\x{1D5F3}\x{1D5F4}\x{1D5F5}\x{1D5F6}\x{1D5F7}\x{1D5F8}\x{1D5F9}\x{1D5FA}\x{1D5FB}\x{1D5FC}\x{1D5FD}\x{1D5FE}\x{1D5FF}\x{1D600}\x{1D601}\x{1D602}\x{1D603}\x{1D604}\x{1D605}\x{1D606}\x{1D607}\x{1D756}\x{1D757}\x{1D758}\x{1D759}\x{1D75A}\x{1D75B}\x{1D75C}\x{1D75D}\x{1D75E}\x{1D75F}\x{1D760}\x{1D761}\x{1D762}\x{1D763}\x{1D764}\x{1D765}\x{1D766}\x{1D767}\x{1D768}\x{1D769}\x{1D76A}\x{1D76B}\x{1D76C}\x{1D76D}\x{1D76E}\x{1D76F}\x{1D770}\x{1D771}\x{1D772}\x{1D773}\x{1D774}\x{1D775}\x{1D776}\x{1D777}\x{1D778}\x{1D779}\x{1D77A}\x{1D77B}\x{1D77C}\x{1D77D}\x{1D77E}\x{1D77F}\x{1D780}\x{1D781}\x{1D782}\x{1D783}\x{1D784}\x{1D785}\x{1D786}\x{1D787}\x{1D788}\x{1D789}\x{1D78A}\x{1D78B}\x{1D78C}\x{1D78D}\x{1D78E}\x{1D78F}";
1070 PushR zmm1;
1071 V(loop)->getReg(r14)->for(sub # Write each letter out from its position on the stack
1072 {my ($index, $start, $next, $end) = @_; # Execute body
1073 $index->setReg(r14); # Index stack
1074 ClearRegisters r15;
1075 Mov r15b, "[rsp+4*r14]"; # Load alphabet offset from stack
1076 Shl r15, 2; # Each letter is 4 bytes wide in utf8
1077 Mov r14, $a; # Alphabet address
1078 Mov r14d, "[r14+r15]"; # Alphabet letter as utf8
1079 PushR r14; # utf8 is on the stack and it is 4 bytes wide
1080 Mov rax, rsp;
1081 Mov rdi, 4;
1082 PrintOutMemory; # Print letter from stack
1083 PopR;
1084 });
1085 Jmp $success;
1086 };
1087  
1088 Cmp rax, $assign; # Test for operator
1089 IfEq
1090 Then
1091 {my $va = Rutf8 "\x{1D434}\x{1D435}\x{1D436}\x{1D437}\x{1D438}\x{1D439}\x{1D43A}\x{1D43B}\x{1D43C}\x{1D43D}\x{1D43E}\x{1D43F}\x{1D440}\x{1D441}\x{1D442}\x{1D443}\x{1D444}\x{1D445}\x{1D446}\x{1D447}\x{1D448}\x{1D449}\x{1D44A}\x{1D44B}\x{1D44C}\x{1D44D}\x{1D44E}\x{1D44F}\x{1D450}\x{1D451}\x{1D452}\x{1D453}\x{1D454}\x{1D456}\x{1D457}\x{1D458}\x{1D459}\x{1D45A}\x{1D45B}\x{1D45C}\x{1D45D}\x{1D45E}\x{1D45F}\x{1D460}\x{1D461}\x{1D462}\x{1D463}\x{1D464}\x{1D465}\x{1D466}\x{1D467}\x{1D6E2}\x{1D6E3}\x{1D6E4}\x{1D6E5}\x{1D6E6}\x{1D6E7}\x{1D6E8}\x{1D6E9}\x{1D6EA}\x{1D6EB}\x{1D6EC}\x{1D6ED}\x{1D6EE}\x{1D6EF}\x{1D6F0}\x{1D6F1}\x{1D6F2}\x{1D6F3}\x{1D6F4}\x{1D6F5}\x{1D6F6}\x{1D6F7}\x{1D6F8}\x{1D6F9}\x{1D6FA}\x{1D6FB}\x{1D6FC}\x{1D6FD}\x{1D6FE}\x{1D6FF}\x{1D700}\x{1D701}\x{1D702}\x{1D703}\x{1D704}\x{1D705}\x{1D706}\x{1D707}\x{1D708}\x{1D709}\x{1D70A}\x{1D70B}\x{1D70C}\x{1D70D}\x{1D70E}\x{1D70F}\x{1D710}\x{1D711}\x{1D712}\x{1D713}\x{1D714}\x{1D715}\x{1D716}\x{1D717}\x{1D718}\x{1D719}\x{1D71A}\x{1D71B}";
1092 PushR zmm1;
1093 V(loop)->getReg(r14)->for(sub # Write each letter out from its position on the stack
1094 {my ($index, $start, $next, $end) = @_; # Execute body
1095 $index->setReg(r14); # Index stack
1096 ClearRegisters r15;
1097 Mov r15b, "[rsp+4*r14]"; # Load alphabet offset from stack
1098 Shl r15, 2; # Each letter is 4 bytes wide in utf8
1099 Mov r14, $va; # Alphabet address
1100 Mov r14d, "[r14+r15]"; # Alphabet letter as utf8
1101 PushR r14; # utf8 is on the stack and it is 4 bytes wide
1102 Mov rax, rsp;
1103 Mov rdi, 4;
1104 PrintOutMemory; # Print letter from stack
1105 PopR;
1106 Jmp $success;
1107 });
1108 };
1109  
1110 SetLabel $success;
1111 PopR;
1112 } [qw(offset source32)],
1113 name => q(Unisyn::Parse::printLexicalItem);
1114  
1115 $s->call(offset => $offset, source32 => $source32);
1116 }
1117  
1118 sub print($) # Create a parser for an expression described by variables.
1119 {my ($parse) = @_; # Parse tree
1120 my $t = $parse->arena->DescribeTree;
1121  
1122 PushR my ($depthR) = (r12); # Recursion depth
1123  
1124 my $b = Subroutine # Print the spacing blanks to offset sub trees
1125 {V(loop, $depthR)->for(sub
1126 {PrintOutString " ";
1127 });
1128 } [], name => "Nasm::X86::Tree::dump::spaces";
1129  
1130 my $s = Subroutine # Print a tree
1131 {my ($p, $s) = @_; # Parameters, sub definition
1132  
1133 my $B = $$p{bs};
1134  
1135 $t->address->copy($$p{bs});
1136 $t->first ->copy($$p{first});
1137 $t->find(K(key, 0)); # Key 0 tells us the type of the element - normally a term
1138  
1139 If ($t->found == 0, # Not found key 0
1140 Then
1141 {PrintOutString "No type for node";
1142 Exit(1);
1143 });
1144  
1145 If ($t->data != $term, # Expected a term
1146 Then
1147 {PrintOutString "Expected a term";
1148 Exit(1);
1149 });
1150  
1151 my $operands = V(operands); # Number of operands
1152 $t->find(K(key, 1)); # Key 1 tells us the number of operands
1153 If ($t->found > 0, # Found key 1
1154 Then
1155 {$operands->copy($t->data); # Number of operands
1156 },
1157 Else
1158 {PrintOutString "Expected at least one operand";
1159 Exit(1);
1160 });
1161  
1162 $operands->for(sub # Each operand
1163 {my ($index, $start, $next, $end) = @_; # Execute body
1164 my $i = 2 + $index * 2; my $j = $i + 1; # Operand type and value
1165 $t->find($i); my $key = V(key) ->copy($t->data);
1166 $t->find($j); my $data = V(data)->copy($t->data);
1167  
1168 If ($key == $term, # Term
1169 Then
1170 {$b->call;
1171 PrintOutStringNL "Term";
1172 Inc $depthR; # Increase indentation for sub terms
1173 $s->call($B, first => $data, $$p{source32}); # Print sub tree referenced by data field
1174 Dec $depthR; # Restore existing indentation
1175 $t->first ->copy($$p{first}); # Re-establish addressability to the tree after the recursive call
1176 });
1177  
1178 If ($key == $variable, # Variable
1179 Then
1180 {$b->call;
1181 PrintOutString "Variable: ";
1182 $parse->printLexicalItem($$p{source32}, $data); # Print the variable name
1183 PrintOutNL;
1184 });
1185  
1186 If ($key == $assign, # Assign
1187 Then
1188 {$b->call;
1189 PrintOutString "Assign: ";
1190 $parse->printLexicalItem($$p{source32}, $data); # Print the variable name
1191 PrintOutNL;
1192 });
1193  
1194 If ($index == 0, # Operator followed by indented operands
1195 Then
1196 {Inc $depthR;
1197 });
1198 });
1199  
1200 Dec $depthR; # Reset indentation after operands
1201 } [qw(bs first source32)], name => "Nasm::X86::Tree::print";
1202  
1203 ClearRegisters $depthR; # Depth starts at zero
1204  
1205 $s->call($parse->arena->bs, first => $parse->parse, $parse->source32);
1206  
1207 PopR;
1208 } # print
1209  
1210 #d
1211 sub lexicalData {do {
1212 my $a = bless({
1213 alphabetRanges => 13,
1214 alphabets => {
1215 "circledLatinLetter" => "\x{24B6}\x{24B7}\x{24B8}\x{24B9}\x{24BA}\x{24BB}\x{24BC}\x{24BD}\x{24BE}\x{24BF}\x{24C0}\x{24C1}\x{24C2}\x{24C3}\x{24C4}\x{24C5}\x{24C6}\x{24C7}\x{24C8}\x{24C9}\x{24CA}\x{24CB}\x{24CC}\x{24CD}\x{24CE}\x{24CF}\x{24D0}\x{24D1}\x{24D2}\x{24D3}\x{24D4}\x{24D5}\x{24D6}\x{24D7}\x{24D8}\x{24D9}\x{24DA}\x{24DB}\x{24DC}\x{24DD}\x{24DE}\x{24DF}\x{24E0}\x{24E1}\x{24E2}\x{24E3}\x{24E4}\x{24E5}\x{24E6}\x{24E7}\x{24E8}\x{24E9}",
1216 "mathematicalBold" => "\x{1D400}\x{1D401}\x{1D402}\x{1D403}\x{1D404}\x{1D405}\x{1D406}\x{1D407}\x{1D408}\x{1D409}\x{1D40A}\x{1D40B}\x{1D40C}\x{1D40D}\x{1D40E}\x{1D40F}\x{1D410}\x{1D411}\x{1D412}\x{1D413}\x{1D414}\x{1D415}\x{1D416}\x{1D417}\x{1D418}\x{1D419}\x{1D41A}\x{1D41B}\x{1D41C}\x{1D41D}\x{1D41E}\x{1D41F}\x{1D420}\x{1D421}\x{1D422}\x{1D423}\x{1D424}\x{1D425}\x{1D426}\x{1D427}\x{1D428}\x{1D429}\x{1D42A}\x{1D42B}\x{1D42C}\x{1D42D}\x{1D42E}\x{1D42F}\x{1D430}\x{1D431}\x{1D432}\x{1D433}\x{1D6A8}\x{1D6A9}\x{1D6AA}\x{1D6AB}\x{1D6AC}\x{1D6AD}\x{1D6AE}\x{1D6AF}\x{1D6B0}\x{1D6B1}\x{1D6B2}\x{1D6B3}\x{1D6B4}\x{1D6B5}\x{1D6B6}\x{1D6B7}\x{1D6B8}\x{1D6B9}\x{1D6BA}\x{1D6BB}\x{1D6BC}\x{1D6BD}\x{1D6BE}\x{1D6BF}\x{1D6C0}\x{1D6C1}\x{1D6C2}\x{1D6C3}\x{1D6C4}\x{1D6C5}\x{1D6C6}\x{1D6C7}\x{1D6C8}\x{1D6C9}\x{1D6CA}\x{1D6CB}\x{1D6CC}\x{1D6CD}\x{1D6CE}\x{1D6CF}\x{1D6D0}\x{1D6D1}\x{1D6D2}\x{1D6D3}\x{1D6D4}\x{1D6D5}\x{1D6D6}\x{1D6D7}\x{1D6D8}\x{1D6D9}\x{1D6DA}\x{1D6DB}\x{1D6DC}\x{1D6DD}\x{1D6DE}\x{1D6DF}\x{1D6E0}\x{1D6E1}",
1217 "mathematicalBoldFraktur" => "\x{1D56C}\x{1D56D}\x{1D56E}\x{1D56F}\x{1D570}\x{1D571}\x{1D572}\x{1D573}\x{1D574}\x{1D575}\x{1D576}\x{1D577}\x{1D578}\x{1D579}\x{1D57A}\x{1D57B}\x{1D57C}\x{1D57D}\x{1D57E}\x{1D57F}\x{1D580}\x{1D581}\x{1D582}\x{1D583}\x{1D584}\x{1D585}\x{1D586}\x{1D587}\x{1D588}\x{1D589}\x{1D58A}\x{1D58B}\x{1D58C}\x{1D58D}\x{1D58E}\x{1D58F}\x{1D590}\x{1D591}\x{1D592}\x{1D593}\x{1D594}\x{1D595}\x{1D596}\x{1D597}\x{1D598}\x{1D599}\x{1D59A}\x{1D59B}\x{1D59C}\x{1D59D}\x{1D59E}\x{1D59F}",
1218 "mathematicalBoldItalic" => "\x{1D468}\x{1D469}\x{1D46A}\x{1D46B}\x{1D46C}\x{1D46D}\x{1D46E}\x{1D46F}\x{1D470}\x{1D471}\x{1D472}\x{1D473}\x{1D474}\x{1D475}\x{1D476}\x{1D477}\x{1D478}\x{1D479}\x{1D47A}\x{1D47B}\x{1D47C}\x{1D47D}\x{1D47E}\x{1D47F}\x{1D480}\x{1D481}\x{1D482}\x{1D483}\x{1D484}\x{1D485}\x{1D486}\x{1D487}\x{1D488}\x{1D489}\x{1D48A}\x{1D48B}\x{1D48C}\x{1D48D}\x{1D48E}\x{1D48F}\x{1D490}\x{1D491}\x{1D492}\x{1D493}\x{1D494}\x{1D495}\x{1D496}\x{1D497}\x{1D498}\x{1D499}\x{1D49A}\x{1D49B}\x{1D71C}\x{1D71D}\x{1D71E}\x{1D71F}\x{1D720}\x{1D721}\x{1D722}\x{1D723}\x{1D724}\x{1D725}\x{1D726}\x{1D727}\x{1D728}\x{1D729}\x{1D72A}\x{1D72B}\x{1D72C}\x{1D72D}\x{1D72E}\x{1D72F}\x{1D730}\x{1D731}\x{1D732}\x{1D733}\x{1D734}\x{1D735}\x{1D736}\x{1D737}\x{1D738}\x{1D739}\x{1D73A}\x{1D73B}\x{1D73C}\x{1D73D}\x{1D73E}\x{1D73F}\x{1D740}\x{1D741}\x{1D742}\x{1D743}\x{1D744}\x{1D745}\x{1D746}\x{1D747}\x{1D748}\x{1D749}\x{1D74A}\x{1D74B}\x{1D74C}\x{1D74D}\x{1D74E}\x{1D74F}\x{1D750}\x{1D751}\x{1D752}\x{1D753}\x{1D754}\x{1D755}",
1219 "mathematicalBoldScript" => "\x{1D4D0}\x{1D4D1}\x{1D4D2}\x{1D4D3}\x{1D4D4}\x{1D4D5}\x{1D4D6}\x{1D4D7}\x{1D4D8}\x{1D4D9}\x{1D4DA}\x{1D4DB}\x{1D4DC}\x{1D4DD}\x{1D4DE}\x{1D4DF}\x{1D4E0}\x{1D4E1}\x{1D4E2}\x{1D4E3}\x{1D4E4}\x{1D4E5}\x{1D4E6}\x{1D4E7}\x{1D4E8}\x{1D4E9}\x{1D4EA}\x{1D4EB}\x{1D4EC}\x{1D4ED}\x{1D4EE}\x{1D4EF}\x{1D4F0}\x{1D4F1}\x{1D4F2}\x{1D4F3}\x{1D4F4}\x{1D4F5}\x{1D4F6}\x{1D4F7}\x{1D4F8}\x{1D4F9}\x{1D4FA}\x{1D4FB}\x{1D4FC}\x{1D4FD}\x{1D4FE}\x{1D4FF}\x{1D500}\x{1D501}\x{1D502}\x{1D503}",
1220 "mathematicalDouble-struck" => "\x{1D538}\x{1D539}\x{1D53B}\x{1D53C}\x{1D53D}\x{1D53E}\x{1D540}\x{1D541}\x{1D542}\x{1D543}\x{1D544}\x{1D546}\x{1D54A}\x{1D54B}\x{1D54C}\x{1D54D}\x{1D54E}\x{1D54F}\x{1D550}\x{1D552}\x{1D553}\x{1D554}\x{1D555}\x{1D556}\x{1D557}\x{1D558}\x{1D559}\x{1D55A}\x{1D55B}\x{1D55C}\x{1D55D}\x{1D55E}\x{1D55F}\x{1D560}\x{1D561}\x{1D562}\x{1D563}\x{1D564}\x{1D565}\x{1D566}\x{1D567}\x{1D568}\x{1D569}\x{1D56A}\x{1D56B}",
1221 "mathematicalFraktur" => "\x{1D504}\x{1D505}\x{1D507}\x{1D508}\x{1D509}\x{1D50A}\x{1D50D}\x{1D50E}\x{1D50F}\x{1D510}\x{1D511}\x{1D512}\x{1D513}\x{1D514}\x{1D516}\x{1D517}\x{1D518}\x{1D519}\x{1D51A}\x{1D51B}\x{1D51C}\x{1D51E}\x{1D51F}\x{1D520}\x{1D521}\x{1D522}\x{1D523}\x{1D524}\x{1D525}\x{1D526}\x{1D527}\x{1D528}\x{1D529}\x{1D52A}\x{1D52B}\x{1D52C}\x{1D52D}\x{1D52E}\x{1D52F}\x{1D530}\x{1D531}\x{1D532}\x{1D533}\x{1D534}\x{1D535}\x{1D536}\x{1D537}",
1222 "mathematicalItalic" => "\x{1D434}\x{1D435}\x{1D436}\x{1D437}\x{1D438}\x{1D439}\x{1D43A}\x{1D43B}\x{1D43C}\x{1D43D}\x{1D43E}\x{1D43F}\x{1D440}\x{1D441}\x{1D442}\x{1D443}\x{1D444}\x{1D445}\x{1D446}\x{1D447}\x{1D448}\x{1D449}\x{1D44A}\x{1D44B}\x{1D44C}\x{1D44D}\x{1D44E}\x{1D44F}\x{1D450}\x{1D451}\x{1D452}\x{1D453}\x{1D454}\x{1D456}\x{1D457}\x{1D458}\x{1D459}\x{1D45A}\x{1D45B}\x{1D45C}\x{1D45D}\x{1D45E}\x{1D45F}\x{1D460}\x{1D461}\x{1D462}\x{1D463}\x{1D464}\x{1D465}\x{1D466}\x{1D467}\x{1D6E2}\x{1D6E3}\x{1D6E4}\x{1D6E5}\x{1D6E6}\x{1D6E7}\x{1D6E8}\x{1D6E9}\x{1D6EA}\x{1D6EB}\x{1D6EC}\x{1D6ED}\x{1D6EE}\x{1D6EF}\x{1D6F0}\x{1D6F1}\x{1D6F2}\x{1D6F3}\x{1D6F4}\x{1D6F5}\x{1D6F6}\x{1D6F7}\x{1D6F8}\x{1D6F9}\x{1D6FA}\x{1D6FB}\x{1D6FC}\x{1D6FD}\x{1D6FE}\x{1D6FF}\x{1D700}\x{1D701}\x{1D702}\x{1D703}\x{1D704}\x{1D705}\x{1D706}\x{1D707}\x{1D708}\x{1D709}\x{1D70A}\x{1D70B}\x{1D70C}\x{1D70D}\x{1D70E}\x{1D70F}\x{1D710}\x{1D711}\x{1D712}\x{1D713}\x{1D714}\x{1D715}\x{1D716}\x{1D717}\x{1D718}\x{1D719}\x{1D71A}\x{1D71B}",
1223 "mathematicalMonospace" => "\x{1D670}\x{1D671}\x{1D672}\x{1D673}\x{1D674}\x{1D675}\x{1D676}\x{1D677}\x{1D678}\x{1D679}\x{1D67A}\x{1D67B}\x{1D67C}\x{1D67D}\x{1D67E}\x{1D67F}\x{1D680}\x{1D681}\x{1D682}\x{1D683}\x{1D684}\x{1D685}\x{1D686}\x{1D687}\x{1D688}\x{1D689}\x{1D68A}\x{1D68B}\x{1D68C}\x{1D68D}\x{1D68E}\x{1D68F}\x{1D690}\x{1D691}\x{1D692}\x{1D693}\x{1D694}\x{1D695}\x{1D696}\x{1D697}\x{1D698}\x{1D699}\x{1D69A}\x{1D69B}\x{1D69C}\x{1D69D}\x{1D69E}\x{1D69F}\x{1D6A0}\x{1D6A1}\x{1D6A2}\x{1D6A3}",
1224 "mathematicalSans-serif" => "\x{1D5A0}\x{1D5A1}\x{1D5A2}\x{1D5A3}\x{1D5A4}\x{1D5A5}\x{1D5A6}\x{1D5A7}\x{1D5A8}\x{1D5A9}\x{1D5AA}\x{1D5AB}\x{1D5AC}\x{1D5AD}\x{1D5AE}\x{1D5AF}\x{1D5B0}\x{1D5B1}\x{1D5B2}\x{1D5B3}\x{1D5B4}\x{1D5B5}\x{1D5B6}\x{1D5B7}\x{1D5B8}\x{1D5B9}\x{1D5BA}\x{1D5BB}\x{1D5BC}\x{1D5BD}\x{1D5BE}\x{1D5BF}\x{1D5C0}\x{1D5C1}\x{1D5C2}\x{1D5C3}\x{1D5C4}\x{1D5C5}\x{1D5C6}\x{1D5C7}\x{1D5C8}\x{1D5C9}\x{1D5CA}\x{1D5CB}\x{1D5CC}\x{1D5CD}\x{1D5CE}\x{1D5CF}\x{1D5D0}\x{1D5D1}\x{1D5D2}\x{1D5D3}",
1225 "mathematicalSans-serifBold" => "\x{1D5D4}\x{1D5D5}\x{1D5D6}\x{1D5D7}\x{1D5D8}\x{1D5D9}\x{1D5DA}\x{1D5DB}\x{1D5DC}\x{1D5DD}\x{1D5DE}\x{1D5DF}\x{1D5E0}\x{1D5E1}\x{1D5E2}\x{1D5E3}\x{1D5E4}\x{1D5E5}\x{1D5E6}\x{1D5E7}\x{1D5E8}\x{1D5E9}\x{1D5EA}\x{1D5EB}\x{1D5EC}\x{1D5ED}\x{1D5EE}\x{1D5EF}\x{1D5F0}\x{1D5F1}\x{1D5F2}\x{1D5F3}\x{1D5F4}\x{1D5F5}\x{1D5F6}\x{1D5F7}\x{1D5F8}\x{1D5F9}\x{1D5FA}\x{1D5FB}\x{1D5FC}\x{1D5FD}\x{1D5FE}\x{1D5FF}\x{1D600}\x{1D601}\x{1D602}\x{1D603}\x{1D604}\x{1D605}\x{1D606}\x{1D607}\x{1D756}\x{1D757}\x{1D758}\x{1D759}\x{1D75A}\x{1D75B}\x{1D75C}\x{1D75D}\x{1D75E}\x{1D75F}\x{1D760}\x{1D761}\x{1D762}\x{1D763}\x{1D764}\x{1D765}\x{1D766}\x{1D767}\x{1D768}\x{1D769}\x{1D76A}\x{1D76B}\x{1D76C}\x{1D76D}\x{1D76E}\x{1D76F}\x{1D770}\x{1D771}\x{1D772}\x{1D773}\x{1D774}\x{1D775}\x{1D776}\x{1D777}\x{1D778}\x{1D779}\x{1D77A}\x{1D77B}\x{1D77C}\x{1D77D}\x{1D77E}\x{1D77F}\x{1D780}\x{1D781}\x{1D782}\x{1D783}\x{1D784}\x{1D785}\x{1D786}\x{1D787}\x{1D788}\x{1D789}\x{1D78A}\x{1D78B}\x{1D78C}\x{1D78D}\x{1D78E}\x{1D78F}",
1226 "mathematicalSans-serifBoldItalic" => "\x{1D63C}\x{1D63D}\x{1D63E}\x{1D63F}\x{1D640}\x{1D641}\x{1D642}\x{1D643}\x{1D644}\x{1D645}\x{1D646}\x{1D647}\x{1D648}\x{1D649}\x{1D64A}\x{1D64B}\x{1D64C}\x{1D64D}\x{1D64E}\x{1D64F}\x{1D650}\x{1D651}\x{1D652}\x{1D653}\x{1D654}\x{1D655}\x{1D656}\x{1D657}\x{1D658}\x{1D659}\x{1D65A}\x{1D65B}\x{1D65C}\x{1D65D}\x{1D65E}\x{1D65F}\x{1D660}\x{1D661}\x{1D662}\x{1D663}\x{1D664}\x{1D665}\x{1D666}\x{1D667}\x{1D668}\x{1D669}\x{1D66A}\x{1D66B}\x{1D66C}\x{1D66D}\x{1D66E}\x{1D66F}\x{1D790}\x{1D791}\x{1D792}\x{1D793}\x{1D794}\x{1D795}\x{1D796}\x{1D797}\x{1D798}\x{1D799}\x{1D79A}\x{1D79B}\x{1D79C}\x{1D79D}\x{1D79E}\x{1D79F}\x{1D7A0}\x{1D7A1}\x{1D7A2}\x{1D7A3}\x{1D7A4}\x{1D7A5}\x{1D7A6}\x{1D7A7}\x{1D7A8}\x{1D7A9}\x{1D7AA}\x{1D7AB}\x{1D7AC}\x{1D7AD}\x{1D7AE}\x{1D7AF}\x{1D7B0}\x{1D7B1}\x{1D7B2}\x{1D7B3}\x{1D7B4}\x{1D7B5}\x{1D7B6}\x{1D7B7}\x{1D7B8}\x{1D7B9}\x{1D7BA}\x{1D7BB}\x{1D7BC}\x{1D7BD}\x{1D7BE}\x{1D7BF}\x{1D7C0}\x{1D7C1}\x{1D7C2}\x{1D7C3}\x{1D7C4}\x{1D7C5}\x{1D7C6}\x{1D7C7}\x{1D7C8}\x{1D7C9}",
1227 "mathematicalSans-serifItalic" => "\x{1D608}\x{1D609}\x{1D60A}\x{1D60B}\x{1D60C}\x{1D60D}\x{1D60E}\x{1D60F}\x{1D610}\x{1D611}\x{1D612}\x{1D613}\x{1D614}\x{1D615}\x{1D616}\x{1D617}\x{1D618}\x{1D619}\x{1D61A}\x{1D61B}\x{1D61C}\x{1D61D}\x{1D61E}\x{1D61F}\x{1D620}\x{1D621}\x{1D622}\x{1D623}\x{1D624}\x{1D625}\x{1D626}\x{1D627}\x{1D628}\x{1D629}\x{1D62A}\x{1D62B}\x{1D62C}\x{1D62D}\x{1D62E}\x{1D62F}\x{1D630}\x{1D631}\x{1D632}\x{1D633}\x{1D634}\x{1D635}\x{1D636}\x{1D637}\x{1D638}\x{1D639}\x{1D63A}\x{1D63B}",
1228 "mathematicalScript" => "\x{1D49C}\x{1D49E}\x{1D49F}\x{1D4A2}\x{1D4A5}\x{1D4A6}\x{1D4A9}\x{1D4AA}\x{1D4AB}\x{1D4AC}\x{1D4AE}\x{1D4AF}\x{1D4B0}\x{1D4B1}\x{1D4B2}\x{1D4B3}\x{1D4B4}\x{1D4B5}\x{1D4B6}\x{1D4B7}\x{1D4B8}\x{1D4B9}\x{1D4BB}\x{1D4BD}\x{1D4BE}\x{1D4BF}\x{1D4C0}\x{1D4C1}\x{1D4C2}\x{1D4C3}\x{1D4C5}\x{1D4C6}\x{1D4C7}\x{1D4C8}\x{1D4C9}\x{1D4CA}\x{1D4CB}\x{1D4CC}\x{1D4CD}\x{1D4CE}\x{1D4CF}",
1229 "negativeCircledLatinLetter" => "\x{1F150}\x{1F151}\x{1F152}\x{1F153}\x{1F154}\x{1F155}\x{1F156}\x{1F157}\x{1F158}\x{1F159}\x{1F15A}\x{1F15B}\x{1F15C}\x{1F15D}\x{1F15E}\x{1F15F}\x{1F160}\x{1F161}\x{1F162}\x{1F163}\x{1F164}\x{1F165}\x{1F166}\x{1F167}\x{1F168}\x{1F169}",
1230 "negativeSquaredLatinLetter" => "\x{1F170}\x{1F171}\x{1F172}\x{1F173}\x{1F174}\x{1F175}\x{1F176}\x{1F177}\x{1F178}\x{1F179}\x{1F17A}\x{1F17B}\x{1F17C}\x{1F17D}\x{1F17E}\x{1F17F}\x{1F180}\x{1F181}\x{1F182}\x{1F183}\x{1F184}\x{1F185}\x{1F186}\x{1F187}\x{1F188}\x{1F189}",
1231 "semiColon" => "\x{27E2}",
1232 "squaredLatinLetter" => "\x{1F130}\x{1F131}\x{1F132}\x{1F133}\x{1F134}\x{1F135}\x{1F136}\x{1F137}\x{1F138}\x{1F139}\x{1F13A}\x{1F13B}\x{1F13C}\x{1F13D}\x{1F13E}\x{1F13F}\x{1F140}\x{1F141}\x{1F142}\x{1F143}\x{1F144}\x{1F145}\x{1F146}\x{1F147}\x{1F148}\x{1F149}\x{1F1A5}",
1233 },
1234 brackets => 16,
1235 bracketsBase => 16,
1236 bracketsClose => [
1237 "\x{2309}",
1238 "\x{230B}",
1239 "\x{232A}",
1240 "\x{2769}",
1241 "\x{276B}",
1242 "\x{276D}",
1243 "\x{276F}",
1244 "\x{2771}",
1245 "\x{2773}",
1246 "\x{2775}",
1247 "\x{27E7}",
1248 "\x{27E9}",
1249 "\x{27EB}",
1250 "\x{27ED}",
1251 "\x{27EF}",
1252 "\x{2984}",
1253 "\x{2986}",
1254 "\x{2988}",
1255 "\x{298A}",
1256 "\x{298C}",
1257 "\x{298E}",
1258 "\x{2990}",
1259 "\x{2992}",
1260 "\x{2994}",
1261 "\x{2996}",
1262 "\x{2998}",
1263 "\x{29FD}",
1264 "\x{2E29}",
1265 "\x{3009}",
1266 "\x{300B}",
1267 "\x{3011}",
1268 "\x{3015}",
1269 "\x{3017}",
1270 "\x{3019}",
1271 "\x{301B}",
1272 "\x{FD3F}",
1273 "\x{FF09}",
1274 "\x{FF60}",
1275 ],
1276 bracketsHigh => [
1277 "0x1300230b",
1278 "0x1500232a",
1279 "0x23002775",
1280 "0x2d0027ef",
1281 "0x43002998",
1282 "0x450029fd",
1283 "0x47002e29",
1284 "0x4b00300b",
1285 "0x4d003011",
1286 "0x5500301b",
1287 "0x5700fd3f",
1288 "0x5900ff09",
1289 "0x5b00ff60",
1290 0,
1291 0,
1292 0,
1293 ],
1294 bracketsLow => [
1295 "0x10002308",
1296 "0x14002329",
1297 "0x16002768",
1298 "0x240027e6",
1299 "0x2e002983",
1300 "0x440029fc",
1301 "0x46002e28",
1302 "0x48003008",
1303 "0x4c003010",
1304 "0x4e003014",
1305 "0x5600fd3e",
1306 "0x5800ff08",
1307 "0x5a00ff5f",
1308 0,
1309 0,
1310 0,
1311 ],
1312 bracketsOpen => [
1313 "\x{2308}",
1314 "\x{230A}",
1315 "\x{2329}",
1316 "\x{2768}",
1317 "\x{276A}",
1318 "\x{276C}",
1319 "\x{276E}",
1320 "\x{2770}",
1321 "\x{2772}",
1322 "\x{2774}",
1323 "\x{27E6}",
1324 "\x{27E8}",
1325 "\x{27EA}",
1326 "\x{27EC}",
1327 "\x{27EE}",
1328 "\x{2983}",
1329 "\x{2985}",
1330 "\x{2987}",
1331 "\x{2989}",
1332 "\x{298B}",
1333 "\x{298D}",
1334 "\x{298F}",
1335 "\x{2991}",
1336 "\x{2993}",
1337 "\x{2995}",
1338 "\x{2997}",
1339 "\x{29FC}",
1340 "\x{2E28}",
1341 "\x{3008}",
1342 "\x{300A}",
1343 "\x{3010}",
1344 "\x{3014}",
1345 "\x{3016}",
1346 "\x{3018}",
1347 "\x{301A}",
1348 "\x{FD3E}",
1349 "\x{FF08}",
1350 "\x{FF5F}",
1351 ],
1352 lexicalAlpha => {
1353 "" => [
1354 "circledLatinLetter",
1355 "mathematicalBoldFraktur",
1356 "mathematicalBoldScript",
1357 "mathematicalDouble-struck",
1358 "mathematicalFraktur",
1359 "mathematicalMonospace",
1360 "mathematicalSans-serif",
1361 "mathematicalSans-serifItalic",
1362 "mathematicalScript",
1363 "negativeSquaredLatinLetter",
1364 "semiColon",
1365 "squaredLatinLetter",
1366 ],
1367 "Ascii" => ["negativeCircledLatinLetter"],
1368 "assign" => ["mathematicalItalic"],
1369 "CloseBracket" => [],
1370 "dyad" => ["mathematicalBold"],
1371 "OpenBracket" => [],
1372 "prefix" => ["mathematicalBoldItalic"],
1373 "semiColon" => [],
1374 "suffix" => ["mathematicalSans-serifBoldItalic"],
1375 "term" => [],
1376 "variable" => ["mathematicalSans-serifBold"],
1377 },
1378 lexicalHigh => [
1379 127,
1380 10210,
1381 119859,
1382 119911,
1383 119963,
1384 120327,
1385 120431,
1386 872535777,
1387 872535835,
1388 872535893,
1389 872535951,
1390 872536009,
1391 2147610985,
1392 0,
1393 0,
1394 0,
1395 ],
1396 lexicalLow => [
1397 33554432,
1398 134227938,
1399 50451456,
1400 84005940,
1401 67228776,
1402 100783572,
1403 117560892,
1404 50452136,
1405 84006626,
1406 67229468,
1407 100783958,
1408 117561232,
1409 33681744,
1410 0,
1411 0,
1412 0,
1413 ],
1414 lexicals => bless({
1415 Ascii => bless({ letter => "a", like => "v", name => "Ascii", number => 2 }, "Unisyn::Parse::Lexical::Constant"),
1416 assign => bless({ letter => "a", like => "a", name => "assign", number => 5 }, "Unisyn::Parse::Lexical::Constant"),
1417 CloseBracket => bless({ letter => "B", like => "B", name => "CloseBracket", number => 1 }, "Unisyn::Parse::Lexical::Constant"),
1418 dyad => bless({ letter => "d", like => "d", name => "dyad", number => 3 }, "Unisyn::Parse::Lexical::Constant"),
1419 empty => bless({ letter => "e", like => "e", name => "empty", number => 10 }, "Unisyn::Parse::Lexical::Constant"),
1420 NewLineSemiColon => bless({ letter => "N", like => undef, name => "NewLineSemiColon", number => 12 }, "Unisyn::Parse::Lexical::Constant"),
1421 OpenBracket => bless({ letter => "b", like => "b", name => "OpenBracket", number => 0 }, "Unisyn::Parse::Lexical::Constant"),
1422 prefix => bless({ letter => "p", like => "p", name => "prefix", number => 4 }, "Unisyn::Parse::Lexical::Constant"),
1423 semiColon => bless({ letter => "s", like => "s", name => "semiColon", number => 8 }, "Unisyn::Parse::Lexical::Constant"),
1424 suffix => bless({ letter => "q", like => "q", name => "suffix", number => 7 }, "Unisyn::Parse::Lexical::Constant"),
1425 term => bless({ letter => "t", like => "t", name => "term", number => 9 }, "Unisyn::Parse::Lexical::Constant"),
1426 variable => bless({ letter => "v", like => "v", name => "variable", number => 6 }, "Unisyn::Parse::Lexical::Constant"),
1427 WhiteSpace => bless({ letter => "W", like => undef, name => "WhiteSpace", number => 11 }, "Unisyn::Parse::Lexical::Constant"),
1428 }, "Unisyn::Parse::Lexicals"),
1429 sampleLexicals => {
1430 brackets => [
1431 100663296,
1432 83886080,
1433 0,
1434 0,
1435 0,
1436 100663296,
1437 16777216,
1438 16777216,
1439 50331648,
1440 0,
1441 100663296,
1442 16777216,
1443 16777216,
1444 134217728,
1445 ],
1446 nosemi => [
1447 100663296,
1448 83886080,
1449 0,
1450 0,
1451 0,
1452 100663296,
1453 16777216,
1454 16777216,
1455 50331648,
1456 0,
1457 100663296,
1458 16777216,
1459 16777216,
1460 ],
1461 s1 => [
1462 100663296,
1463 83886080,
1464 33554442,
1465 33554464,
1466 33554464,
1467 33554497,
1468 33554442,
1469 33554464,
1470 33554464,
1471 33554464,
1472 ],
1473 v => [100663296],
1474 vav => [100663296, 83886080, 100663296],
1475 vnsvs => [
1476 100663296,
1477 33554442,
1478 33554464,
1479 33554464,
1480 33554464,
1481 100663296,
1482 33554464,
1483 33554464,
1484 33554464,
1485 ],
1486 vnv => [100663296, 33554442, 100663296],
1487 vnvs => [
1488 100663296,
1489 33554442,
1490 100663296,
1491 33554464,
1492 33554464,
1493 33554464,
1494 33554464,
1495 ],
1496 ws => [
1497 100663296,
1498 83886080,
1499 0,
1500 0,
1501 0,
1502 100663296,
1503 16777216,
1504 16777216,
1505 50331648,
1506 0,
1507 100663296,
1508 16777216,
1509 16777216,
1510 134217728,
1511 100663296,
1512 83886080,
1513 33554497,
1514 50331648,
1515 100663296,
1516 134217728,
1517 ],
1518 },
1519 sampleText => {
1520 brackets => "\x{1D5EE}\x{1D44E}\x{1D460}\x{1D460}\x{1D456}\x{1D454}\x{1D45B}\x{230A}\x{2329}\x{2768}\x{1D5EF}\x{1D5FD}\x{2769}\x{232A}\x{1D429}\x{1D425}\x{1D42E}\x{1D42C}\x{276A}\x{1D600}\x{1D5F0}\x{276B}\x{230B}\x{27E2}",
1521 nosemi => "\x{1D5EE}\x{1D44E}\x{1D460}\x{1D460}\x{1D456}\x{1D454}\x{1D45B}\x{230A}\x{2329}\x{2768}\x{1D5EF}\x{1D5FD}\x{2769}\x{232A}\x{1D429}\x{1D425}\x{1D42E}\x{1D42C}\x{276A}\x{1D600}\x{1D5F0}\x{276B}\x{230B}",
1522 s1 => "\x{1D5EE}\x{1D44E}\n A\n ",
1523 v => "\x{1D5EE}",
1524 vav => "\x{1D5EE}\x{1D44E}\x{1D5EF}",
1525 vnsvs => "\x{1D5EE}\x{1D5EE}\n \x{1D5EF}\x{1D5EF} ",
1526 vnv => "\x{1D5EE}\n\x{1D5EF}",
1527 vnvs => "\x{1D5EE}\n\x{1D5EF} ",
1528 ws => "\x{1D5EE}\x{1D44E}\x{1D460}\x{1D460}\x{1D456}\x{1D454}\x{1D45B}\x{230A}\x{2329}\x{2768}\x{1D5EF}\x{1D5FD}\x{2769}\x{232A}\x{1D429}\x{1D425}\x{1D42E}\x{1D42C}\x{276A}\x{1D600}\x{1D5F0}\x{276B}\x{230B}\x{27E2}\x{1D5EE}\x{1D5EE}\x{1D44E}\x{1D460}\x{1D460}\x{1D456}\x{1D454}\x{1D45B}A\x{1D429}\x{1D425}\x{1D42E}\x{1D42C}\x{1D5F0}\x{1D5F0}\x{27E2}",
1529 },
1530 semiColon => "\x{27E2}",
1531 separator => "\x{205F}",
1532 structure => bless({
1533 codes => bless({
1534 a => bless({
1535 letter => "a",
1536 name => "assignment operator",
1537 next => "bpv",
1538 short => "assign",
1539 }, "Tree::Term::LexicalCode"),
1540 B => bless({
1541 letter => "B",
1542 name => "closing parenthesis",
1543 next => "aBdqs",
1544 short => "CloseBracket",
1545 }, "Tree::Term::LexicalCode"),
1546 b => bless({
1547 letter => "b",
1548 name => "opening parenthesis",
1549 next => "bBpsv",
1550 short => "OpenBracket",
1551 }, "Tree::Term::LexicalCode"),
1552 d => bless({ letter => "d", name => "dyadic operator", next => "bpv", short => "dyad" }, "Tree::Term::LexicalCode"),
1553 p => bless({ letter => "p", name => "prefix operator", next => "bpv", short => "prefix" }, "Tree::Term::LexicalCode"),
1554 q => bless({
1555 letter => "q",
1556 name => "suffix operator",
1557 next => "aBdqs",
1558 short => "suffix",
1559 }, "Tree::Term::LexicalCode"),
1560 s => bless({ letter => "s", name => "semi-colon", next => "bBpsv", short => "semiColon" }, "Tree::Term::LexicalCode"),
1561 t => bless({ letter => "t", name => "term", next => "aBdqs", short => "term" }, "Tree::Term::LexicalCode"),
1562 v => bless({ letter => "v", name => "variable", next => "aBdqs", short => "variable" }, "Tree::Term::LexicalCode"),
1563 }, "Tree::Term::Codes"),
1564 first => "bpsv",
1565 last => "Bqsv",
1566 }, "Tree::Term::LexicalStructure"),
1567 treeTermLexicals => 'fix',
1568 }, "Unisyn::Parse::Lexical::Tables");
1569 $a->{treeTermLexicals} = $a->{structure}{codes};
1570 $a;
1571 }}
1572  
1573 #-------------------------------------------------------------------------------
1574 # Export - eeee
1575 #-------------------------------------------------------------------------------
1576  
1577 use Exporter qw(import);
1578  
1579 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
1580  
1581 @ISA = qw(Exporter);
1582 @EXPORT = qw();
1583 @EXPORT_OK = qw();
1584 %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
1585  
1586 # podDocumentation
1587 =pod
1588  
1589 =encoding utf-8
1590  
1591 =head1 Name
1592  
1593 Unisyn::Parse - Parse a Unisyn expression.
1594  
1595 =head1 Synopsis
1596  
1597 Parse the Unisyn expression:
1598  
1599 𝗮𝑎𝗯
1600  
1601 which assigns B<b> to B<a>. Parse this expression and print the resulting parse
1602 tree:
1603  
1604 my $address = Rutf8 $Lex->{sampleText}{vav}; # Source in utf8
1605 my $size = StringLength V(string, $address); # Length of source
1606  
1607 my $parse = create K(address, $address), $size; # Create parse tree from source
1608 $parse->print; # Print parse tree
1609  
1610  
1611 To get:
1612  
1613 ok Assemble(debug=>0, eq => <<END); # Assemble and run
1614 Assign: 𝑎
1615 Term
1616 Variable: 𝗮
1617 Term
1618 Variable: 𝗯
1619 END
1620  
1621 =head1 Description
1622  
1623 Parse a Unisyn expression.
1624  
1625  
1626 Version "20210818".
1627  
1628  
1629 The following sections describe the methods in each functional area of this
1630 module. For an alphabetic listing of all methods by name see L<Index|/Index>.
1631  
1632  
1633  
1634 =head1 Create
1635  
1636 Create a Unisyn parse of a utf8 string.
1637  
1638 =head2 create($address, $size)
1639  
1640 Create a new unisyn parse from a utf8 string
1641  
1642 Parameter Description
1643 1 $address Address of utf8 source string to parse as a variable
1644 2 $size Length of string as a variable
1645  
1646 B<Example:>
1647  
1648  
1649 my $address = Rutf8 $Lex->{sampleText}{vav}; # Source in utf8
1650 my $size = StringLength V(string, $address); # Length of source
1651  
1652  
1653 my $parse = create K(address, $address), $size; # Create parse tree from source # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
1654  
1655 $parse->print; # Print parse tree
1656  
1657 ok Assemble(debug=>0, eq => <<END);
1658 Assign
1659 Term
1660 Variable
1661 Term
1662 Variable
1663 END
1664  
1665  
1666 =head1 Parse
1667  
1668 Parse Unisyn expressions
1669  
1670 =head1 Print
1671  
1672 Print a parse tree
1673  
1674 =head2 print($parse)
1675  
1676 Create a parser for an expression:
1677  
1678 𝗮 = 𝗯
1679  
1680 by coding:
1681  
1682 my $address = Rutf8 $Lex->{sampleText}{vav}; # Source in utf8
1683 my $size = StringLength V(string, $address); # Length of source
1684  
1685 my $parse = create K(address, $address), $size; # Create parse tree from source
1686  
1687 $parse->print; # Print parse tree # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
1688  
1689 Parse the B<Unisyn> expression to get:
1690  
1691 ok Assemble(debug=>0, eq => <<END);
1692 Assign
1693 Term
1694 Variable: 𝗮
1695 Term
1696 Variable: 𝗯
1697 END
1698  
1699  
1700 =head1 Hash Definitions
1701  
1702  
1703  
1704  
1705 =head2 Unisyn::Parse Definition
1706  
1707  
1708 Description of parse
1709  
1710  
1711  
1712  
1713 =head3 Output fields
1714  
1715  
1716 =head4 address
1717  
1718 Address of source string as utf8
1719  
1720 =head4 arena
1721  
1722 Arena containing tree
1723  
1724 =head4 fails
1725  
1726 Number of failures encountered in this parse
1727  
1728 =head4 parse
1729  
1730 Offset to the head of the parse tree
1731  
1732 =head4 size
1733  
1734 Size of source string as utf8
1735  
1736  
1737  
1738 =head1 Private Methods
1739  
1740 =head2 getAlpha($register, $address, $index)
1741  
1742 Load the position of a lexical item in its alphabet from the current character.
1743  
1744 Parameter Description
1745 1 $register Register to load
1746 2 $address Address of start of string
1747 3 $index Index into string
1748  
1749 =head2 getLexicalCode($register, $address, $index)
1750  
1751 Load the lexical code of the current character in memory into the specified register.
1752  
1753 Parameter Description
1754 1 $register Register to load
1755 2 $address Address of start of string
1756 3 $index Index into string
1757  
1758 =head2 putLexicalCode($register, $address, $index, $code)
1759  
1760 Put the specified lexical code into the current character in memory.
1761  
1762 Parameter Description
1763 1 $register Register used to load code
1764 2 $address Address of string
1765 3 $index Index into string
1766 4 $code Code to put
1767  
1768 =head2 loadCurrentChar()
1769  
1770 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.
1771  
1772  
1773 =head2 checkStackHas($depth)
1774  
1775 Check that we have at least the specified number of elements on the stack.
1776  
1777 Parameter Description
1778 1 $depth Number of elements required on the stack
1779  
1780 =head2 pushElement()
1781  
1782 Push the current element on to the stack.
1783  
1784  
1785 =head2 pushEmpty()
1786  
1787 Push the empty element on to the stack.
1788  
1789  
1790 =head2 lexicalNameFromLetter($l)
1791  
1792 Lexical name for a lexical item described by its letter.
1793  
1794 Parameter Description
1795 1 $l Letter of the lexical item
1796  
1797 =head2 lexicalNumberFromLetter($l)
1798  
1799 Lexical number for a lexical item described by its letter.
1800  
1801 Parameter Description
1802 1 $l Letter of the lexical item
1803  
1804 =head2 new($depth, $description)
1805  
1806 Create a new term in the parse tree rooted on the stack.
1807  
1808 Parameter Description
1809 1 $depth Stack depth to be converted
1810 2 $description Text reason why we are creating a new term
1811  
1812 =head2 error($message)
1813  
1814 Die.
1815  
1816 Parameter Description
1817 1 $message Error message
1818  
1819 =head2 testSet($set, $register)
1820  
1821 Test a set of items, setting the Zero Flag is one matches else clear the Zero flag.
1822  
1823 Parameter Description
1824 1 $set Set of lexical letters
1825 2 $register Register to test
1826  
1827 =head2 checkSet($set)
1828  
1829 Check that one of a set of items is on the top of the stack or complain if it is not.
1830  
1831 Parameter Description
1832 1 $set Set of lexical letters
1833  
1834 =head2 reduce($priority)
1835  
1836 Convert the longest possible expression on top of the stack into a term at the specified priority.
1837  
1838 Parameter Description
1839 1 $priority Priority of the operators to reduce
1840  
1841 =head2 reduceMultiple($priority)
1842  
1843 Reduce existing operators on the stack.
1844  
1845 Parameter Description
1846 1 $priority Priority of the operators to reduce
1847  
1848 =head2 accept_a()
1849  
1850 Assign.
1851  
1852  
1853 =head2 accept_b()
1854  
1855 Open.
1856  
1857  
1858 =head2 accept_B()
1859  
1860 Closing parenthesis.
1861  
1862  
1863 =head2 accept_d()
1864  
1865 Infix but not assign or semi-colon.
1866  
1867  
1868 =head2 accept_p()
1869  
1870 Prefix.
1871  
1872  
1873 =head2 accept_q()
1874  
1875 Post fix.
1876  
1877  
1878 =head2 accept_s()
1879  
1880 Semi colon.
1881  
1882  
1883 =head2 accept_v()
1884  
1885 Variable.
1886  
1887  
1888 =head2 parseExpressionCode()
1889  
1890 Parse the string of classified lexical items addressed by register $start of length $length. The resulting parse tree (if any) is returned in r15.
1891  
1892  
1893 =head2 parseExpression(@parameters)
1894  
1895 Create a parser for an expression described by variables.
1896  
1897 Parameter Description
1898 1 @parameters Parameters describing expression
1899  
1900 =head2 MatchBrackets(@parameters)
1901  
1902 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.
1903  
1904 Parameter Description
1905 1 @parameters Parameters
1906  
1907 =head2 ClassifyNewLines(@parameters)
1908  
1909 Scan input string looking for opportunities to convert new lines into semi colons.
1910  
1911 Parameter Description
1912 1 @parameters Parameters
1913  
1914 =head2 ClassifyWhiteSpace(@parameters)
1915  
1916 Classify white space per: "lib/Unisyn/whiteSpace/whiteSpaceClassification.pl".
1917  
1918 Parameter Description
1919 1 @parameters Parameters
1920  
1921 =head2 parseUtf8($p, @parameters)
1922  
1923 Parse a unisyn expression encoded as utf8 and return the parse tree.
1924  
1925 Parameter Description
1926 1 $p Parse
1927 2 @parameters Parameters
1928  
1929 =head2 T($key, $expected, %options)
1930  
1931 Test a parse.
1932  
1933 Parameter Description
1934 1 $key Key of text to be parsed
1935 2 $expected Expected result
1936 3 %options Options
1937  
1938  
1939 =head1 Index
1940  
1941  
1942 1 L<accept_a|/accept_a> - Assign.
1943  
1944 2 L<accept_B|/accept_B> - Closing parenthesis.
1945  
1946 3 L<accept_b|/accept_b> - Open.
1947  
1948 4 L<accept_d|/accept_d> - Infix but not assign or semi-colon.
1949  
1950 5 L<accept_p|/accept_p> - Prefix.
1951  
1952 6 L<accept_q|/accept_q> - Post fix.
1953  
1954 7 L<accept_s|/accept_s> - Semi colon.
1955  
1956 8 L<accept_v|/accept_v> - Variable.
1957  
1958 9 L<checkSet|/checkSet> - Check that one of a set of items is on the top of the stack or complain if it is not.
1959  
1960 10 L<checkStackHas|/checkStackHas> - Check that we have at least the specified number of elements on the stack.
1961  
1962 11 L<ClassifyNewLines|/ClassifyNewLines> - Scan input string looking for opportunities to convert new lines into semi colons.
1963  
1964 12 L<ClassifyWhiteSpace|/ClassifyWhiteSpace> - Classify white space per: "lib/Unisyn/whiteSpace/whiteSpaceClassification.
1965  
1966 13 L<create|/create> - Create a new unisyn parse from a utf8 string
1967  
1968 14 L<error|/error> - Die.
1969  
1970 15 L<getAlpha|/getAlpha> - Load the position of a lexical item in its alphabet from the current character.
1971  
1972 16 L<getLexicalCode|/getLexicalCode> - Load the lexical code of the current character in memory into the specified register.
1973  
1974 17 L<lexicalNameFromLetter|/lexicalNameFromLetter> - Lexical name for a lexical item described by its letter.
1975  
1976 18 L<lexicalNumberFromLetter|/lexicalNumberFromLetter> - Lexical number for a lexical item described by its letter.
1977  
1978 19 L<loadCurrentChar|/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.
1979  
1980 20 L<MatchBrackets|/MatchBrackets> - Replace the low three bytes of a utf32 bracket character with 24 bits of offset to the matching opening or closing bracket.
1981  
1982 21 L<new|/new> - Create a new term in the parse tree rooted on the stack.
1983  
1984 22 L<parseExpression|/parseExpression> - Create a parser for an expression described by variables.
1985  
1986 23 L<parseExpressionCode|/parseExpressionCode> - Parse the string of classified lexical items addressed by register $start of length $length.
1987  
1988 24 L<parseUtf8|/parseUtf8> - Parse a unisyn expression encoded as utf8 and return the parse tree.
1989  
1990 25 L<print|/print> - Create a parser for an expression described by variables.
1991  
1992 26 L<pushElement|/pushElement> - Push the current element on to the stack.
1993  
1994 27 L<pushEmpty|/pushEmpty> - Push the empty element on to the stack.
1995  
1996 28 L<putLexicalCode|/putLexicalCode> - Put the specified lexical code into the current character in memory.
1997  
1998 29 L<reduce|/reduce> - Convert the longest possible expression on top of the stack into a term at the specified priority.
1999  
2000 30 L<reduceMultiple|/reduceMultiple> - Reduce existing operators on the stack.
2001  
2002 31 L<T|/T> - Test a parse.
2003  
2004 32 L<testSet|/testSet> - Test a set of items, setting the Zero Flag is one matches else clear the Zero flag.
2005  
2006 =head1 Installation
2007  
2008 This module is written in 100% Pure Perl and, thus, it is easy to read,
2009 comprehend, use, modify and install via B<cpan>:
2010  
2011 sudo cpan install Unisyn::Parse
2012  
2013 =head1 Author
2014  
2015 L<philiprbrenan@gmail.com|mailto:philiprbrenan@gmail.com>
2016  
2017 L<http://www.appaapps.com|http://www.appaapps.com>
2018  
2019 =head1 Copyright
2020  
2021 Copyright (c) 2016-2021 Philip R Brenan.
2022  
2023 This module is free software. It may be used, redistributed and/or modified
2024 under the same terms as Perl itself.
2025  
2026 =cut
2027  
2028  
2029  
2030 # Tests and documentation
2031  
2032 sub test
2033 {my $p = __PACKAGE__;
2034 binmode($_, ":utf8") for *STDOUT, *STDERR;
2035 return if eval "eof(${p}::DATA)";
2036 my $s = eval "join('', <${p}::DATA>)";
2037 $@ and die $@;
2038 eval $s;
2039 $@ and die $@;
2040 1
2041 }
2042  
2043 test unless caller;
2044  
2045 1;
2046 # podDocumentation
2047 #__DATA__
2048 use Time::HiRes qw(time);
2049 use Test::More;
2050  
2051 my $localTest = ((caller(1))[0]//'Unisyn::Parse') eq "Unisyn::Parse"; # Local testing mode
2052  
2053 Test::More->builder->output("/dev/null") if $localTest; # Reduce number of confirmation messages during testing
2054  
2055 if ($^O =~ m(bsd|linux|cygwin)i) # Supported systems
2056 {if (confirmHasCommandLineCommand(q(nasm)) and LocateIntelEmulator) # Network assembler and Intel Software Development emulator
2057 {plan tests => 3;
2058 }
2059 else
2060 {plan skip_all => qq(Nasm or Intel 64 emulator not available);
2061 }
2062 }
2063 else
2064 {plan skip_all => qq(Not supported on: $^O);
2065 }
2066  
2067 my $startTime = time; # Tests
2068  
2069 eval {goto latest} if !caller(0) and -e "/home/phil"; # Go to latest test if specified
2070  
2071 sub T($$%) #P Test a parse.
2072 {my ($key, $expected, %options) = @_; # Key of text to be parsed, expected result, options
2073 my $source = $$Lex{sampleText}{$key}; # String to be parsed in utf8
2074 defined $source or confess;
2075 my $address = Rutf8 $source;
2076 my $size = StringLength V(string, $address);
2077  
2078 my $p = create V(address, $address), $size;
2079  
2080 if ($options{print}) # Print the parse tree if requested
2081 {my $t = $arena->DescribeTree;
2082 $t->first->copy($p->parse);
2083 $t->dump;
2084 }
2085  
2086 Assemble(debug => 0, eq => $expected);
2087 }
2088  
2089 #latest:
2090 ok T(q(brackets), <<END, comments=>10, print=>1, debug => 0);
2091 Tree at: 0000 0000 0000 0618 length: 0000 0000 0000 0008
2092 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2093 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0598 0000 0009 0000 0018 0000 0009 0000 0001 0000 0005 0000 0003 0000 0009
2094 0000 0658 00A0 0008 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0007 0000 0006 0000 0005 0000 0004 0000 0003 0000 0002 0000 0001 0000 0000
2095 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2096 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0003
2097 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0005
2098 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0001
2099 index: 0000 0000 0000 0004 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009
2100 index: 0000 0000 0000 0005 key: 0000 0000 0000 0005 data: 0000 0000 0000 0018 subTree
2101 index: 0000 0000 0000 0006 key: 0000 0000 0000 0006 data: 0000 0000 0000 0009
2102 index: 0000 0000 0000 0007 key: 0000 0000 0000 0007 data: 0000 0000 0000 0598 subTree
2103 Tree at: 0000 0000 0000 0018 length: 0000 0000 0000 0004
2104 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2105 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0006 0000 0001 0000 0009
2106 0000 0058 0000 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 0002 0000 0001 0000 0000
2107 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2108 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001
2109 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006
2110 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0000
2111 end
2112 Tree at: 0000 0000 0000 0598 length: 0000 0000 0000 0006
2113 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2114 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0518 0000 0009 0000 0007 0000 0000 0000 0002 0000 0009
2115 0000 05D8 0020 0006 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0005 0000 0004 0000 0003 0000 0002 0000 0001 0000 0000
2116 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2117 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0002
2118 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0000
2119 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0007
2120 index: 0000 0000 0000 0004 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009
2121 index: 0000 0000 0000 0005 key: 0000 0000 0000 0005 data: 0000 0000 0000 0518 subTree
2122 Tree at: 0000 0000 0000 0518 length: 0000 0000 0000 0004
2123 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2124 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0498 0000 0009 0000 0001 0000 0009
2125 0000 0558 0008 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 0002 0000 0001 0000 0000
2126 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2127 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001
2128 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009
2129 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0498 subTree
2130 Tree at: 0000 0000 0000 0498 length: 0000 0000 0000 0008
2131 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2132 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0418 0000 0009 0000 0298 0000 0009 0000 000E 0000 0003 0000 0003 0000 0009
2133 0000 04D8 00A0 0008 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0007 0000 0006 0000 0005 0000 0004 0000 0003 0000 0002 0000 0001 0000 0000
2134 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2135 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0003
2136 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0003
2137 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 000E
2138 index: 0000 0000 0000 0004 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009
2139 index: 0000 0000 0000 0005 key: 0000 0000 0000 0005 data: 0000 0000 0000 0298 subTree
2140 index: 0000 0000 0000 0006 key: 0000 0000 0000 0006 data: 0000 0000 0000 0009
2141 index: 0000 0000 0000 0007 key: 0000 0000 0000 0007 data: 0000 0000 0000 0418 subTree
2142 Tree at: 0000 0000 0000 0298 length: 0000 0000 0000 0006
2143 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2144 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0218 0000 0009 0000 0008 0000 0000 0000 0002 0000 0009
2145 0000 02D8 0020 0006 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0005 0000 0004 0000 0003 0000 0002 0000 0001 0000 0000
2146 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2147 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0002
2148 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0000
2149 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0008
2150 index: 0000 0000 0000 0004 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009
2151 index: 0000 0000 0000 0005 key: 0000 0000 0000 0005 data: 0000 0000 0000 0218 subTree
2152 Tree at: 0000 0000 0000 0218 length: 0000 0000 0000 0004
2153 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2154 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0198 0000 0009 0000 0001 0000 0009
2155 0000 0258 0008 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 0002 0000 0001 0000 0000
2156 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2157 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001
2158 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009
2159 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0198 subTree
2160 Tree at: 0000 0000 0000 0198 length: 0000 0000 0000 0006
2161 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2162 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0118 0000 0009 0000 0009 0000 0000 0000 0002 0000 0009
2163 0000 01D8 0020 0006 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0005 0000 0004 0000 0003 0000 0002 0000 0001 0000 0000
2164 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2165 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0002
2166 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0000
2167 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0009
2168 index: 0000 0000 0000 0004 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009
2169 index: 0000 0000 0000 0005 key: 0000 0000 0000 0005 data: 0000 0000 0000 0118 subTree
2170 Tree at: 0000 0000 0000 0118 length: 0000 0000 0000 0004
2171 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2172 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0098 0000 0009 0000 0001 0000 0009
2173 0000 0158 0008 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 0002 0000 0001 0000 0000
2174 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2175 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001
2176 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009
2177 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0098 subTree
2178 Tree at: 0000 0000 0000 0098 length: 0000 0000 0000 0004
2179 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2180 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 000A 0000 0006 0000 0001 0000 0009
2181 0000 00D8 0000 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 0002 0000 0001 0000 0000
2182 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2183 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001
2184 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006
2185 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 000A
2186 end
2187 end
2188 end
2189 end
2190 end
2191 Tree at: 0000 0000 0000 0418 length: 0000 0000 0000 0006
2192 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2193 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0398 0000 0009 0000 0012 0000 0000 0000 0002 0000 0009
2194 0000 0458 0020 0006 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0005 0000 0004 0000 0003 0000 0002 0000 0001 0000 0000
2195 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2196 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0002
2197 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0000
2198 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0012
2199 index: 0000 0000 0000 0004 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009
2200 index: 0000 0000 0000 0005 key: 0000 0000 0000 0005 data: 0000 0000 0000 0398 subTree
2201 Tree at: 0000 0000 0000 0398 length: 0000 0000 0000 0004
2202 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2203 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0318 0000 0009 0000 0001 0000 0009
2204 0000 03D8 0008 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 0002 0000 0001 0000 0000
2205 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2206 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001
2207 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0009
2208 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0318 subTree
2209 Tree at: 0000 0000 0000 0318 length: 0000 0000 0000 0004
2210 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2211 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0013 0000 0006 0000 0001 0000 0009
2212 0000 0358 0000 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 0002 0000 0001 0000 0000
2213 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2214 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001
2215 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006
2216 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0013
2217 end
2218 end
2219 end
2220 end
2221 end
2222 end
2223 end
2224 END
2225  
2226 #latest:
2227 ok T(q(vav), <<END, comments=>10, print=>1);
2228 Tree at: 0000 0000 0000 0118 length: 0000 0000 0000 0008
2229 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2230 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0098 0000 0009 0000 0018 0000 0009 0000 0001 0000 0005 0000 0003 0000 0009
2231 0000 0158 00A0 0008 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0007 0000 0006 0000 0005 0000 0004 0000 0003 0000 0002 0000 0001 0000 0000
2232 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2233 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0003
2234 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0005
2235 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0001
2236 index: 0000 0000 0000 0004 key: 0000 0000 0000 0004 data: 0000 0000 0000 0009
2237 index: 0000 0000 0000 0005 key: 0000 0000 0000 0005 data: 0000 0000 0000 0018 subTree
2238 index: 0000 0000 0000 0006 key: 0000 0000 0000 0006 data: 0000 0000 0000 0009
2239 index: 0000 0000 0000 0007 key: 0000 0000 0000 0007 data: 0000 0000 0000 0098 subTree
2240 Tree at: 0000 0000 0000 0018 length: 0000 0000 0000 0004
2241 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2242 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0006 0000 0001 0000 0009
2243 0000 0058 0000 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 0002 0000 0001 0000 0000
2244 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2245 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001
2246 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006
2247 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0000
2248 end
2249 Tree at: 0000 0000 0000 0098 length: 0000 0000 0000 0004
2250 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2251 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0002 0000 0006 0000 0001 0000 0009
2252 0000 00D8 0000 0004 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 0002 0000 0001 0000 0000
2253 index: 0000 0000 0000 0000 key: 0000 0000 0000 0000 data: 0000 0000 0000 0009
2254 index: 0000 0000 0000 0001 key: 0000 0000 0000 0001 data: 0000 0000 0000 0001
2255 index: 0000 0000 0000 0002 key: 0000 0000 0000 0002 data: 0000 0000 0000 0006
2256 index: 0000 0000 0000 0003 key: 0000 0000 0000 0003 data: 0000 0000 0000 0002
2257 end
2258 end
2259 END
2260  
2261 #latest:
2262 if (1) { #Tcreate #Tprint
2263 my $address = Rutf8 $Lex->{sampleText}{vav}; # Source in utf8
2264 my $size = StringLength V(string, $address); # Length of source
2265  
2266 my $parse = create K(address, $address), $size; # Create parse tree from source
2267 $parse->print; # Print parse tree
2268  
2269 ok Assemble(debug=>0, eq => <<END);
2270 Assign: 𝑎
2271 Term
2272 Variable: 𝗮
2273 Term
2274 Variable: 𝗯
2275 END
2276 }
2277  
2278 #latest:
2279 ok T(q(brackets), <<END) if 0;
2280 ParseUtf8
2281 END
2282  
2283 #latest:
2284 ok T(q(brackets), <<END) if 0;
2285 ParseUtf8
2286 END
2287  
2288  
2289 unlink $_ for qw(hash print2 sde-log.txt sde-ptr-check.out.txt z.txt); # Remove incidental files
2290  
2291 say STDERR sprintf("# Finished in %.2fs, bytes: %s, execs: %s ", time - $startTime,
2292 map {numberWithCommas $_}
2293 $Nasm::X86::totalBytesAssembled, $Nasm::X86::instructionsExecuted);
« Build ↑ Summary