qntm / loco Goto Github PK
View Code? Open in Web Editor NEWParsing library for PHP
License: MIT License
Parsing library for PHP
License: MIT License
Which class do you use to represent a non-terminal to a non-terminal rule??
<script> ::= <statements>
<statements> ::= <statements> <statement> | <statement>
<statement> ::= <assignment-stm> | <return-stm>
...
new Ferno\Loco\Grammar(
"<script>",
array(
"<script>" => ??? <- to <statements>
),
function($script)
{
return $script;
}
);
Thank you for adding the composer.json. It would be great if you could submit this repository to packagist.org too. Before that, version-tagging the repository is important.
I migrated the codebase towards PSR coding standards, namespaces and auto-loading.
https://github.com/mindplay-dk/loco
I did not submit a pull-request (yet) because the addition of namespaces breaks backwards compatibility - I figured there's a good chance you would want to start a 2.0 branch first, if you're willing to pull my changes?
I'm hoping this will help the project gain some traction, as following standards will appeal to a broader community and makes it easier to contribute.
I left the example/test scripts alone, for the most part - I didn't want to break your formatting, so these files do not follow standards at the moment. Only the core library has been migrated to use namespaces.
All the example code has been tested and works with these changes.
if(FILE !== $_SERVER["PHP_SELF"]) {
return;
}
for me (php5.3, windows) it's full path in FILE and only file name in $_SERVER["PHP_SELF"]
I apologize the poor title but that's all I got right now.
https://github.com/qntm/loco/blob/master/src/Loco.php#L795
I believe this line is wrong, it should be:
if (!is_a($internal, "Ferno\\Loco\\GreedyMultiParser")) {
Also, I'm not sure what "$internal->optional" is, probably is meant to be nullable?
In order for this project to gain some footing, you need to provide a license - most developers are working in a commercial setting of some sort, and won't consider contributing unless the code is properly licensed.
I am playing with a Matchparser but as somewhat newbie to parsing and lexing, i am wondering if there is place for such a parser in the library, or that it might be totally beyond the scope of loco.
The idea is that instead of using a ConcParser for every possible known xml or html tag <p <h etc. just fetch matching pairs.
new MatchParser( array(
'<', 'name', '>','content','</', 'name', '>',
1, 4 // should match and not be nullable
))
//...
/*
<channel>
<item></item>
<xxx></xxx>
</channel>
*/
I made a copy of the ConcParser where two internals have to match. During construct it is checked that both internals are identical, and during parsing the two args[] should be identical, otherwise throw an exception.
I haven't found out an easy way how to check that both the matching internals should not be nullable.
The MatchParser can be found in this gist, as i didn't want to do a pull request, before knowing if this type of parser might be out of order.
The GreedyMultiParser getResult method does a for($k) on lower and optional limits but it never references $k and only fetches matches for internals[0]. Is this intentional?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.