klorenz / atom-regex-railroad-diagrams Goto Github PK
View Code? Open in Web Editor NEWdisplay regex as railroad diagram, if cursor moves to it
License: MIT License
display regex as railroad diagram, if cursor moves to it
License: MIT License
Hey Guys,
I get this annoying error message. How can I fix this problem?
Where do I get the 'regexp' module?
Attached you find the steps I did so far and the atom report.
Best regards,
Ottnorml
Atom Version: 1.0.0
System: ADMIN-PC
Thrown From: atom-regex-railroad-diagrams package, vundefined
Failed to load the regex-railroad-diagram package
At Cannot find module 'regexp'
Error: Cannot find module 'regexp'
at Module._resolveFilename (module.js:328:15)
at Function.Module._resolveFilename (C:\Users\OttNorml\AppData\Local\atom\app-1.0.0\resources\app.asar\src\module-cache.js:383:52)
at Function.Module._load (module.js:270:25)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/C:/Users/OttNorml/.atom/packages/atom-regex-railroad-diagrams/lib/regex-to-railroad.coffee:4:11)
at Object.<anonymous> (/C:/Users/OttNorml/.atom/packages/atom-regex-railroad-diagrams/lib/regex-to-railroad.coffee:224:4)
at Module._compile (module.js:452:26)
at Object.requireCoffeeScript (C:\Users\OttNorml\AppData\Local\atom\app-1.0.0\resources\app.asar\node_modules\coffee-cash\lib\coffee-cash.js:85:19)
at Module.load (module.js:347:32)
{
"core": {
"disabledPackages": [
"metrics"
]
}
}
# User
color-picker, v2.0.9
minimap, v4.10.2
pigments, v0.8.2
pretty-json, v0.4.1
# Dev
No dev packages
Hi all,
I really love this package, both as a tool, but also to teach regular expressions to people. To bad it doesn't seem to be maintained anymore.
Is there any news from @klorenz on the commitment for this package? Does anyone who has already created PR"s or personal forks feel like creating a forked release?
Is there anything else that could be done?
Occasionally in python the system only grabs part of the regular expression. For example in this regex:
ur"([a-z][a-z0-9]*)([A-Z][a-z0-9]*)*_$"
it misses the _$
portion in the diagram and in this
ur"([a-zA-z]+[0-9]+)/ours/([a-zA-Z]+-[a-zA-Z]+|[a-zA-Z]+)/(hw[0-9]+)"
it grabs each group individually and ignores the /ours/
portion
I have the following code in a ES6 code.
const DEFAULT_PATTERN = /([a-zA-Z]{2,5})-?(\d{3,5})/g;
But the plugin doesn't recognize my regex correctly, it says:
/([a-zA-Z]{2,5})-?(\d{3,5}
^
Expected "$", "(", ")", ".", "\\", "\\0", "\\A", "\\B", "\\D", "\\G", "\\S", "\\W", "\\Z", "\\b", "\\c", "\\d", "\\f", "\\n", "\\r", "\\s", "\\t", "\\u", "\\v", "\\w", "\\x", "\\z", "|", CharacterSet or Literal but end of input found.
Since the update to Atom 0.189.0, some calls seem to be deprecated:
Requiring $$
from atom
is no longer supported.
Please require atom-space-pen-views
instead:
{$$} = require 'atom-space-pen-views'
Add "atom-space-pen-views": "^2.0.3"
to your package dependencies.
Object.Object.defineProperty.get (D:\Programme\Dokumente\Atom\resources\app\exports\atom.js:49:9)
Object.<anonymous> (C:\Users\Daniel\.atom\packages\regex-railroad-diagram\lib\regex-railroad-diagram-view.coffee:1:7)
Requiring View
from atom
is no longer supported.
Please require atom-space-pen-views
instead:
{View} = require 'atom-space-pen-views'
Add "atom-space-pen-views": "^2.0.3"
to your package dependencies.
Object.Object.defineProperty.get (/Applications/Atom.app/Contents/Resources/app/exports/atom.js:61:9)
Object.<anonymous> (/Users/kyoh/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:1:1)
What happened in the last few versions of the package? It's good to know what changes in each version in terms of API, performance, bug fixes, features.
Since the update to Atom 0.189.0, this message appears:
Store package style sheets in the styles/
directory instead of stylesheets/
in the regex-railroad-diagram
package
Package.getStylesheetsPath (D:\Programme\Dokumente\Atom\resources\app\src\package.js:448:9)
Package.getStylesheetPaths (D:\Programme\Dokumente\Atom\resources\app\src\package.js:459:32)
The fix should be simple: You only have to rename the folder stylesheets
to styles
. You also have to adjust the path if you used the original path in your code (I found one case in the file select-list-view.js
at line 12).
For example: /dbo\.Test\(\)/
should show up as a single bubble, dbo.Test()
rather than 5: dbo
.
Test
(
)
. I suppose this could also live as a new option, "coalesce escaped literals with adjacent literals" or something.
I'm wondering if this can be used without Atom.
If not, it may be interesting to move the core code out in its own JS library which generates SVG code from a regexp.
The regex scope narrowing by skipping punctuation scopes is too aggressive. It causes errors if the regex begins or ends with a group (or other regex punctuation). It should only skip "punctuation.section.regexp" (begin and end), not "punctuation.definition.group" for example. The problem manifests as an unbalanced group but also occurs more subtly if the group is at both ends of the regex (the grouping disappears from the diagram).
The regex /(foo|bar)/ illustrates the disappearing grouping. And /(foo|bar)$/ illustrates the unbalanced grouping error.
[Enter steps to reproduce below:]
Atom Version: 0.179.0
System: Mac OS X 10.9.5
Thrown From: regex-railroad-diagram package, v0.6.3
Uncaught TypeError: Cannot read property 'tokenIndexAtBufferColumn' of undefined
At /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/tokenized-buffer.js:567
TypeError: Cannot read property 'tokenIndexAtBufferColumn' of undefined
at TokenizedBuffer.module.exports.TokenizedBuffer.bufferRangeForScopeAtPosition (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/tokenized-buffer.js:567:33)
at DisplayBuffer.module.exports.DisplayBuffer.bufferRangeForScopeAtPosition (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/display-buffer.js:1048:35)
at TextEditor.module.exports.TextEditor.bufferRangeForScopeAtCursor (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/text-editor.js:2441:33)
at RegexRailroadDiagramView.module.exports.RegexRailroadDiagramView.updateRailRoadDiagram (/Users/Ilan/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:26:20)
at atom-workspace.<anonymous> (/Users/Ilan/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:1:1)
at atom-workspace.handler (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/space-pen-extensions.js:112:34)
at atom-workspace.jQuery.event.dispatch (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4681:9)
at atom-workspace.elemData.handle (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4359:46)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/command-registry.js:243:29)
at CommandRegistry.handleCommandEvent (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/command-registry.js:3:61)
at CommandRegistry.module.exports.CommandRegistry.dispatch (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/command-registry.js:156:19)
at TextEditorView.jQuery.fn.trigger (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/space-pen-extensions.js:64:23)
at [object Object].module.exports.React.createClass.componentDidUpdate (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/text-editor-component.js:198:49)
at CallbackQueue.mixInto.notifyAll (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/CallbackQueue.js:75:22)
at ReactReconcileTransaction.ON_DOM_READY_QUEUEING.close (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactReconcileTransaction.js:88:26)
at ReactReconcileTransaction.Mixin.closeAll (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/Transaction.js:214:42)
at ReactReconcileTransaction.Mixin.perform (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/Transaction.js:155:16)
at ReactUpdatesFlushTransaction.Mixin.perform (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/Transaction.js:141:20)
at ReactUpdatesFlushTransaction.mixInto.perform (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactUpdates.js:98:38)
at Object.flushBatchedUpdates (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactUpdates.js:176:19)
at ReactDefaultBatchingStrategyTransaction.Mixin.closeAll (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/Transaction.js:214:42)
at ReactDefaultBatchingStrategyTransaction.Mixin.perform (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/Transaction.js:155:16)
at Object.ReactDefaultBatchingStrategy.batchedUpdates (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactDefaultBatchingStrategy.js:70:19)
at Object.enqueueUpdate (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactUpdates.js:209:22)
at [object Object].ReactCompositeComponentMixin.forceUpdate (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1232:18)
at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/text-editor-component.js:243:28
-9:39.9 core:save (atom-text-editor.editor.is-focused)
2x -9:37.4 core:cut (atom-text-editor.editor.is-focused)
-9:36.9 core:save (atom-text-editor.editor.is-focused)
-9:11.3 emmet:toggle-comment (atom-text-editor.editor.is-focused)
-9:10.8 core:save (atom-text-editor.editor.is-focused)
-6:44.6 core:cut (atom-text-editor.editor.is-focused)
-6:44.3 core:save (atom-text-editor.editor.is-focused)
-6:41.5 core:undo (atom-text-editor.editor.is-focused)
2x -6:41.3 core:save (atom-text-editor.editor.is-focused)
-6:23.4 command-palette:toggle (atom-text-editor.editor.is-focused)
-6:21.4 core:move-down (atom-text-editor.editor.mini)
-6:21.1 core:confirm (atom-text-editor.editor.mini)
-6:21.1 editor:auto-indent (atom-text-editor.editor.is-focused)
3x -6:19.4 core:save (atom-text-editor.editor.is-focused)
7x -0:05.0 core:undo (atom-text-editor.editor.is-focused)
-0:00.6 core:save (atom-text-editor.editor.is-focused)
{
"core": {
"disabledPackages": [
"atom-beautify"
],
"themes": [
"seti-ui",
"seti-syntax"
]
}
}
# User
angularjs, v0.1.0
docblockr, v0.5.8
editorconfig, v0.3.0
emmet, v2.3.3
git-log, v0.2.0
jsformat, v0.7.18
language-jade, v0.3.0
language-json, v0.12.0
linter, v0.11.1
linter-jshint, v0.1.0
regex-railroad-diagram, v0.6.3
seti-syntax, v0.3.1
seti-ui, v0.6.3
# Dev
No dev packages
Requiring $$
from atom
is no longer supported.
Please require atom-space-pen-views
instead:
{$$} = require 'atom-space-pen-views'
Add "atom-space-pen-views": "^2.0.3"
to your package dependencies.
Object.Object.defineProperty.get (/Applications/Atom.app/Contents/Resources/app/exports/atom.js:49:9)
Object.<anonymous> (/Users/kyoh/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:1:7)
[Enter steps to reproduce below:]
Atom Version: 1.0.16
System: Mac OS X 10.10.5
Thrown From: regex-railroad-diagram package, v0.10.3
Uncaught ReferenceError: expecctedClose is not defined
At /Users/slobo/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram.coffee:124
ReferenceError: expecctedClose is not defined
at Object.module.exports.cleanRegex (/Users/slobo/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram.coffee:124:17)
at Object.module.exports.checkForRegExp (/Users/slobo/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram.coffee:150:27)
at /Users/slobo/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram.coffee:18:73
at later (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/underscore-plus/node_modules/underscore/underscore.js:724:25)
-2:48.8.0 core:backspace (atom-text-editor.editor.is-focused)
6x -2:48.5.0 core:move-right (atom-text-editor.editor.is-focused)
6x -2:47.4.0 core:backspace (atom-text-editor.editor.is-focused)
-2:44.9.0 core:save (atom-text-editor.editor.is-focused.autocomplete-active)
3x -2:44.6.0 core:move-up (atom-text-editor.editor.is-focused.autocomplete-active)
-2:43.6.0 autocomplete-plus:cancel (atom-text-editor.editor.is-focused.autocomplete-active)
2x -2:43.3.0 core:move-up (atom-text-editor.editor.is-focused)
-2:42.7.0 core:move-right (atom-text-editor.editor.is-focused)
-2:41.8.0 core:move-down (atom-text-editor.editor.is-focused)
2x -2:41.5.0 core:move-left (atom-text-editor.editor.is-focused)
-2:41 core:move-right (atom-text-editor.editor.is-focused)
-2:40.7.0 core:backspace (atom-text-editor.editor.is-focused)
-2:39.5.0 core:save (atom-text-editor.editor.is-focused)
-2:38.2.0 core:move-right (atom-text-editor.editor.is-focused)
3x -2:38 core:select-down (atom-text-editor.editor.is-focused)
-2:37.3.0 core:copy (atom-text-editor.editor.is-focused)
{
"core": {
"disabledPackages": [
"vim-mode",
"terminal-status",
"file-icon-supplement",
".bin",
"perltidy",
"linter-perl"
],
"themes": [
"atom-dark-ui",
"monokai"
]
}
}
# User
aligner, v0.16.1
atom-typescript, v6.0.14
autoclose-html, v0.19.0
autocomplete-paths, v1.0.2
docblockr, v0.7.3
file-icons, v1.6.9
hex, v0.6.2
jshint, v1.8.0
last-cursor-position, v0.9.0
linter, v1.6.0
monokai, v0.18.0
pretty-json, v0.4.1
project-manager, v2.5.2
react, v0.12.10
regex-railroad-diagram, v0.10.3
save-session, v0.15.7
# Dev
No dev packages
[Enter steps to reproduce below:]
Atom Version: 0.206.0
System: Mac OS X 10.10.3
Thrown From: regex-railroad-diagram package, v0.7.4
Uncaught TypeError: Cannot read property 'find' of undefined
At /Users/petey/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:125
TypeError: Cannot read property 'find' of undefined
at RegexRailroadDiagramView.module.exports.RegexRailroadDiagramView.showRailRoadDiagram (/Users/petey/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:125:15)
at RegexRailroadDiagramView.module.exports.RegexRailroadDiagramView.updateRailRoadDiagram (/Users/petey/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:97:14)
at RegexRailroadDiagramView.updateRailRoadDiagram (/Users/petey/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:1:1)
at /Users/petey/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:21:10
at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
at TextEditor.module.exports.TextEditor.cursorMoved (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:1563:27)
at /Applications/Atom.app/Contents/Resources/app.asar/src/cursor.js:56:31
at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
at Marker.module.exports.Marker.notifyObservers (/Applications/Atom.app/Contents/Resources/app.asar/src/marker.js:270:27)
at /Applications/Atom.app/Contents/Resources/app.asar/src/marker.js:65:26
at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
at Marker.module.exports.Marker.emitChangeEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/marker.js:390:20)
at Marker.module.exports.Marker.update (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/marker.js:339:12)
at Marker.module.exports.Marker.setHeadPosition (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/marker.js:140:19)
at Marker.module.exports.Marker.setHeadBufferPosition (/Applications/Atom.app/Contents/Resources/app.asar/src/marker.js:175:32)
at Marker.module.exports.Marker.setHeadScreenPosition (/Applications/Atom.app/Contents/Resources/app.asar/src/marker.js:185:19)
at /Applications/Atom.app/Contents/Resources/app.asar/src/cursor.js:121:31
at Cursor.module.exports.Cursor.changePosition (/Applications/Atom.app/Contents/Resources/app.asar/src/cursor.js:683:7)
at Cursor.module.exports.Cursor.setScreenPosition (/Applications/Atom.app/Contents/Resources/app.asar/src/cursor.js:119:19)
at Cursor.module.exports.Cursor.moveLeft (/Applications/Atom.app/Contents/Resources/app.asar/src/cursor.js:311:21)
at /Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:1396:23
at TextEditor.module.exports.TextEditor.moveCursors (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:1554:9)
at TextEditor.module.exports.TextEditor.moveLeft (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:1395:19)
at TextEditor.atom.commands.add.stopEventPropagation.core:move-left (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor-element.js:326:19)
at atom-text-editor.newCommandListeners.(anonymous function) (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor-element.js:288:32)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:238:29)
at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:520:16)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:355:22)
at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:177:20)
-0:03.3.0 docblockr:parse-enter (atom-text-editor.editor.is-focused)
-0:03.3.0 editor:newline (atom-text-editor.editor.is-focused)
-0:01.2.0 core:move-left (atom-text-editor.editor.is-focused)
{
"core": {
"disabledPackages": [
"metrics",
"cucumber-step",
"coffee-compile",
"git-grep",
"project-ring",
"project-switcher",
"react",
"pretty-json",
"todo-list",
"mocha-test-runner",
"mocha-ui",
"package-js-generator"
],
"projectHome": "~/git/"
}
}
# User
atom-yamljson, v0.2.3
cucumber, v0.5.0
docblockr, v0.7.2
ember-cli-helper, v0.7.2
file-icons, v1.5.7
git-projects, v1.14.1
git-tab-status, v1.9.2
javascript-snippets, v1.0.0
language-arduino, v0.2.1
language-chef, v0.4.0
linter, v0.12.6
linter-csslint, v0.0.13
linter-js-yaml, v1.0.1
linter-jshint, v0.1.6
linter-jsonlint, v0.1.4
markdown-scroll-sync, v0.4.0
project-colorize, v0.2.0
regex-railroad-diagram, v0.7.4
symbols-tree-view, v0.9.3
# Dev
No dev packages
Since the update to Atom 0.189.0, some calls seem to be deprecated:
Requiring View
from atom
is no longer supported.
Please require atom-space-pen-views
instead:
{View} = require 'atom-space-pen-views'
Add "atom-space-pen-views": "^2.0.3"
to your package dependencies.
Object.Object.defineProperty.get (D:\Programme\Dokumente\Atom\resources\app\exports\atom.js:61:9)
Object.<anonymous> (C:\Users\Daniel\.atom\packages\regex-railroad-diagram\lib\regex-railroad-diagram-view.coffee:1:1)
Call ::getActiveTextEditor instead
Workspace.getActiveEditor (/Applications/Atom.app/Contents/Resources/app/src/workspace.js:674:12)
RegexRailroadDiagramView.module.exports.RegexRailroadDiagramView.updateRailRoadDiagram (/Users/kyoh/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:32:28)
http://www.gnu.org/software/grep/manual/html_node/Character-Classes-and-Bracket-Expressions.html
The diagram is wrong if there are these bracket expressions.
Given this test in perl:
$line =~ /[a-z]*/
Or any test of the form:
$variablename =~ /REGEX/
This error pops up:
~ /[a-z]*/
^
Expected "$", "("...........CharacterSet, Literal, or Quantifier but "/" found (for the first "/")
"MATCH operators will test a string of information to see if the specified regular expression is present. If true, the statement returns a true (non-zero) value. If no match, it returns a zero or false value. The match is symbolized by an equals and tilde. "
Do you think there's anything you can do about this?
(PS. This tool is awesome when it works!)
The "railroad" track should have some kind of close functionality (ESC?) because some regular expressions may eat up all screen estate. Right now I have a regex on screen that leaves me 10 lines of code visible on the screen. Not much more needed and I can't see my code at all. ;)
It does not show diagram view even when regex is under the cursor.
Command palette does not show shortcut for toggling diagram too.
It seems the parser makes some wierd assumptions about tab size when using tabs. It correctly identifies regexes, but misplaces their position in the line as if spaces was used.
Example from a line indented with 3 tabs with tab-width set to 4:
.replace(/(\+\d+)? ?(\d{2}) ?(\d{2}) ?(\d{2}) ?(\d{2})/g, '$1 $2 $3 $4 $5')
results in the error
?(\d{2}) ?(\d{2}) ?(\d{2}) ?(\d{2})/g, '$1 $2
Expected "^" but "?" found.
You'll note the regex given is offset by 9 characters, the difference between indenting with tabs and spaces. The diagram is also only visible when the cursor is inside the string given, rather than inside the actual regex. Running tabs to spaces fixes the problem (but is of course not an option, as the project uses tabs).
Hi,
stock atom (0.106.0) on OS X Mavericks, I installed the package using the graphic tool. I cannot get it to do anything. Using the keybinding resolver, I see it being known, but "ctrl-alt-o" does nothing when over a regex in my Python code. Here is my regex:
regex = re.compile('%ASA-3-106100: access-list (.*) permitted (udp|tcp) (.*?)/(.*?)\(.*?\) -> (.*?)/(.*?)\((.*?)\)')
TIA for helping,
Charles
For example, instead of "greedy" and "lazy" for \s*
and .+?
respectively, print out something like "zero or more (greedy)" and "at least one or more (lazy)". The repetition syntax already results in this kind of description, and that's good.
When doing validations in Rails you often use '\z' to match end of string because you can easily circumvent '$' if you put a newline in the string. However '\z' is shows up as a simple 'z' in the diagram.
Read more: http://stackoverflow.com/questions/577653/difference-between-a-z-and-in-ruby-regular-expressions
Thoughts? Are you following a certain regex spec?
It looks like it doesn't play well with the React Editor. Here's an error log.
railroad diagram activated regex-railroad-diagram.coffee:7
TypeError: Object #<Editor> has no method 'decorationsForBufferRow'
at [object Object].module.exports.React.createClass.getGutterDecorations (/Applications/Atom.app/Contents/Resources/app/src/editor-component.js:315:41)
at [object Object].boundMethod [as getGutterDecorations] (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1434:21)
at [object Object].module.exports.React.createClass.render (/Applications/Atom.app/Contents/Resources/app/src/editor-component.js:63:28)
at [object Object]._renderValidatedComponent (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1394:34)
at [object Object].updateComponent (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1326:32)
at [object Object].ReactCompositeComponentMixin._performComponentUpdate (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1264:10)
at [object Object].ReactCompositeComponentMixin._performUpdateIfNecessary (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1207:14)
at ReactReconcileTransaction.Mixin.perform (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/Transaction.js:159:20)
at [object Object].ReactComponent.Mixin.performUpdateIfNecessary (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactComponent.js:478:19)
at [object Object].ReactCompositeComponentMixin.performUpdateIfNecessary (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1157:51)
at Object.enqueueUpdate (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactUpdates.js:107:15)
at [object Object].ReactCompositeComponentMixin.forceUpdate (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1379:18)
at [object Object].module.exports.React.createClass.requestUpdate (/Applications/Atom.app/Contents/Resources/app/src/editor-component.js:237:21)
at [object Object].boundMethod [as requestUpdate] (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1434:21)
at [object Object].module.exports.React.createClass.onBatchedUpdatesEnded (/Applications/Atom.app/Contents/Resources/app/src/editor-component.js:986:21)
at boundMethod (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1434:21)
at /Applications/Atom.app/Contents/Resources/app/node_modules/emissary/lib/emitter.js:133:30
at Array.forEach (native)
at Editor.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/emissary/lib/emitter.js:132:47)
at Editor.module.exports.Editor.batchUpdates (/Applications/Atom.app/Contents/Resources/app/src/editor.js:1915:12)
at [object Object].module.exports.React.createClass.measureLineHeightAndDefaultCharWidth (/Applications/Atom.app/Contents/Resources/app/src/lines-component.js:284:21)
at [object Object].boundMethod [as measureLineHeightAndDefaultCharWidth] (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1434:21)
at [object Object].module.exports.React.createClass.measureLineHeightAndDefaultCharWidth (/Applications/Atom.app/Contents/Resources/app/src/editor-component.js:1143:30)
at [object Object].boundMethod [as measureLineHeightAndDefaultCharWidth] (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1434:21)
at /Applications/Atom.app/Contents/Resources/app/src/editor-component.js:203:17
at Editor.module.exports.Editor.batchUpdates (/Applications/Atom.app/Contents/Resources/app/src/editor.js:1914:16)
at [object Object].module.exports.React.createClass.componentDidMount (/Applications/Atom.app/Contents/Resources/app/src/editor-component.js:201:21)
at ReactMountReady.mixInto.notifyAll (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactMountReady.js:69:18)
at ReactReconcileTransaction.ON_DOM_READY_QUEUEING.close (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactReconcileTransaction.js:87:26)
at ReactReconcileTransaction.Mixin.closeAll (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/Transaction.js:242:42)
at ReactReconcileTransaction.Mixin.perform (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/Transaction.js:175:16)
at [object Object].ReactComponent.Mixin.mountComponentIntoNode (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactComponent.js:537:19)
at Object._renderNewRootComponent (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactMount.js:309:25)
at Object.ReactMount.renderComponent (/Applications/Atom.app/Contents/Resources/app/node_modules/react-atom-fork/lib/ReactMount.js:359:32)
at ReactEditorView.module.exports.ReactEditorView.afterAttach (/Applications/Atom.app/Contents/Resources/app/src/react-editor-view.js:89:30)
at callAttachHook (/Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/lib/space-pen.js:343:107)
at [object Object].jQuery.fn.(anonymous function) [as append] (/Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/lib/space-pen.js:359:9)
at PaneView.module.exports.PaneView.onActiveItemChanged (/Applications/Atom.app/Contents/Resources/app/src/pane-view.js:297:24)
at /Applications/Atom.app/Contents/Resources/app/src/pane-view.js:3:61
at /Applications/Atom.app/Contents/Resources/app/node_modules/emissary/lib/emitter.js:133:30
at Array.forEach (native)
at Behavior.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/emissary/lib/emitter.js:132:47)
at Behavior.module.exports.Behavior.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/emissary/lib/behavior.js:44:38)
at Behavior.module.exports.Signal.emitValue (/Applications/Atom.app/Contents/Resources/app/node_modules/emissary/lib/signal.js:82:19)
at Pane.module.exports.Model.set (/Applications/Atom.app/Contents/Resources/app/node_modules/theorist/lib/model.js:166:21)
at Pane.accessor.set (/Applications/Atom.app/Contents/Resources/app/node_modules/theorist/lib/model.js:57:23)
at Pane.module.exports.Pane.activateItem (/Applications/Atom.app/Contents/Resources/app/src/pane.js:175:32)
at /Applications/Atom.app/Contents/Resources/app/src/workspace.js:214:16
at _fulfilled (/Applications/Atom.app/Contents/Resources/app/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/Applications/Atom.app/Contents/Resources/app/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/q/q.js:749:13)
at /Applications/Atom.app/Contents/Resources/app/node_modules/q/q.js:557:44
at flush (/Applications/Atom.app/Contents/Resources/app/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:605:11)
/Applications/Atom.app/Contents/Resources/app/src/workspace.js:223
Uncaught TypeError: Object #<Editor> has no method 'decorationsForBufferRow' /Applications/Atom.app/Contents/Resources/app/src/editor-component.js:315
It would be great if this tool was available when searching with the Find / Replace pane in Atom.
Please see the error message.
npm ERR! fetch failed https://github.com/klorenz/railroad-diagrams.git
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 406
npm ERR! fetch failed https://github.com/klorenz/regexp.git
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 406
npm ERR! fetch failed https://github.com/klorenz/railroad-diagrams.git
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 406
npm ERR! fetch failed https://github.com/klorenz/regexp.git
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 406
npm ERR! fetch failed https://github.com/klorenz/railroad-diagrams.git
npm ERR! fetch failed https://github.com/klorenz/regexp.git
npm ERR! Darwin 14.1.0
npm ERR! argv "/Applications/Atom.app/Contents/Resources/app/apm/bin/node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/bin/npm-cli.js" "--globalconfig" "/Users/username/.atom/.apm/.apmrc" "--userconfig" "/Users/username/.atom/.apmrc" "install" "/private/var/folders/1d/8rzpz2116797s2msmkymxkjc0000gn/T/d-11533-3709-an5xb5/package.tgz" "--target=0.22.0" "--arch=x64"
npm ERR! node v0.10.35
npm ERR! npm v2.5.1
npm ERR! fetch failed with status code 406
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /private/var/folders/1d/8rzpz2116797s2msmkymxkjc0000gn/T/apm-install-dir-11533-3709-95yszs/npm-debug.log
If I have a file open and the railroad diagram is showing, I then close the file, and the diagram is still there. The diagram should close if the file isn't open anymore.
PHP uses delimiters around a regex string, see: http://php.net/manual/en/regexp.reference.delimiters.php . However, this confuses this plugin completely. For example, this is a valid regex in PHP:
preg_match("/^abc[def]g/",$target)
But it throws this error:
"/^abc[def]g/"
^
Expected "$", "(", ".", "\\", "\\0", "\\A", "\\B", "\\D", "\\G", "\\S", "\\W", "\\Z", "\\b", "\\c", "\\d", "\\f", "\\n", "\\r", "\\s", "\\t", "\\u", "\\v", "\\w", "\\x", "\\z", "|", CharacterSet, Literal or Quantifier but "/" found.
Is there any way to check for .php files and handle the delimiter automatically?
I get an error message like this when I try to install the package
npm ERR! git clone git://github.com/klorenz/railroad-diagrams.git Cloning into bare repository '/home/abinashmeher999/.atom/.apm/_git-remotes/git-github-com-klorenz-railroad-diagrams-git-e7ef8859'...
npm ERR! git clone git://github.com/klorenz/railroad-diagrams.git fatal: unable to connect to github.com:
npm ERR! git clone git://github.com/klorenz/railroad-diagrams.git github.com[0: 192.30.252.131]: errno=Connection refused
npm ERR! git clone git://github.com/klorenz/regexp.git Cloning into bare repository '/home/abinashmeher999/.atom/.apm/_git-remotes/git-github-com-klorenz-regexp-git-00540c62'...
npm ERR! git clone git://github.com/klorenz/regexp.git fatal: unable to connect to github.com:
npm ERR! git clone git://github.com/klorenz/regexp.git github.com[0: 192.30.252.131]: errno=Connection refused
npm ERR! Linux 3.13.0-55-generic
npm ERR! argv "/usr/share/atom/resources/app/apm/bin/node" "/usr/share/atom/resources/app/apm/node_modules/npm/bin/npm-cli.js" "--globalconfig" "/home/abinashmeher999/.atom/.apm/.apmrc" "--userconfig" "/home/abinashmeher999/.atom/.apmrc" "install" "/tmp/d-11568-4395-15i8k7r/package.tgz" "--target=0.22.0" "--arch=x64"
npm ERR! node v0.10.35
npm ERR! npm v2.5.1
npm ERR! code 128
npm ERR! Command failed: Cloning into bare repository '/home/abinashmeher999/.atom/.apm/_git-remotes/git-github-com-klorenz-railroad-diagrams-git-e7ef8859'...
npm ERR! fatal: unable to connect to github.com:
npm ERR! github.com[0: 192.30.252.131]: errno=Connection refused
npm ERR!
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/apm-install-dir-11568-4395-vrxejx/npm-debug.log
Maybe this is because I use atom behind proxy and the git clone
command above is executed with the git://
beginning url. I have faced this problem before when I have tried to clone a repo with it's git url, it has failed. Changing the url to a https one might solve the issue.
The following regex gives me an exception:
/\b@?TODO:?\s(.+$)/g
/\b@?TODO:?\s(.+$
^
Expected ")" or "|" but end of input found.
I have just installed this (awesome) plugin and am getting
Uncaught TypeError: Cannot call method 'bufferRangeForScopeAtCursor' of undefined regex-railroad-diagram-view.coffee:19
This plugin stopped working a while back. Nothing pops up when placing the cursor over a regex, and it's not possible to toggle with ctrl-alt-o.
atom.workspaceView is no longer available.
In most cases you will not need the view. See the Workspace docs for
alternatives: https://atom.io/docs/api/latest/Workspace.
If you do need the view, please use atom.views.getView(atom.workspace)
,
which returns an HTMLElement.
Atom.Object.defineProperty.get (/usr/share/atom/resources/app/src/atom.js:55:11)
RegexRailroadDiagramView.initialize (/home/slanger/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:16:9)
atom.workspaceView is no longer available.
In most cases you will not need the view. See the Workspace docs for
alternatives: https://atom.io/docs/api/latest/Workspace.
If you do need the view, please use atom.views.getView(atom.workspace)
,
which returns an HTMLElement.
Atom.Object.defineProperty.get (/Applications/Atom.app/Contents/Resources/app/src/atom.js:53:11)
RegexRailroadDiagramView.initialize (/Users/stjohn/.atom/packages/regex-railroad-diagram/lib/regex-railroad-diagram-view.coffee:16:9)
It's kinda annoying that when you try to uncomment a line, either by //
or by /*
, the view for the railroad pops up. It really breaks the flow of typing.
I suggest the view only popping up when there's an opening AND closing /
(and text in between them).
Ideally the diagram should be different if there is a /g
at the end instead of /
, because it means that the regex picks up all instances, and not just the first one.
I'm fixing the scala grammar, similar to #16 a regex is enclosed by strings.
'match': "(@(?:tparam|throws))\\s+(\\S)(\\s+)"
vs
'match': /(@(?:tparam|throws))\\s+(\\S)(\\s+)/
it's based on oniguruma (http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt)
For example the code /(<|>)/
will work just fine, but /(<|>)/gi
will fail giving a `Expected "$", "(", ......, but ")" found.
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.