Tutorial by Examples

Labeling the alternatives inside a rule starting with the # operator tells ANTLR to generate listener methods for each label corresponding to the alternative. By specifying a label for each alternative in the following rule: // Rule type : int #typeInt | short #typeShort | long ...
Specifying the -gui command line option when running an ANTLR grammar in the test rig will result in a window popping up with a visual representation of the parse tree. For example: Given the following grammar: JSON.g4 /** Taken from "The Definitive ANTLR 4 Reference" by Terence Parr */...
#demo-element { background: @theme-color; color: contrast(@theme-color, black, white, 50%); } @theme-color: red; The above example will set the text color of the element as white if the background-color is dark and vice-versa. This is achieved using the contrast() color operation functi...
The presence of a tsconfig.json file indicates that the current directory is the root of a TypeScript enabled project. Initializing a TypeScript project, or better put tsconfig.json file, can be done through the following command: tsc --init As of TypeScript v2.3.0 and higher this will create t...
Setting a top-level property compileOnSave signals to the IDE to generate all files for a given tsconfig.json upon saving. { "compileOnSave": true, "compilerOptions": { ... }, "exclude": [ ... ] } This feature is available...
Due to the vulnerability caused by CSRF, it is generally considered a good practice to check for an AntiForgeryToken on all HttpPosts unless there is a good reason to not do it (some technical issue with the post, there is another authentication mechanism and/or the post does not mutate state like s...
For a 12hour time format one can use: ^(?:0?[0-9]|1[0-2])[-:][0-5][0-9]\s*[ap]m$ Where (?:0?[0-9]|1[0-2]) is the hour [-:] is the separator, which can be adjusted to fit your need [0-5][0-9] is the minute \s*[ap]m followed any number of whitespace characters, and am or pm If you need th...
Servant is a library for declaring APIs at the type-level and then: write servers (this part of servant can be considered a web framework), obtain client functions (in haskell), generate client functions for other programming languages, generate documentation for your web applications and m...
PresenceOf - Validates that a value is not null or empty string $validator->add('name', new \Phalcon\Validation\Validator\PresenceOf([ 'message' => 'The name is required' ])); Email - Checks if a value has a correct e-mail format $validator->add('email', new \Phalcon\Validation\Va...
In Tcl, a control structure is basically just another command. This is one possible implementation of a do ... while / do ... until control structure. proc do {body keyword expression} { uplevel 1 $body switch $keyword { while {uplevel 1 [list while $expression $body]} u...
if expr1 ?then? body1 elseif expr2 ?then? body2 ... ?else? ?bodyN? exprN is an expression that evaluates to a boolean value. bodyN is a list of commands. set i 5 if {$i < 10} { puts {hello world} } elseif {$i < 70} { puts {enjoy world} } else { puts {goodbye world} } for sta...
In Object oriented programming language, a mixin is a class that contains methods for use by other classes without having to be the parent class of those other classes. How those other classes gain access to the mixin's methods depends on the language. It provides a mechanism for multiple inheritan...
2.1.3 1. Preview Different Devices There is a preview panel at the right of the android studio. In thispanel there is a button with device name with which you are previewing the UI of your app like this . Click on small dropdown indicator of this and a floating panel will appear with all the pr...
VB 14.0 introduces the ability to add comments after implicit line continuation. Dim number = From c As Char 'Comment In "dj58kwd92n4" 'Comment Where Char.IsNumber(c) 'Comment Select c 'Comment
In Emacs, basic search tool (I-Search) allows you to search after or before the location of your cursor. To search for sometext after the location of your cursor (search-forward) hit C-s sometext. If you want to go to the next occurence of sometext, just press C-s again (and so on for the ne...
Set mark in cursor location: C-space or C-@ Kill region (Cut): C-w Copy region to kill ring: M-w or Esc-w Yank (Paste) most recently killed: C-y Yank (Paste) next last killed: M-y or Esc-y Kill killis the command used by Emacs for the deletion of ...
It forces you to explicitly declare all variables. What is the difference between explicitly declaring and implicitly declaring a variable? Explicitly declaring a variable: Dim anInteger As Integer = 1234 Implicitly declaring a variable: 'Did not declare aNumber using Dim aNumber = 1234 C...
Document level It is on by default, but you can have an extra layer of protection by placing Option Explicit On at the top of the code file. The option will apply to the whole document. Project level You can switch it on via the menu in Visual Studio: Project > [Project] Properties > Com...
Use the task dependencies. Depending on how your modules are set up, it may be either ./gradlew dependencies or to see the dependencies of module app use ./gradlew :app:dependencies The example following build.gradle file dependencies { compile 'com.android.support:design:23.2.1' compile...
To create mixins, simply declare lightweight classes that can be used as "behaviours". class Flies { fly() { alert('Is it a bird? Is it a plane?'); } } class Climbs { climb() { alert('My spider-sense is tingling.'); } } class Bulletproof { ...

Page 643 of 1336