Commands Not Showing in Command Palette with RegReplace (Sublime Text 3) - regex

I'm trying to run a series of commands with the RegReplace plugin in Sublime Text 3 but I cannot get the command to load and I cannot get the keybindings to work either. I have no clue what's wrong.
Steps Taken:
Installed RegReplace
Opened the Command Palette
Searched for "RegReplace: Create New Regular Expression"
Modified the Rule to the following
"""
If you don't need a setting, just leave it as None.
When the rule is parsed, the default will be used.
Each variable is evaluated separately, so you cannot substitute variables in other variables.
"""
# name (str): Rule name. Required.
name = "extract_variables"
# find (str): Regular expression pattern or literal string.
# Use (?i) for case insensitive. Use (?s) for dotall.
# See https://docs.python.org/3.4/library/re.html for more info on regex flags.
# Required unless "scope" is defined.
find = r".*\[(.*[^(<|>)]*?)\].*"
# replace (str - default=r'\g<0>'): Replace pattern.
replace = r"\1"
# literal (bool - default=False): Preform a non-regex, literal search and replace.
literal = None
# literal_ignorecase (bool - default=False): Ignore case when "literal" is true.
literal_ignorecase = None
# scope (str): Scope to search for and to apply optional regex to.
# Required unless "find" is defined.
scope = None
# scope_filter ([str] - default=[]): An array of scope qualifiers for the match.
# Only used when "scope" is not defined.
#
# - Any instance of scope qualifies match: scope.name
# - Entire match of scope qualifies match: !scope.name
# - Any instance of scope disqualifies match: -scope.name
# - Entire match of scope disqualifies match: -!scope.name
scope_filter = None
# greedy (bool - default=True): Apply action to all instances (find all).
# Used when "find" is defined.
greedy = None
# greedy_scope (bool - default=True): Find all the scopes specified by "scope."
greedy_scope = None
# format_replace (bool - default=False): Use format string style replace templates.
# Works only for Regex (with and without Backrefs) and Re (with Backrefs).
# See http://facelessuser.github.io/backrefs/#format-replacements for more info.
format_replace = None
# selection_inputs (bool -default=False): Use selection for inputs into find pattern.
# Global setting "selection_only" must be disabled for this to work.
selection_inputs = None
# multi_pass (bool - default=False): Perform multiple sweeps on the scope region to find
# and replace all instances of the regex when regex cannot be formatted to find
# all instances. Since a replace can change a scope, this can be useful.
multi_pass = None
# plugin (str): Define replace plugin for more advanced replace logic.
plugin = None
# args (dict): Arguments for 'plugin'.
args = None
# ----------------------------------------------------------------------------------------
# test: Here you can setup a test command. This is not saved and is just used for this session.
# - replacements ([str]): A list of regex rules to sequence together.
# - find_only (bool): Highlight current find results and prompt for action.
# - action (str): Apply the given action (fold|unfold|mark|unmark|select).
# This overrides the default replace action.
# - options (dict): optional parameters for actions (see documentation for more info).
# - key (str): Unique name for highlighted region.
# - scope (str - default="invalid"): Scope name to use as the color.
# - style (str - default="outline"): Highlight style (solid|underline|outline).
# - multi_pass (bool): Repeatedly sweep with sequence to find all instances.
# - no_selection (bool): Overrides the "selection_only" setting and forces no selections.
# - regex_full_file_with_selections (bool): Apply regex search to full file then apply
# action to results under selections.
test = {
"replacements": ["extract_variables"],
"find_only": True,
"action": None,
"options": {},
"multi_pass": False,
"no_selection": False,
"regex_full_file_with_selections": False
}
This code Generates the following in AppData\Roaming\Sublime Text 3\Packages\User\reg_replace_rules.sublime-settings
{
"replacements":
{
"extract_variables":
{
"find": ".*\\[(.*[^(<|>)]*?)\\].*",
"name": "extract_variables",
"replace": "\\1"
}
}
}
And then I created the following command under the same directory with filename Default.sublime-commands
[
{
"caption": "Reg Replace: Extract ERS Variables",
"command": "extract_ers_variables",
"args": {
"replacements": [
"extract_variables"
]
}
}
]
After saving all of this, I still do not see the command in the command palette and it didn't show when I tried to save it as a keymap either.
Any help is much appreciated

Came here with my own troubles and may as well document my dumb mistakes. I know nothing of JSON.
When adding two replacements used together going by the examples at the developer's site, I could not get the command to show up in the Command Palette. I could get a keybinding to work, but it gave error messages that the first replacement could not be found…after having successfully used it. The culprit was a malformed reg_replace_rules.sublime-settings file:
//Wrong
{
"replacements":
{
"rep_one":
//stuff
},
"replacements":
{
"rep_two":
//other stuff
}
}
//Correct
{
"replacements":
{
"rep_one":
//stuff, comma
"rep_two":
//other stuff
}
}
Fixing that cleared up the error message, but the command still would not appear in the Command Palette. The problem there was more bad JSON, this time in Default.sublime-commands.
//Wrong
{
"caption": "My Command",
"command": "reg_replace",
"args": {"replacements": ["rep_one", "rep_two"]}
}
//Correct
[
{
"caption": "My Command",
"command": "reg_replace",
"args": {"replacements": ["rep_one", "rep_two"]}
}
]
This is probably obvious to people who have learned JSON properly and use it regularly, and perhaps one day I will be one of those.

The reason this doesn't work for you is that you have the command wrong in your Default.sublime-commands file. In particular, the command extract_ers_variables does not exist, so the entry for it in the command palette is hidden because selecting it wouldn't do anything. Visually speaking, if this command was in a sublime-menu file, the entry in the menu would appear disabled.
If you select Preferences > Package Settings > RegReplace > Quick Start Guide from the menu and follow through the example that's displayed, note that when it comes to the part about creating the command entry in Default.sublime-commands, it tells you to use reg_replace as the command, and the name of the replacements argument is what tells the command which replacement to do.
As such, your entry should look more like:
[
{
"caption": "Reg Replace: Extract ERS Variables",
"command": "reg_replace",
"args": {
"replacements": [
"extract_variables"
]
}
}
]

Related

Extract a regex capturing group with rego

I'm trying to build a rule based file access "engine", that evaluates whether a service is allowed to access a file or not via rego rules/data.
Here's what I have so far
data
{
"bucketname": "randombucket"
"bucketpaths": {
"service1": "/base/path/in/bucket"
}
"rules": {
"service1": {
"GET": ["/storage/service1/(.*)"]
// ^ This is basically a relative path and I'd like to extract it
}
}
}
rego rule
package org.test
import future.keywords.if
import future.keywords.in
default allow := false
default ttl := 60
basePath = data["bucketpaths"][input.ServiceType]
default relativePath := ""
allow if {
allowedPaths := data["rules"][input.ServiceType][input.Method]
some allowedPath in allowedPaths
regex.match(allowedPath, input.Path)
# here I would like to do three things:
# 1) check if the regex matches
# 2) extract the capuring group
# 3) set the value into relativePath
}
fullPath = concat(basePath, relativePath)
bucketName = data["bucketname"]
input
{
"ServiceType": "service1",
"Method": "GET",
"Path": "/storage/service1/a/relative/path"
}
Here's a link to the rego playground: https://play.openpolicyagent.org/p/3p7VAxwTcR
Disclaimer, I'm a noob to opa/rego, so these statements probably don't make any sense to experienced people...
I already tried using regex.find_all_string_submatch_n but I just cannot wrap my head around two things basically
I'm inside of an if statement, which is obviously not meant to set values - but how else would I do it?
How do I "just run a piece of code" to evaluate stuff "somewhere"? To - for example - evaluate the regex and just assign the result

VS Code search and replace and change line order Vuejs

I have this tag occurring in multiple files - same path but with different image files:
<img
id="logo"
style="margin-left:170px;margin-top:8px;width:85px"
class="shrunk"
src="~/static/img/poweredby-grey.png"
alt=" logo"
>
I want to replace the src line everywhere BUT I also need to move the new :src line up in order because the Vue js linter will say the :src needs to be before class and style.
<img
id="logo"
:src="require('~/static/' + imgURL + '/poweredby-grey.png')"
style="margin-left:170px;margin-top:8px;width:85px"
class="shrunk"
alt=" logo"
>
I used regex replace and was able to replace the src line to the correct :src line. Given I have about 100 files to do this how can i do this quickly in VS Code?
My current search and replace regex is:
src="~/static/img/(.+?)"
:src="require('~/static/' + imgURL + '/$1')"
How can I adapt the two regex to search and replace across the whole <img> tag - this way in my replace regex I correct the line order at the same time.
Thanks a lot.
I guess that Multiline search can help you here. You can create group for different properties and then rearrange it. Also Search Editor feature of VS Code in combination with this experimental plugin might help.
However I'd not recommend to use regexp for such transformation, if there is alternative.
The best possible way is to use autofix option of the rule (if it has it). I suspect that it is this rule that gives you an error: attributes-order. In this case you can simply run eslint with --fix flag, and it'll reorder props automatically.
One way to do it that keep your regex's a little simpler is to run two find and replaces in series. Using an extension like Replace Rules you can do this.
In your settings.json:
"replacerules.rules": {
"editImgSrc": {
"find": "src=\"~/static/img/(.*?)\"",
"replace": ":src=\"require('~/static/' + imgURL + '/$1')\""
},
"reorder vueImgSrc": {
// get the src line and the two preceding lines
"find": "((.*\r?\n){2})( *:src=\"require.*\r?\n)",
"replace": "$3$1" // reorder them
},
},
"replacerules.rulesets": { // bundle the 2 find/replaces into one ruleset
"Replace with vueImgSrc and reorder": {
"rules": [
"editImgSrc",
"reorder vueImgSrc"
]
}
},
and then a keybinding to run that (in keybindings.json):
{
"key": "alt+w", // whatever keybinding you want
"command": "replacerules.runRuleset",
"when": "editorTextFocus && !editorReadonly",
"args": {
"rulesetName": "Replace with vueImgSrc and reorder"
}
},

Nifi - Extracting Key Value pairs into new fields

With Nifi I am trying to use the ReplaceText processor to extract key value pairs.
The relevant part of the JSON file is the 'RuleName':
"winlog": {
"channel": "Microsoft-Windows-Sysmon/Operational",
"event_id": 3,
"api": "wineventlog",
"process": {
"pid": 1640,
"thread": {
"id": 4452
}
},
"version": 5,
"record_id": 521564887,
"computer_name": "SERVER001",
"event_data": {
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
},
"provider_guid": "{5790385F-C22A-43E0-BF4C-06F5698FFBD9}",
"opcode": "Info",
"provider_name": "Microsoft-Windows-Sysmon",
"task": "Network connection detected (rule: NetworkConnect)",
"user": {
"identifier": "S-1-5-18",
"name": "SYSTEM",
"domain": "NT AUTHORITY",
"type": "Well Known Group"
}
},
Within the ReplaceText processor I have this configuration
ReplaceText
"winlog.event_data.RuleName":"MitreRef=(.*),Technique=(.*),Tactic=(.*),Alert=(.*)"
"MitreRef":"$1","Technique":"$2","Tactic":"$3","Alert":"$4"
The first problem is that the new fields MitreRef etc. are not created.
The second thing is that the fields may appear in any order in the original JSON, e.g.
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
or,
MitreRef=1043,Tactic=Command and Control,Technique=Commonly Used Port
Any ideas on how to proceed?
Welcome to StackOverflow!
As your question is quite ambiqious I'll try to guess what you aimed for.
Replacing string value of "RuleName" with JSON representation
I assume that you want to replace the entry
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
with something along the lines of
"RuleName": {
"Technique": "Commonly Used Port",
"Tactic": "Command and Control",
"MitreRef": "1043"
}
In this case you can grab basically the whole line and assume you have three groups of characters, each consisting of
A number of characters that are not the equals sign: ([^=]+)
The equals sign =
A number of characters that are not the comma sign: ([^,]+)
These groups in turn are separated by a comma: ,
Based on these assumptions you can write the following RegEx inside the Search Value property of the ReplaceText processor:
"RuleName"\s*:\s*"([^=]+)=([^,]+),([^=]+)=([^,]+),([^=]+)=([^,]+)"
With this, you grab the whole line and build a group for every important data point.
Based on the groups you may set the Replacement Value to:
"RuleName": {
"${'$1'}": "${'$2'}",
"${'$3'}": "${'$4'}",
"${'$5'}": "${'$6'}"
}
Resulting in the above mentioned JSON object.
Some remarks
The RegEx assumes that the entry is on a single line and does NOT work when it is splitted onto multiple lines, e.g.
"RuleName":
"Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
The RegEx assumes the are exactly three "items" inside the value of RuleName and does NOT work with different number of "items".
In case your JSON file can grow larger you may try to avoid using the Entire text evaluation mode, as this loads the content into a buffer and routes the FlowFile to the failure output in case the file is to large. In that case I recommend you to use the Line-by-Line mode as seen in the attached image.
Allowing a fourth additional value
In case there might be a fourth additional value, you may adjust the RegEx in the Search Value property.
You can add (,([^=]+)=([^,]+))? to the previous expression, which roughly translated to:
( )? - match what is in the bracket zero or one times
, - match the character comma
([^=]+)=([^,]+) - followed by the group of characters as explaind above
The whole RegEx will look like this:
"RuleName"\s*:\s*"([^=]+)=([^,]+),([^=]+)=([^,]+),([^=]+)=([^,]+)(,([^=]+)=([^,]+))?"
To allow the new value to be used you have to adjust the replacement value as well.
You can use the Expression Language available in most NiFi processor properties to decide whether to add another item to the JSON object or not.
${'$7':isEmpty():ifElse(
'',
${literal(', "'):append(${'$8'}):append('": '):append('"'):append(${'$9'}):append('"')}
)}
This expression will look if the seventh RegEx group exists or not and either append an empty string or the found values.
With this modification included the whole replacement value will look like the following:
"RuleName": {
"${'$1'}": "${'$2'}",
"${'$3'}": "${'$4'}",
"${'$5'}": "${'$6'}"
${'$7':isEmpty():ifElse(
'',
${literal(', "'):append(${'$8'}):append('": '):append('"'):append(${'$9'}):append('"')}
)}
}
regarding multiple occurrences
The ReplaceText processor replaces all occurrences it finds where the RegEx matches. Using the settings provided in the last paragraph given the following example input
{
"event_data": {
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043,Foo=Bar"
},
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
}
will result in the following:
{
"event_data": {
"RuleName": {
"Technique": "Commonly Used Port",
"Tactic": "Command and Control",
"MitreRef": "1043",
"Foo": "Bar"
}
},
"RuleName": {
"Technique": "Commonly Used Port",
"Tactic": "Command and Control",
"MitreRef": "1043"
}
}
example template
You may download a template I created that includes the above processor from gist.

Extending Calcite parser to Adding Custom relational operators

I want to support FOO_GREATER_THAN clause instead of > in my sql parser.
For ex:
select * from people where age FOO_GREATER_THAN 10
I followed https://calcite.apache.org/docs/adapter.html#extending-the-parser and I have added custom fmpp and ftl file, but I am not able to add it.
parserImpls.ftl
SqlKind regRealtionalOperator() :
SqlKind regRealtionalOperator() :
{
}
{
<FOO_EQUAL> { return SqlKind.EQUALS; }
|
<FOO_GREATER_THAN> { return SqlKind.NOT_EQUALS; }
}
config.fmpp
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is an FMPP (http://fmpp.sourceforge.net/) configuration file to
# allow clients to extend Calcite's SQL parser to support application specific
# SQL statements, literals or data types.
#
# Calcite's parser grammar file (Parser.jj) is written in javacc
# (http://javacc.java.net/) with Freemarker (http://freemarker.org/) variables
# to allow clients to:
# 1. have custom parser implementation class and package name.
# 2. insert new parser method implementations written in javacc to parse
# custom:
# a) SQL statements.
# b) literals.
# c) data types.
# 3. add new keywords to support custom SQL constructs added as part of (2).
# 4. add import statements needed by inserted custom parser implementations.
#
# Parser template file (Parser.jj) along with this file are packaged as
# part of the calcite-core-<version>.jar under "codegen" directory.
data: {
parser: {
# Generated parser implementation package and class name.
package: "org.apache.calcite.sql.parser.impl",
class: "SqlParserImpl",
# List of additional classes and packages to import.
# Example. "org.apache.calcite.sql.*", "java.util.List".
imports: [
]
# List of new keywords. Example: "DATABASES", "TABLES". If the keyword is not a reserved
# keyword add it to 'nonReservedKeywords' section.
keywords: [
"FOO_EQUAL"
"FOO_GREATER_THAN"
]
# List of keywords from "keywords" section that are not reserved.
nonReservedKeywords: [
"A"
"ABSENT"
"ABSOLUTE"
"ACTION"
"ADA"
"ADD"
"ADMIN"
"AFTER"
"ALWAYS"
"APPLY"
"ASC"
"ASSERTION"
"ASSIGNMENT"
"ATTRIBUTE"
"ATTRIBUTES"
"BEFORE"
"BERNOULLI"
"BREADTH"
"C"
"CASCADE"
"CATALOG"
"CATALOG_NAME"
"CENTURY"
"CHAIN"
"CHARACTER_SET_CATALOG"
"CHARACTER_SET_NAME"
"CHARACTER_SET_SCHEMA"
"CHARACTERISTICS"
"CHARACTERS"
"CLASS_ORIGIN"
"COBOL"
"COLLATION"
"COLLATION_CATALOG"
"COLLATION_NAME"
"COLLATION_SCHEMA"
"COLUMN_NAME"
"COMMAND_FUNCTION"
"COMMAND_FUNCTION_CODE"
"COMMITTED"
"CONDITION_NUMBER"
"CONDITIONAL"
"CONNECTION"
"CONNECTION_NAME"
"CONSTRAINT_CATALOG"
"CONSTRAINT_NAME"
"CONSTRAINT_SCHEMA"
"CONSTRAINTS"
"CONSTRUCTOR"
"CONTINUE"
"CURSOR_NAME"
"DATA"
"DATABASE"
"DATETIME_INTERVAL_CODE"
"DATETIME_INTERVAL_PRECISION"
"DECADE"
"DEFAULTS"
"DEFERRABLE"
"DEFERRED"
"DEFINED"
"DEFINER"
"DEGREE"
"DEPTH"
"DERIVED"
"DESC"
"DESCRIPTION"
"DESCRIPTOR"
"DIAGNOSTICS"
"DISPATCH"
"DOMAIN"
"DOW"
"DOY"
"DYNAMIC_FUNCTION"
"DYNAMIC_FUNCTION_CODE"
"ENCODING"
"EPOCH"
"ERROR"
"EXCEPTION"
"EXCLUDE"
"EXCLUDING"
"FINAL"
"FIRST"
"FOLLOWING"
"FORMAT"
"FORTRAN"
"FOUND"
"FRAC_SECOND"
"G"
"GENERAL"
"GENERATED"
"GEOMETRY"
"GO"
"GOTO"
"GRANTED"
"HIERARCHY"
"IGNORE"
"IMMEDIATE"
"IMMEDIATELY"
"IMPLEMENTATION"
"INCLUDING"
"INCREMENT"
"INITIALLY"
"INPUT"
"INSTANCE"
"INSTANTIABLE"
"INVOKER"
"ISODOW"
"ISOYEAR"
"ISOLATION"
"JAVA"
"JSON"
"K"
"KEY"
"KEY_MEMBER"
"KEY_TYPE"
"LABEL"
"LAST"
"LENGTH"
"LEVEL"
"LIBRARY"
"LOCATOR"
"M"
"MAP"
"MATCHED"
"MAXVALUE"
"MICROSECOND"
"MESSAGE_LENGTH"
"MESSAGE_OCTET_LENGTH"
"MESSAGE_TEXT"
"MILLISECOND"
"MILLENNIUM"
"MINVALUE"
"MORE_"
"MUMPS"
"NAME"
"NAMES"
"NANOSECOND"
"NESTING"
"NORMALIZED"
"NULLABLE"
"NULLS"
"NUMBER"
"OBJECT"
"OCTETS"
"OPTION"
"OPTIONS"
"ORDERING"
"ORDINALITY"
"OTHERS"
"OUTPUT"
"OVERRIDING"
"PAD"
"PARAMETER_MODE"
"PARAMETER_NAME"
"PARAMETER_ORDINAL_POSITION"
"PARAMETER_SPECIFIC_CATALOG"
"PARAMETER_SPECIFIC_NAME"
"PARAMETER_SPECIFIC_SCHEMA"
"PARTIAL"
"PASCAL"
"PASSING"
"PASSTHROUGH"
"PAST"
"PATH"
"PLACING"
"PLAN"
"PLI"
"PRECEDING"
"PRESERVE"
"PRIOR"
"PRIVILEGES"
"PUBLIC"
"QUARTER"
"READ"
"RELATIVE"
"REPEATABLE"
"REPLACE"
"RESPECT"
"RESTART"
"RESTRICT"
"RETURNED_CARDINALITY"
"RETURNED_LENGTH"
"RETURNED_OCTET_LENGTH"
"RETURNED_SQLSTATE"
"RETURNING"
"ROLE"
"ROUTINE"
"ROUTINE_CATALOG"
"ROUTINE_NAME"
"ROUTINE_SCHEMA"
"ROW_COUNT"
"SCALAR"
"SCALE"
"SCHEMA"
"SCHEMA_NAME"
"SCOPE_CATALOGS"
"SCOPE_NAME"
"SCOPE_SCHEMA"
"SECTION"
"SECURITY"
"SELF"
"SEQUENCE"
"SERIALIZABLE"
"SERVER"
"SERVER_NAME"
"SESSION"
"SETS"
"SIMPLE"
"SIZE"
"SOURCE"
"SPACE"
"SPECIFIC_NAME"
"SQL_BIGINT"
"SQL_BINARY"
"SQL_BIT"
"SQL_BLOB"
"SQL_BOOLEAN"
"SQL_CHAR"
"SQL_CLOB"
"SQL_DATE"
"SQL_DECIMAL"
"SQL_DOUBLE"
"SQL_FLOAT"
"SQL_INTEGER"
"SQL_INTERVAL_DAY"
"SQL_INTERVAL_DAY_TO_HOUR"
"SQL_INTERVAL_DAY_TO_MINUTE"
"SQL_INTERVAL_DAY_TO_SECOND"
"SQL_INTERVAL_HOUR"
"SQL_INTERVAL_HOUR_TO_MINUTE"
"SQL_INTERVAL_HOUR_TO_SECOND"
"SQL_INTERVAL_MINUTE"
"SQL_INTERVAL_MINUTE_TO_SECOND"
"SQL_INTERVAL_MONTH"
"SQL_INTERVAL_SECOND"
"SQL_INTERVAL_YEAR"
"SQL_INTERVAL_YEAR_TO_MONTH"
"SQL_LONGVARBINARY"
"SQL_LONGVARNCHAR"
"SQL_LONGVARCHAR"
"SQL_NCHAR"
"SQL_NCLOB"
"SQL_NUMERIC"
"SQL_NVARCHAR"
"SQL_REAL"
"SQL_SMALLINT"
"SQL_TIME"
"SQL_TIMESTAMP"
"SQL_TINYINT"
"SQL_TSI_DAY"
"SQL_TSI_FRAC_SECOND"
"SQL_TSI_HOUR"
"SQL_TSI_MICROSECOND"
"SQL_TSI_MINUTE"
"SQL_TSI_MONTH"
"SQL_TSI_QUARTER"
"SQL_TSI_SECOND"
"SQL_TSI_WEEK"
"SQL_TSI_YEAR"
"SQL_VARBINARY"
"SQL_VARCHAR"
"STATE"
"STATEMENT"
"STRUCTURE"
"STYLE"
"SUBCLASS_ORIGIN"
"SUBSTITUTE"
"TABLE_NAME"
"TEMPORARY"
"TIES"
"TIMESTAMPADD"
"TIMESTAMPDIFF"
"TOP_LEVEL_COUNT"
"TRANSACTION"
"TRANSACTIONS_ACTIVE"
"TRANSACTIONS_COMMITTED"
"TRANSACTIONS_ROLLED_BACK"
"TRANSFORM"
"TRANSFORMS"
"TRIGGER_CATALOG"
"TRIGGER_NAME"
"TRIGGER_SCHEMA"
"TYPE"
"UNBOUNDED"
"UNCOMMITTED"
"UNCONDITIONAL"
"UNDER"
"UNNAMED"
"USAGE"
"USER_DEFINED_TYPE_CATALOG"
"USER_DEFINED_TYPE_CODE"
"USER_DEFINED_TYPE_NAME"
"USER_DEFINED_TYPE_SCHEMA"
"UTF8"
"UTF16"
"UTF32"
"VERSION"
"VIEW"
"WEEK"
"WRAPPER"
"WORK"
"WRITE"
"XML"
"ZONE"
]
# List of additional join types. Each is a method with no arguments.
# Example: LeftSemiJoin()
joinTypes: [
]
# List of methods for parsing custom SQL statements.
# Return type of method implementation should be 'SqlNode'.
# Example: SqlShowDatabases(), SqlShowTables().
statementParserMethods: [
]
# List of methods for parsing custom literals.
# Return type of method implementation should be "SqlNode".
# Example: ParseJsonLiteral().
literalParserMethods: [
]
# List of methods for parsing custom data types.
# Return type of method implementation should be "SqlIdentifier".
# Example: SqlParseTimeStampZ().
dataTypeParserMethods: [
]
# List of methods for parsing extensions to "ALTER <scope>" calls.
# Each must accept arguments "(SqlParserPos pos, String scope)".
# Example: "SqlUploadJarNode"
alterStatementParserMethods: [
]
# List of methods for parsing extensions to "CREATE [OR REPLACE]" calls.
# Each must accept arguments "(SqlParserPos pos, boolean replace)".
createStatementParserMethods: [
]
# List of methods for parsing extensions to "DROP" calls.
# Each must accept arguments "(SqlParserPos pos)".
dropStatementParserMethods: [
]
# List of files in #includes directory that have parser method
# implementations for parsing custom SQL statements, literals or types
# given as part of "statementParserMethods", "literalParserMethods" or
# "dataTypeParserMethods".
implementationFiles: [
"parserImpls.ftl"
]
includeCompoundIdentifier: true
includeBraces: true
includeAdditionalDeclarations: false
}
}
freemarkerLinks: {
includes: includes/
}
I am able to see the method regRealtionalOperator present in generated SqlParseImp class in javacc package of the target directory. Also in fmpp of generate-source, the generated Parser.jj also contains by the method.
Still, upon running the above query, SqlPArseException [ Encountered FOO_GREATER_THAN error is being thrown.
You've added it as a keyword, but you still need to indicate where this operator can be used in a query. For example, in Parser.jj, you'll see the comp() production which is used wherever a comparison operator is required. Based on where your operator is valid in a query, you'll have to decide how to modify the grammar.

How to set SublimeText to auto match brackets but neither quotes or parenthesis?

I find the auto match behavior in sublime text 3 is not quite up to snuff when you're typing code and more importantly when you're going back to edit in real time it can add all kinds of parens or quotes you don't really need.
But it's pretty much always perfect at auto matching squirly brackets {} so that's still a very useful feature especially since I type a lot of them in a local markup language.
I know I can turn auto match off but I don't want to turn off the behavior entirely, just modify it to not auto match "" or ().
Does anyone know the command to put in the user settings for this?
Here's the steps I've done to try to resolve this:
find ~/ -name "Sublime Text"
find ~/ -name "BracketHighlighter"
Both return nothing. So I can't find this 'BracketHighlighter.sublime-settings'
Instead of looking for it on the hard drive, I accessed it via the built in menus in Sublime Text via:
Preferences ->
Package Settings ->
Bracket Highlighter ->
Bracket Settings - User
This last menu option opens a file called "~/.config/sublime-text-3/Packages/User/bh_core.sublime-settings. In there I've pasted the code from AGS' answer and toggled:
"auto_match_enabled" : true,
"auto_match_enabled" : false,
I have tried both auto match settings while the code has been saved to the bh_core.sublime-settings file. Neither option produces the result as expected. With auto match on, braces, brackets, and quotes are matched. With auto match off, nothing is matched. But I have confirmed the module is on and active as brackets are getting highlighted when selected.
I know I can turn auto match off but I don't want to turn off the behavior entirely, just modify it to not auto match "" or ()
You could install and customize the settings of the BracketHighlighter package.
Disable the system auto-matching:
~/Library/Application Support/Sublime Text 2/Packages/User/Preferences.sublime-settings
"auto_match_enabled": true,
Then edit:
OS X file location:
~/Library/Application Support/Sublime Text 2/Packages/User/BracketHighlighter.sublime-settings
{
"name": "round",
"open": "(\\()",
"close": "(\\))",
"style": "round",
"scope_exclude_exceptions": ["string.other.math.block.environment.latex"],
"scope_exclude": ["string", "comment"],
"language_filter": "blacklist",
"language_list": ["Plain text"],
"find_in_sub_search": "true",
"ignore_string_escape": true,
"enabled": true
},
{
"name": "double_quote",
"open": "(\")",
"close": "(\")",
"style": "double_quote",
"scopes": ["string"],
"language_filter": "blacklist",
"language_list": ["Plain text"],
"sub_bracket_search": "true",
"enabled": true
},