This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Regular expression implementation. | |
* Supports only ( | ) * + ?. No escapes. | |
* Compiles to NFA and then simulates NFA | |
* using Thompson's algorithm. | |
* | |
* See also http://swtch.com/~rsc/regexp/ and | |
* Thompson, Ken. Regular Expression Search Algorithm, | |
* Communications of the ACM 11(6) (June 1968), pp. 419-422. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Classic RegExp implementation (NFA, DFA). | |
* | |
* by Dmitry Soshnikov <[email protected]> | |
* MIT License, 2017 | |
*/ | |
/** | |
* Epsilon. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* NFA (Non-deterministic finite automata) | |
* | |
* A formalism for regular grammars (to recognize strings based on regular | |
* expressions). | |
* | |
* Regexp parser to transform AST to NFA: | |
* https://www.npmjs.com/package/regexp-tree | |
* | |
* NFA/DFA fragment examples: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* LR-parsing. | |
* | |
* Canonical collection of LR(0) items. | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style License (C) 2015 | |
* | |
* See this "rock-painting" to get the picture of what we're building here: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Building LL(1) parsing table from First and Follow sets. | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style License | |
* | |
* This diff is a continuation of what we started in the previous two diffs: | |
* | |
* Dependencies: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* LL(1) parser. Building parsing table, part 1: First and Follow sets. | |
* | |
* NOTICE: see full implementation in the Syntax tool, here: | |
* https://github.com/DmitrySoshnikov/syntax/blob/master/src/sets-generator.js | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style License | |
* | |
* An LL(1)-parser is a top-down, fast predictive non-recursive parser, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* = LL parser = | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style license | |
* | |
* Often one can see manually written LL parsers implemented as | |
* recursive descent. Approach in this diff is a classical parse table | |
* state machine. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Educational Stack-based VM. | |
* | |
* See also: | |
* - More complex example with recursion: https://gist.github.com/DmitrySoshnikov/afda459222e96e6002ac | |
* - Register-based VM example: https://gist.github.com/DmitrySoshnikov/6407781 | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* http://dmitrysoshnikov.com | |
* MIT Stye License (C) 2015 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var docRef = app.activeDocument; | |
cTID = function(s) { return app.charIDToTypeID(s); }; | |
sTID = function(s) { return app.stringIDToTypeID(s); }; | |
function newGroupFromLayers(doc) { | |
var desc = new ActionDescriptor(); | |
var ref = new ActionReference(); | |
ref.putClass( sTID('layerSection') ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Infix to postfix notation RegExp converter | |
* | |
* To implement RegExp machine (NFA, DFA) we need | |
* to transform first RegExp string to postfix notation | |
* for more convinient work with the stack. This function | |
* does exactly this. | |
* | |
* See: http://swtch.com/~rsc/regexp/regexp1.html | |
* |
NewerOlder