rfc:context_sensitive_lexer
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:context_sensitive_lexer [2015/03/14 22:18] – close voting marcio | rfc:context_sensitive_lexer [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2015-02-15 | * Date: 2015-02-15 | ||
* Author: Márcio Almada | * Author: Márcio Almada | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 31: | Line 31: | ||
This RFC revisits the topic of [[https:// | This RFC revisits the topic of [[https:// | ||
- | presenting a minimal and maintainable [[https:// | + | presenting a minimal and maintainable [[https:// |
- | restricted to OO scope only, consistently comprehending: | + | |
* Properties, constants and methods defined on classes, interfaces and traits | * Properties, constants and methods defined on classes, interfaces and traits | ||
Line 52: | Line 51: | ||
==== Limitations ==== | ==== Limitations ==== | ||
- | On purpose, it's still forbidden to define '' | + | On purpose, it's still forbidden to define a **class constant** named as '' |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | So the following code would still be invalid: | + | |
- | + | ||
- | <code php> | + | |
- | class Foo { | + | |
- | const public|protected|private|static|abstract|final|class = ' | + | |
- | function public|protected|private|static|abstract|final(){} // Fatal error | + | |
- | } | + | |
- | + | ||
- | // Fatal error: Cannot declare a class const named as %d as it is reserved in %s on line %d | + | |
- | // Fatal error: Cannot declare a class method named as %d as it is reserved in %s on line %d | + | |
- | </ | + | |
- | + | ||
- | On purpose, it's still forbidden to define a **class constant** named as '' | + | |
<code php> | <code php> | ||
Line 82: | Line 60: | ||
// Fatal error: Cannot redefine class constant Foo::CLASS as it is reserved in %s on line %d | // Fatal error: Cannot redefine class constant Foo::CLASS as it is reserved in %s on line %d | ||
</ | </ | ||
+ | |||
+ | In practice, it means that we would drop from **64** to only **1** reserved word that affects only class constant names. | ||
'' | '' | ||
Line 92: | Line 72: | ||
(new Foo)-> | (new Foo)-> | ||
</ | </ | ||
- | |||
- | In practice, it means that we would drop from **64** to only **6** **globally** reserved words. | ||
===== Practical Examples ===== | ===== Practical Examples ===== | ||
Line 209: | Line 187: | ||
==== Patch 2 ==== | ==== Patch 2 ==== | ||
- | A new patch has been added during the voting phase. It's a different approach, using lexical feedback, | + | A new patch has been added during the voting phase. It's a different approach that proved to have many advantages over the first patch and therefore it is intended to supersede it. |
- | many advantages over the first patch and therefore it is intended to supersede it. The new patch is still a WIP. | + | |
The new patch just requires the maintenance of a single inclusive parser rule listing all tokens that should be matched as a '' | The new patch just requires the maintenance of a single inclusive parser rule listing all tokens that should be matched as a '' | ||
Line 216: | Line 193: | ||
- It offers no regression | forward compatibility risks and is highly predictable | - It offers no regression | forward compatibility risks and is highly predictable | ||
- It has a very small footprint when compared to the previous attempt involving a pure lexical approach | - It has a very small footprint when compared to the previous attempt involving a pure lexical approach | ||
- | - Requires | + | - Requires |
- Is highly configurable, | - Is highly configurable, | ||
- | In order to send information to the lexer about the context change, we just have to use '' | + | In order to send information to the lexer about the context change, we just have to use '' |
- | this is the needed changes on the parser grammar to allow semi reserved words on method names: | + | |
<code c> | <code c> | ||
Line 260: | Line 236: | ||
==== Patch 2 ==== | ==== Patch 2 ==== | ||
- | - Pull request with all the tests is at [[https:// | + | - Pull request with all the tests is at [[https:// |
+ | |||
+ | ==== Later Changes === | ||
- | => the new patch is WIP, ext tokenizer support | + | The *Patch 2* was merged and, later, method modifiers were allowed as class member names. This was a limitation from the older implementation candidate - Patch 1 - and there was no reason to keep it. The **Limitations** section was updated accordingly. Only the keyword **class** for class constants |
===== References ===== | ===== References ===== | ||
Line 270: | Line 248: | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
- | * Prior to voting, the support for '' | + | * Prior to voting, the support for '' |
=> The RFC author will try to solve the wider problem on PHP 7.1 | => The RFC author will try to solve the wider problem on PHP 7.1 |
rfc/context_sensitive_lexer.1426371525.txt.gz · Last modified: 2017/09/22 13:28 (external edit)