Download the PHP package farafiri/php-parsing-tool without Composer

On this page you can find all versions of the php package farafiri/php-parsing-tool. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-parsing-tool

This library:

Example

Let say you have string with dates in format d.m.y or y-m-d separated by comma.

Even more examples

There are a few different example parsers implemented in the ParserGenerator\Example namespace, and you'll also find tests for them, e.g.:

Branch types

You could declare the previous grammar as PEG and it would improve speed x10. To do so, add the option ['defaultBranchType' => 'PEG'] as a second argument to Parser. Note that not every grammar can be parsed with PEG packrat algorithm.

Error handling

If your input cannot be parsed, \ParserGenerator\Parser::parse will return false.

Use \ParserGenerator\Parser::getErrorString() and provide your input data to get a human-readable error description.

Alternatively you can use \ParserGenerator\Parser::getError() and directly work with error nodes.

Symbols

"text"

Matches text. You can also use single quotes. You can use escape sequences so "\n" will match new line.

/regular|expression/

Matches given regular expression. You can use pattern modifiers. Grammar like "start :=> /[a-z]/i." will also match upper case letters. Regular expression cannot be backtracked. They work like the first match is the only match. For example: "start :=> /a+/ 'a'.", when we try to parse string "aa" regular expression will capture both characters and the string will be not matched.

symbolName

Will match the defined symbol. The following example will match any pair of letters, followed by digits.

whiteSpace, space, newLine, tab

whiteSpace matches space, tabulator or new line character If ignoreWhitespaces mode is off these symbols work same as /\s/, " ", /\t/, /\n/. When ignoreWhitespaces mode is on then /\s/, " ", "\t", "\n" won't work and you must use whiteSpace, space, etc symbols. In ignoreWhitespaces mode these symbols check context and not consuming characters from input. For example sequence: 'a' newLine space space 'b' will match characters 'a' and 'b' separated by at least one space and at least one new line symbol

text

match any text

symbol+

Will try to match symbol several times (at least once). For example start :=> "a"+. will match "a" "aa" "aaa" but not ""

symbol?

Symbol is optional. For example start :=> "a"?. wil match "a" and "" but not "aa"

symbol*

Will try to match symbol several times (symbol is optional) For example start :=> "a"*. will match "a" "aa" "aaa" and ""

symbol++, symbol**, symbol??

Same as adequate symbol+, symbol and symbol but consumes it in a greedy way. Example:

If 'defaultBranchType' is set to 'PEG' then symbol* is equal to symbol** (always greedy). Same with "+" and "?". In this mode, the last case will fail (PEG cannot parse it)

?symbol

Lookahead. Check if symbol can be parsed but do not capture it. For example "start :=> 'a' ?/.{3}/ integer. integer :=> /\d+/." will match "a" followed by at least 3 digit number.

!symbol

Negative lookahead. Similar to ?symbol but continue parsing only if cannot match symbol

symbol1+symbol2

Several symbol1 occurrences separated by symbol2 (similar for *, ++, **)

Note that symbol1+ symbol2 is something different than symbol1+symbol2. This space between + and symbol2 is crucial "a"+ "b" matches: "aaaab" but not "ababa" "a"+"b" matches: "ababa" but not :aaaab"

(symbol1 | symbol2)

Choice, match symbol1 or symbol2. For example "start :=> ('a' | 'b') 'c'." will parse strings "ac" and "bc"

string

Syntax sugar for regex like: /"([^\]|\.)*"/ Matches quoted strings Example:

By default string may be quoted by quotation or apostrophe. string/apostrophe : can be quoted only by apostrophe string/quotation : can be quoted only by quotation string/simple : can be quoted only by quotation, no characters escaping by \, quotation character by repetition (style used in Pascal or CSV)

numbers

Of course you you can use /\d+/ but using build-in toolkit for numbers is much easier and readable

time()

Matching time in the given format:

contain, is

Sometimes you may want to do extra checks on the parsed node. Thanks to these constructs, you can check if node contain some text or if matches a pattern:

It is possible to make some basic logic operations on the check and put them into braces

unorder(separator, choice1, choice2...)

unorder should be used when you expect several elements in any order

By default each element is expected exactly once but you can change it:

At least one element is required:


All versions of php-parsing-tool with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package farafiri/php-parsing-tool contains the following files

Loading the files please wait ....