Changes between Version 14 and Version 15 of PIRCDevelopment

Show
Ignore:
Timestamp:
08/06/09 14:28:47 (12 years ago)
Author:
kjs
Comment:

start a section on heredoc parsing.

Legend:

Unmodified
Added
Removed
Modified
  • PIRCDevelopment

    v14 v15  
    8989== Heredoc processor == 
    9090 
     91The Heredoc processor has only one task: flattening heredoc strings. By "flattening", I mean the following. This string: 
     92 
     93{{{ 
     94 $S0 = <<'EOS' 
     95This is 
     96 a multi-line 
     97  heredoc 
     98   string 
     99    with 
     100     increasing 
     101      indention 
     102       on each line. 
     103EOS 
     104}}} 
     105 
     106is "flattened" into: 
     107 
     108{{{ 
     109 $S0 = "This is  a multi-line\n  heredoc\n   string\n    with\n     increasing\n      indention\n       on each line."  
     110}}} 
     111 
     112Note that "newline" characters are inserted as well, so that the string is equivalent to the original heredoc string. 
     113Besides assigning heredoc strings to String registers, the PIR specification also allows you to use heredoc strings as arguments in subroutine invocations: 
     114 
     115{{{ 
     116.sub main 
     117  foo(<<'A') 
     118This is a heredoc 
     119string argument 
     120A 
     121.end 
     122 
     123.sub foo 
     124 # ... 
     125.end 
     126}}} 
     127 
     128Again, the heredoc string (delimited by the string "A") will be flattened. According to the PIR specification, you can even pass multiple heredoc string arguments, like so: 
     129 
     130{{{ 
     131.sub main 
     132  foo(<<'A', 42, <<'B', 3.14, <<'C') 
     133 I have a Parrot 
     134A 
     135 It is not a bird 
     136B 
     137 It is a virtual machine 
     138C 
     139.end 
     140 
     141}}} 
     142 
     143Note that the heredoc arguments may be mixed with other, simple arguments such as integers and numbers. In the rest of this section, the implementation will be discussed. 
     144 
    91145== Macro layer == 
    92146