branch: externals/phps-mode commit d05601b606ef4bf509e76ddf808f598cff54d3d2 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Updated documents --- docs/heuristics.md | 2 ++ docs/imenu.md | 22 ++++++++++++++++++++++ docs/{indentation-algorithm.md => indentation.md} | 12 ++++++------ docs/todo.md | 2 ++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/docs/heuristics.md b/docs/heuristics.md new file mode 100644 index 0000000..90098f5 --- /dev/null +++ b/docs/heuristics.md @@ -0,0 +1,2 @@ +* When pressing return when line after cursor is only white-space +* When pressing backspace when line before cursor is only white-space diff --git a/docs/imenu.md b/docs/imenu.md new file mode 100644 index 0000000..9bba396 --- /dev/null +++ b/docs/imenu.md @@ -0,0 +1,22 @@ +# Imenu algorithm + +## Description + +This file explains with psuedo-code how the imenu generation algorithm works. + +## Psuedo-code + +``` +for token in tokens: + + if token is "{": + nesting-level + 1; + endif; + if token is "}": + nesting-level - 1; + endif; + + + +endfor; +``` diff --git a/docs/indentation-algorithm.md b/docs/indentation.md similarity index 95% rename from docs/indentation-algorithm.md rename to docs/indentation.md index c6fd0be..012fcdd 100644 --- a/docs/indentation-algorithm.md +++ b/docs/indentation.md @@ -1,4 +1,4 @@ -# Indentation algorithm for PHP +# Indentation algorithm Document describing indentation algorithm. @@ -13,7 +13,7 @@ Document describing indentation algorithm. ## Algorithm -Here follows pseudo-code for a algorithm that calculates indentation for each line in buffer. +Here follows pseudo-code for a algorithm that calculates indentation for each line in buffer. Tokens are from the official re2c PHP lexer. ```php foreach token in buffer: @@ -116,11 +116,11 @@ PHP examples using algorithms defined above, explained each line. ## Basic multi-line if-expression 1 -```php // #save indent: 0 +```php // #save indent: 0 if (function( // #save indent: 0, #increase push (0 2) indent: 1 - false) // #save indent: 1 + false) // #save indent: 1 ) { // #decrease pop (0 2) indent: 0, #save indent: 0, #increase push (0 1) indent: 1 - echo true; // #save indent: 1 + echo true; // #save indent: 1 } // #decrease pop (0 1) indent: 0, #save indent: 0 ``` @@ -163,7 +163,7 @@ endif; // #decrease pop (0 1) indent: 0, #save indent: 0 <?php // #save indent: 0 $var = array( // #save indent: 0, #increase push (0 2) indent: 1 'def' // #save indent: 1 -); // #decrease pop (0 2) indent: 0, #save indent: 0 +); // #decrease pop (0 2) indent: 0, #save indent: 0 ``` ## Multi-line assignments 2 diff --git a/docs/todo.md b/docs/todo.md new file mode 100644 index 0000000..822eef7 --- /dev/null +++ b/docs/todo.md @@ -0,0 +1,2 @@ +* Also format white-space inside the line, i.e. after function declarations? +* Fix imenu with multiple namespaces