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

Task: Merge Zephir and PHP (Zephir depends on PHP) #2373

Closed
joshgoebel opened this issue Jan 31, 2020 · 3 comments
Closed

Task: Merge Zephir and PHP (Zephir depends on PHP) #2373

joshgoebel opened this issue Jan 31, 2020 · 3 comments
Labels
enhancement An enhancement or new feature language

Comments

@joshgoebel
Copy link
Member

joshgoebel commented Jan 31, 2020

Context:

#2372

I didn't realize the differences were so small. It looks like a few things need to be fixed/consolidated and then I think Zephir could simply be very similar to the way Arduino lays extra keywords down on top of C++. IE, Zephir becomes just PHP + extra keywords.

The current diff:

--- src/languages/php.js	2020-01-31 08:28:57.000000000 -0500
+++ src/languages/zephir.js	2020-01-31 08:28:54.000000000 -0500
@@ -1,21 +1,14 @@
<snip>
 
 function(hljs) {
-  var VARIABLE = {
-    begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
-  };
-  var PREPROCESSOR = {
-    className: 'meta', begin: /<\?(php)?|\?>/
-  };
   var STRING = {
     className: 'string',
-    contains: [hljs.BACKSLASH_ESCAPE, PREPROCESSOR],
+    contains: [hljs.BACKSLASH_ESCAPE],
     variants: [
       {
         begin: 'b"', end: '"'
@@ -29,20 +22,21 @@
   };
   var NUMBER = {variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]};
   return {
-    aliases: ['php', 'php3', 'php4', 'php5', 'php6', 'php7'],
+    aliases: ['zep'],
     case_insensitive: true,
     keywords:
       'and include_once list abstract global private echo interface as static endswitch ' +
-      'array null if endwhile or const for endforeach self var while isset public ' +
+      'array null if endwhile or const for endforeach self var let while isset public ' +
       'protected exit foreach throw elseif include __FILE__ empty require_once do xor ' +
       'return parent clone use __CLASS__ __LINE__ else break print eval new ' +
       'catch __METHOD__ case exception default die require __FUNCTION__ ' +
       'enddeclare final try switch continue endfor endif declare unset true false ' +
       'trait goto instanceof insteadof __DIR__ __NAMESPACE__ ' +
-      'yield finally',
+      'yield finally int uint long ulong char uchar double float bool boolean string' +
+      'likely unlikely',
     contains: [
+      hljs.C_LINE_COMMENT_MODE,
       hljs.HASH_COMMENT_MODE,
-      hljs.COMMENT('//', '$', {contains: [PREPROCESSOR]}),
       hljs.COMMENT(
         '/\\*',
         '\\*/',
@@ -66,23 +60,9 @@
       ),
       {
         className: 'string',
-        begin: /<<<['"]?\w+['"]?$/, end: /^\w+;?$/,
-        contains: [
-          hljs.BACKSLASH_ESCAPE,
-          {
-            className: 'subst',
-            variants: [
-              {begin: /\$\w+/},
-              {begin: /\{\$/, end: /\}/}
-            ]
-          }
-        ]
-      },
-      PREPROCESSOR,
-      {
-        className: 'keyword', begin: /\$this\b/
+        begin: '<<<[\'"]?\\w+[\'"]?$', end: '^\\w+;',
+        contains: [hljs.BACKSLASH_ESCAPE]
       },
-      VARIABLE,
       {
         // swallow composed identifiers to avoid parsing them as keywords
         begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/
@@ -98,7 +78,6 @@
             begin: '\\(', end: '\\)',
             contains: [
               'self',
-              VARIABLE,
               hljs.C_BLOCK_COMMENT_MODE,
               STRING,
               NUMBER
@joshgoebel joshgoebel added enhancement An enhancement or new feature language labels Jan 31, 2020
@joshgoebel
Copy link
Member Author

@egor-rogov Thoughts?

@egor-rogov
Copy link
Collaborator

It seems to me that Arduino is C++ with some additional functions. But it looks like Zephir is not an extension to PHP but a separate language. Yes, it looks a lot like PHP, and probably we can handle it as a superset to PHP. My only concern is that it may prove more complex to maintain Zefir if the language will change. I'm not sure it is very stable.

@joshgoebel
Copy link
Member Author

It seems to me that Arduino is C++ with some additional functions. But it looks like Zephir is not an extension to PHP but a separate language.

Yeah I learned this later. :) So never mind this idea. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature language
Projects
None yet
Development

No branches or pull requests

2 participants