I'm generating a static parser using ParserGenApp. The generated code contains assembler callbacks in the form 'parser:didMatch[Rule]:'. However, in your JavaScriptSyntaxParser in DempApp the callbacks have the form 'parser:didMatchInterior:' and alike. Can I get ParserGenApp to generate such calls? Or did you add them manually?
Thanks/Mikael
Developer of ParseKit here.
The key is the setting of the "Post Match Callbacks" popup.
By default, the ParserGenApp is configured to produce the normal parser:didMatch[Rule]: callbacks. These are useful for most applications. (this is the "on All" setting).
But you are looking for the syntax tree callbacks like parser:didMatchInterior: and parser:didMatchLeaf:.
To generate the syntax tree callbacks, change the "Post Match Callbacks" popup to the "on Syntax" option. And regenerate.
Related
Is there a such thing as a preprocessor whose statements, once processed, disappear completely and get replaced by the target language syntax permanently?
I want to research it on the web but I don't know what term to search for. If I search for "code generator", "templating language", "preprocessor directives", "mixins", "annotations" I get generators whose input becomes the source of truth.
The closest thing I can think of is a macro.
What I'm trying to do
I often have to write code that is verbose and unnecessary manual labor and am looking for a smarter way to input at least the majority of it and have it automatically transformed and only source-control the output (and hand edit if necessary). For example:
Java code - Instead of writing getters/setters, javadoc (perhaps the transformer can be a maven plugin)
HTML - I just want to add URLs, and have my preprocessor automatically convert them to links, images, videos, audio etc. depending on the file extension with some regex substitution (currently I run a perl script via a cron job)
I just want to use it as my own shorthand and not enforce it in my project and make the output editable so that others have to learn a new framework or language (like Protobuf, Stringtemplate, GWT, C hash-defines, PHP, JSP etc).
There should be no direct clue that I used a template/preprocessor to generate it.
What you want is a "program transformation system". See https://en.wikipedia.org/wiki/Program_transformation. (This is a superset of "transpilers" [ugly term]).
A good source-to-source transformation system will let you apply rewrite rules of the form of:
if you see *this*, replace it by *that* if *this_condition*.
You can then take your source code, and run a set of rewrite rules across that code to change it.
The resulting code is "transformed"; the rewrite rules are not visible.
It seems like Transpiler is one way to describe it.
Is there a way to prevent errors display while still adding the error classes from the js (not with the attribute)? If I use uiEnabled: true I get neither.
This issue solves the problem with attributes, but not from js code.
Why don't you simply hide the error messages with CSS?
Indeed, that's exactly what CSS is for.
Parsley generates error messages and classes, it's then up to you to provide the CSS for the display to match the look what you want. If that's display:none on the error messages, that's fine.
Realize that when designing a library like Parsley, the priority is to add features for things are difficult to achieve without it and fairly common. Hiding messages is neither difficult (it's one line of CSS) nor common, so it shouldn't be surprising that there isn't an option for it.
I want to delete validation errors generated by PHP (that is server-side) when user triggers any validation.
I can delete previous validation errors when in fact there are new errors using the errorsContainer option.
(As on the next example: http://jsfiddle.net/bzydxoL9/)
But I do want to intercept validations always, no matter if valid or invalid ones.
How can I intercept a validation?
Inventive use of errorsContainer, but it's really not meant to be used this way.
Listen to the events like field:validate instead.
I have just started doing some VXML, and looking to do a simple feature where a DTMF input like zero obtained on any of the forms will lead to a common generalized action. A good example for this is the one we use in our normal interactions with IVR where we press zero to speak to an agent at any time when we are in the IVR.
1) I thought of using throw/catch for this purpose. Is this a good design or is there another VXML feature that best suited for an action like this?
<choice dtmf="0" event="zeroEntered"/>
</choice>
My root document would have:
<catch event="ZeroEntered">
---Do something
</catch>
2) If throw/catch is the way to go, I see its not possible to get that dtmf zero on all the VXML pages. Because elements are not present on all the VXML pages I have...Is there another way? Or I should explicitly include menu in all the pages to catch dtmf zero at any during the call?
What you are referring to are often called universal or global grammars. You can implement them using the link element. You can set the scope for this grammar at the application, document or form level. For more on universal grammars look at this article. And you can find more about the link element here.
CakePHP has a global function called h. It's a convenience method for htmlspecialchars. CakePHP also has a utility called Sanitize, which has a method called html. Here is part of its description:
This method prepares user-submitted data for display inside HTML. This
is especially useful if you don’t want users to be able to break your
layouts or insert images or scripts inside of your HTML pages.
When should each be used? Is one better than the other?
Sanitize::html() is more versatile: it lets you strip the HTML completely (via remove option), and lets you specify the how it handles quoting.
See the source code:
h(): http://api.cakephp.org/2.3/source-function-h.html#160-199
Sanitize::html(): http://api.cakephp.org/2.3/source-class-Sanitize.html#83-122
EDIT:
h(): calls htmlspecialchars()
Sanitize::html(): calls htmlentities()
For discussion on differences, see: htmlentities() vs. htmlspecialchars()