rfc:ast_based_parsing_compilation_process

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
rfc:ast_based_parsing_compilation_process [2012/09/07 12:54] – Add link regard functions parens nikicrfc:ast_based_parsing_compilation_process [2012/09/07 13:15] nikic
Line 40: Line 40:
 ==== Decoupling syntax decisions from technical issues ==== ==== Decoupling syntax decisions from technical issues ====
  
-With the current single-pass compiler some things are very hard / near impossible to implement. This actively influences syntax descisions.+With the current single-pass compiler some things are very hard / near impossible to implement. This actively influences syntax decisions.
  
-One example of syntax that is currently impossible is array destructuring without special ''list()'' construct. The syntax ''[$a, $b] = [$b, $a]'' that is common in other languages is not possible to implement in PHP due to parser limitations.+Two examples of syntax that is currently not possible, but would be possible with a syntax tree:
  
-Another example are list comprehensions / generator expressions where the result expression comes first (e.g. ''[x * x for x in list]'' in Python). In PHP only the reversed syntax is possible (''[foreach ($list as $x) yield $x * $x]'').+  * Array destructuring using something like ''[$a, $b, $c] = $array'' instead of a dedicated ''list()'' syntax. This is common in other languages, but not possible in PHP. 
 +  * List comprehensions / generator expressions where the result expression comes firste.g. ''[x * x for x in list]'' in Python. In PHP only the reverse syntax is possible''[foreach ($list as $x) yield $x * $x]''
  
-Those are two examples of larger limitations, but smaller syntax decisions are often driven by parser limitations too. An AST allows implementing many syntax elements that would otherwise be impossible. (One of the main reasons for this is that an AST based parser does not require mid-rule semantic action reduction.)+Apart from larger syntax limitations the current system commonly also affects smaller syntax decisions.
  
 ===== Disadvantages ===== ===== Disadvantages =====
rfc/ast_based_parsing_compilation_process.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1