Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated PHP mode to support PHP8.1 syntax #4696

Merged
merged 1 commit into from
May 12, 2022

Conversation

jeroenpost86
Copy link
Contributor

Issue #, if available:
#4439

Repeating 5834d8f

Description of changes:
Added support for PHP 8.1 syntax. This is only for the syntax checker, I did not add anything for the autocomplete function.

Demo here: https://onlinephp.io/c/php8.1-aceeditor-demo

Rebuild parser that I used:

<?php

const GRAMMAR_REPO  = 'https://raw.githubusercontent.com/nikic/PHP-Parser';
const PARSER_REPO  = 'https://raw.githubusercontent.com/niklasvh/php.js';

const GRAMMAR_FILE = GRAMMAR_REPO .'/master/grammar/php7.y';
const TOKENS_FILE  = GRAMMAR_REPO .'/master/grammar/tokens.y';
const TMP_FILE     = './tmp_parser.jsy';
const RESULT_FILE  = './tmp_parser.js';

file_put_contents('kmyacc.js.parser', file_get_contents(PARSER_REPO .'/master/grammar/kmyacc.js.parser'));

$tokens = file_get_contents(TOKENS_FILE);
$grammarCode = file_get_contents(GRAMMAR_FILE);

$tokens .= "%token T_BAD_CHARACTER
%token T_COMMENT
%token T_DOC_COMMENT
%token T_OPEN_TAG
%token T_OPEN_TAG_WITH_ECHO
%token T_CLOSE_TAG
%token T_WHITESPACE";

$grammarCode = str_replace('%tokens', $tokens, $grammarCode);

file_put_contents(TMP_FILE, $grammarCode);

echo 'Building parser. Output: "',
trim(shell_exec('php PHP-Yacc/bin/phpyacc -m kmyacc.js.parser ' . TMP_FILE . ' 2>&1')),
'"', "\n";

preg_match_all('/T_\w+/', $tokens, $matches);
foreach ($matches[0] as $match)
    echo '"' . $match . '",';

echo "\n". str_repeat('-', 45). "\n";
foreach ($matches[0] as $match)
    if (NULL != constant($match))
        echo 'PHP.Constants.' . $match . ' = ' . constant($match) . "\n";

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented May 11, 2022

Codecov Report

Merging #4696 (f169ca8) into master (7cc98c7) will increase coverage by 0.05%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4696      +/-   ##
==========================================
+ Coverage   71.19%   71.24%   +0.05%     
==========================================
  Files         553      553              
  Lines       55585    55585              
  Branches    10391    10391              
==========================================
+ Hits        39571    39599      +28     
+ Misses      16014    15986      -28     
Flag Coverage Δ
unittests 71.24% <ø> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/ace/range.js 85.51% <0.00%> (+0.68%) ⬆️
lib/ace/editor.js 81.61% <0.00%> (+1.90%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7cc98c7...f169ca8. Read the comment docs.

@andrewnester andrewnester merged commit 33cf1c6 into ajaxorg:master May 12, 2022
jeroenpost86 pushed a commit to jeroenpost86/ace that referenced this pull request May 19, 2022
* 'master' of https://github.com/ajaxorg/ace:
  fix: Made commas be tokenized as punctuation operator instead of text in JSON (ajaxorg#4703)
  fix: Multiple Partiql and Amazon Ion textual notation fixes (ajaxorg#4686)
  fix: Updated PHP mode to support PHP8.1 syntax (ajaxorg#4696)
  release v1.5.0
  chore: use npm changelog in release script (ajaxorg#4698)
  feat: Added ability to configure certain format options for beautify extension
  fix: Render bidirectional unicode characters as control characters (ajaxorg#4693)
@jeroenpost86 jeroenpost86 mentioned this pull request May 20, 2022
@mkslanc mkslanc mentioned this pull request Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants