Skip to content

Commit b7e77ba

Browse files
committed
Add script/extract_functions.php
1 parent 6513efa commit b7e77ba

File tree

5 files changed

+1792
-0
lines changed

5 files changed

+1792
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/.keg/*
66
/.php-cs-fixer.cache
77
php-mode-autoloads.el
8+
php_manual_en.json

Diff for: script/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
# Maintenance script for PHP Mode
3+
4+
These scripts are provided for maintenance of PHP Mode.
5+
6+
## Extract PHP Functions
7+
8+
This script extract PHP function names from <http://doc.php.net/downloads/json/php_manual_en.json>.
9+
10+
### Usage
11+
12+
```
13+
Usage:
14+
./script/extract_functions.php count < php_manual_en.json
15+
./script/extract_functions.php modules < php_manual_en.json
16+
./script/extract_functions.php functions < php_manual_en.json > result.json
17+
./script/extract_functions.php functions-sexp < php_manual_en.json > result.el
18+
```
19+
20+
### Data
21+
22+
A pattern for grouping function modules by function-id is written in `data/module_id_prefixes.php`.
23+
24+
* All entries are combined as prefix matching patterns
25+
* The meanings of `.` and `\.` (matches) in the regular expression are swapped
26+
* `\.` matches any one character
27+
* `.` matches only `"."`
28+
* An alphanumeric-terminated entry requires an exact match
29+
* Other entries require a [`\b`(word boundary)](https://www.php.net/manual/regexp.reference.escape.php) at the end
30+
31+
```php
32+
return [
33+
'apache' => [
34+
'function.apache-', // matches all "apache-" prefixed IDs
35+
'function.virtual', // matches only "function.virtual"
36+
],
37+
'bcmath' => [
38+
'function.bc\.+', // matches "function.bcadd", "function.bccomp", ...etc
39+
],
40+
```

0 commit comments

Comments
 (0)