Download the PHP package didix16/php-grammar without Composer

On this page you can find all versions of the php package didix16/php-grammar. 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-grammar

PHP Grammar

A simple library to make Lexer and Parsers to build a language.

Content

What is a Token

A token is the most atomic piece of your language. It could be a single character in an specific alphabet A or a composition of some of them.

What is a Lexer

Lexer is the responsible of parsing the raw text and tokenize it for a Parser, which will interpret them using a grammar.

Example: Supose we have the following text:

Lets say our language has variables, functions and some else.

A result of applying a parser will generate the following tokens:

With that tokens then the Parser should identify in its grammar a properly syntax for the language you are building.

What is a Parser

A parser or grammar is the responsible of interpret the tokens generated by the Lexer and evaluate them identifying the correct syntax of your language you are builing.

Also we call the grammar, Context Free Grammar. More info here Context Free Grammar - Wikipedia

To program a grammar, we are gona use the Chomsky formal form since we must have well defined rules for our grammar and also most important, we are gonna use the BNF - Backus-Naur Form to define each rules.

Installation

Usage

I'm gonna show a simple usage for build a language which recognise a supe simple script to instruct some API do something like GET url and process it.

Let's gonna call it APIScript and should use APILexer and APIParser.

A simple script would have a structure like this:

We can identify lines, which each line is an action. Each action has a keyname, a space and a param ( it could be a list of params)

So lets say we have to identify tokens like:

T_ACTION, T_WHITESPACE, T_ARG and T_NEWLINE

We are gonna define our Grammar now. Take a look on how to apply the BNF into a programmary form.

I assume that APILexer and APIParser are on the same directory.

Finally lets do a simple code example

Now, with the parsed tokens you can do anything that evaluates the actions with its arguments.

For example, you may have an Interpreter that evaluates the tokens and do the corresponding actions.

I.e, GET may use some library to make HTTP GET requests; PIPETO may pass the gathered data to some of your system service and SAVEDB may save the result from PIPETO $mySuperService to the specified DDBB host.

Check also


All versions of php-grammar with dependencies

PHP Build Version
Package Version
Requires php Version >= 7.2
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 didix16/php-grammar contains the following files

Loading the files please wait ....