Comments (7)
It turned out that my earlier implementation was over zealous. This one seems to be less so. It still consumes as many word characters as it can, but its eagerness for operator characters is now strictly regulated.
The test
123456; 123_456; // +
1234z6; 123456_; 123__456; // -
0x89Ab; 0x89_aB; // +
0x89zB; 0x89AB_; 0x_89AB; 0_x89AB; 0x89__AB; // -
1234.; 1234.e-0; 1234e+0; 1234e0; // +
1234.e-; 1234e+; 1234e; // -
.1234; .12e0; // +
.12.0e0; .12e0.0; .12e0e0; // -
1.234e-10; 1.2_34e-1_0; // +
1.234e-_10; 1.234e_-10; 1.234_e-10; 1._234e-10; 1_.234e-10; // -
01234567; 0_1234567; // +
012345678; // -
0...0; // 0. . .0
.0..0; // .0 . .0
0e+0+0e+0; // 0e+0 + 0e+0
from lexilla.
Due to reevaluating octal numbers, i
is reset and may count a following '/*' comment double for folding. This caused the apostophe.php
test case to fail with this change, the fold level jumping from 401 to 403:
2 400 0 + <?php
0 401 0 | # Test that currently fails as comment style not started in a number.
0 401 0 | # line-comment
0 401 0 | // line-comment
0 401 0 | /* comment */
0 401 0 | $foo = 0#comment
0 401 0 | $foo = 0//comment
2 401 0 + $foo = 0/*'*/;
0 403 0 | ?>
1 403 0 |
0 403 0 | <br />
0 403 0 |
Rewinding is often a difficult strategy as there are multiple effects occurring in the code.
from lexilla.
I agree that the "HTML" lexer is rather complicated and needs overhaul. However, do you have in mind compile-time or run-time combining?
Sets of choices would be defined at compile time. At runtime an application may say they want to combine ASP
and C#
for server-side scripting along with Mustache
and Sass
then Dart
client side. A limited number of slots (server-side-control, server-side-scripting; expression-language; stylesheet-language; client-side-language) would be specified at compile-time along with the choices available in each slot. The choice for each slot would be set by the application at runtime.
from lexilla.
Due to reevaluating octal numbers,
i
is reset and may count a following '/*' comment double for folding.
The revised patch fixes it by using the inline reevaluation.
Rewinding is often a difficult strategy as there are multiple effects occurring in the code.
I forgot that there are side-effects in the lex loop.
The patch also fixes the apostophe.php
test case entirely by reusing the code in PHP's default branch, although it does so by using goto
, which isn't liked by everybody. But this case seems perfect for this often misused language feature.
Here is how it might look like:
from lexilla.
Issues and their fixes should be isolated. If the current apostophe.php
case is incorrect then that should be a separate issue and fix.
LexerHTML::Lex is 1500 lines long and is worked on by many people so is a bad place to use a goto.
It should be possible to move the character handling logic for numeric literals out of Lex and into PhpNumberState.
from lexilla.
Here is the next iteration of my patch.
All character handling logic is moved into PhpNumberState
. I also removed the usage of goto
.
However the failing tests in test/examples/hypertext/apostophe.php
still got fixed as a byproduct of using the look-ahead strategy in PhpNumberState
.
The test case
123456; 123_456; // +
1234z6; 123456_; 123__456; // -
0x89Ab; 0x89_aB; // +
0x89zB; 0x89AB_; 0x_89AB; 0_x89AB; 0x89__AB; // -
1234.; 1234.e-0; 1234e+0; 1234e0; 1234e0.PHP_EOL; // +
1234._; 1234.e-; 1234e+; 1234e; // -
.1234; .12e0; // +
.12.0e0; .12e0.0; .12e0e0; // -
1.234e-10; 1.2_34e-1_0; // +
1.234e-_10; 1.234e_-10; 1.234_e-10; 1._234e-10; 1_.234e-10; // -
1.234e-+10; 1.234e-_+10; // -
01234567; 0_1234567; // +
012345678; // -
0...0; // 0. . .0
.0..0; // .0 . .0
0e+0+0e+0; // 0e+0 + 0e+0
;0#comment
;0//comment
;0/*comment*/;
PS. I think, I'll open another issue for the hypertext-lexer-overhaul discussion after I think it through, for I have some ideas but I'm not sure whether they are implementable.
from lexilla.
Committed with reformatting. LexHTML.cxx follows 1TBS as does most of Lexilla and Scintilla. Changes should match existing code. Also fixed spelling of "unchanged".
from lexilla.
Related Issues (20)
- Inconsistent lexing of '-' at line start by bash lexer HOT 8
- [Bash] two bugs in test operator highlighting HOT 6
- Fold Issue in Verilog mode HOT 17
- LexerVerilog tries to set line state beyond EOF HOT 2
- R escape sequences don't terminate properly HOT 13
- Syntax highlighting for Svelte HOT 1
- [CSS] Nesting and &-selector HOT 4
- Fold issue in verilog with nested MACRO and nested if HOT 3
- nested square brackets, TeX files
- Syntax colour highlighting of HTML with JSON context in JavaScript section HOT 7
- Shell language lexing mistakes bitwise left shift operator for here document HOT 3
- [Bash] Don't nest `${}` parameter expansion on `{` HOT 1
- unreachable code HOT 1
- Feature Request: Folding by indentation in plain text HOT 2
- Update Assembly (Update Syntax Highlighting)
- Batch Syntax "keyword" + ":" => "keyword:" dont work properly HOT 5
- raw formatted string is not handled in Python lexer HOT 5
- prevent negative code folding level in lexer HOT 26
- [Ruby] fix `number.method` highlighting
- Batch File Syntax Highlighting After 1024 Characters HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lexilla.