parentheses

Quick, Petty Java Question: Parenthesis around SQLException

try { ... } catch (SQLException sqle) { String theError = (sqle).getSQLState(); ... } What does surrounding sqle with parenthesis do? Anything? Just curious. ...

Ruby block and unparenthesized arguments

I extracted simple example: require 'pp' x = 1..3 pp x.map do |i| {:value => i, :double => (i*2)} end pp x.map { |i| {:value => i, :double => (i*2)} } pp(x.map do |i| {:value => i, :double => (i*2)} end) pp(x.map { |i| {:value => i, :double => (i*2)} }) I am wondering why first pp produces: [1, 2, 3] While all the oders are giving...

Keeping parentheses balanced (Paredit for Vim?)

Emacs has Paredit which actively prevents you from typing unbalanced parentheses (short of C-Q ( to force-insert a literal one, or other craziness). Inserting an open paren also inserts a closing one. Backspacing over a paren either deletes both the opening and closing paren, or neither. There are shortcuts to wrap a bare word in new ...

How do I parenthesize an expression programmatically?

I have an idea for a simple program to make that will help me with operator precedence in languages like C. The most difficult part of this is parenthesizing the expression. For example, I want this: *a.x++ = *b.x++ Converted to this: ((*(((a).(x))++)) = (*(((b).(x))++))) Which I did manually in these steps: *a.x++ = *b...

How to set curly braces'/parentheses'/square brackets'/arithmetic operators' syntax highlight color in VIM?

How do I highlight operators/parentheses/brackets/etc. in VIM? I'm not interested in coloring matching or unmatching parentheses/brackets. I've tried ":hi cBracket/whatnot guifg=something" and ":hi Operator/cOperator guifg=something" but these don't seem to affect anything. ...

Convert TSQL to MS-Access SQL

TSQL (as used in MS SQL Server 2000 and 2005) allows multiple JOIN clauses, one right after the other, no commas or parentheses needed. Try this in Access and it throws a fit: "Syntax error (missing operator) in query expression ... " From what I have been able to gather out in Google-land, Access SQL wants parentheses to group the JOIN...

Changing Paredit Formatting

When using paredit in programming modes such as C, typing ( will insert a space before the paren when I'm trying to call a function, leaving me with: foo () Is there a way to disable the insertion of the space without changing paredit's source? ...

languages with functions that do not need parentheses?

IIRC, vb6 allowed function calls with no (). IIRC, it was allowed whenever the func didn't have a return value, and you could always use func(same, params, here). What other languages allow this? What do you think func with no parentheses should mean? What are the rules for them? Disclaimer: I am designing a language, so if you are a...

How to get rid of unnecessary parentheses in mathematical expression

Hi I was wondering if there is any known way to get rid of unnecessary parentheses in mathematical formula. The reason I am asking this question is that I have to minimize such formula length if((-if(([V].[6432])=0;0;(([V].[6432])-([V].[6445]))*(((([V].[6443]))/1000*([V].[6448]) +(([V].[6443]))*([V].[6449])+([V].[6450]))*(1-([V].[6446])...

Is there an optimal method/algorithm to unecessary extra parens in BOOL or arithmetic operations

I have this, I built it programatically: (( cat1:bobo AND ( ( cat2:jojo ) OR ( cat2:coco ) ) )) For the sake of debugging, I am looking for a good method that would basically reduce it to least amount of parens needed: cat1:bobo AND ( cat2:jojo OR cat2:coco ) I'm on C#, but if you have a good technique you've seen, I will port it...

C# Regular expresson to get parenthesized info

Hi all, I need a regular expression that will match text enclosed in parentheses. The parentheses should be included. Here are some examples. String: "(AB123-16W) DJ2988W61" Should match: "(AB123-16W)" String: "(6541238 Rev. B, PS B1 & PS B2) 62MJ301-29 Rev. NC" Should match: "(6541238 Rev. B, PS B1 & PS B2)" Any ideas? ...

Access a function pointer without parenthesis

I have this code: #include <stdio.h> int getAns(void); int num; int main() { int (*current_ans)(void); current_ans = &getAns; // HERE printf("%d", current_ans()); } int getAns() { return num + 3; } However, is it possible to have something in the // HERE spot that allows the next line to be printf("%d", curre...

Aggrivated unexpected T_ELSE in small PHP function

Hello, I have a very aggrivated unexped T_ELSE on the last else in this function. function QueryPeople($stringQuery, $table, $max, $cmd) { $con = mysqli_connect("localhost","user","password", "host"); if ($cmd == "Option1") { $SearchSQL = "SELECT signature, firstname, birthdate FROM $table WHERE lower(signature) LIKE ?...

Highlighting quoted/backquoted parens

In Emacs is there a way to syntax-highlight the parentheses of quoted and backquoted sexps differently than the parens of other sexps so they stand out? e.g. I want these parens to be a different color than other parens: (foo `(bar (baz)) quux) ^ ^ ...

A text editor that auto-folds parentheses?

I have some big messy SQL procedures that I'm debugging, and they tend to have a lot of heavily nested parentheses: SELECT * FROM (SELECT F1,F2 FROM TABLE1 AS X LEFT JOIN (SELECT F9,F8 FROM (SELECT F13,F14 FROM TABLE4) AS J INNER JOIN TABLE3 ON...) AS B ON X.F1=B.F9) AS X1 I'm looking for an editor that can automatically mark and op...

Count Parenthesis in a file with a Python program?

I Wanna fix a function through it i can count how many times are used the:(,),[,] if the counts of ( are equal to those of ) and if the counts of [ are equal to those of ] then i have valid syntax! my first -dissapointed- try: filename=input("Give a file name:") def parenthesis(filename): try: f=open(filename,'r') exc...

How do i add parens to this rule?

I have a left-recursive rule like the following: EXPRESSION : EXPRESSION BINARYOP EXPRESSION | UNARYOP EXPRESSION | NUMBER; I need to add parens to it but i'm not sure how to make a left parens depend on a matching right parens yet still optional. Can someone show me how? (or am i trying to do entirely too much in lexing, and shoul...

trying to find a file/line for: .(eval):289: warning: don't put space before argument parentheses

So, I get this warning when I'm running my tests in ruby/RoR .(eval):289: warning: don't put space before argument parentheses I've checked every where (but obvoiusly not) and I can't find the origin of this error. The above error just pops up inbetween the unit tests ... Can someone clue me in onto how to find the location of this e...

How do you make parentheses match height when they're split between lines in LaTeX math

Consider the following example \begin{equation} \begin{split} f = & \left( \frac{a}{b} + \right. \\ & \left. c \right) + d \end{split} \end{equation} In the result, the left parenthesis on the first line is very large, because of the fraction inside. In the second line, since there is no fraction, t...

Getting contents of square brackets, avoiding nested brackets

(first time poster, long time visitor via Google) I'm trying to extract the contents of some square brackets, however i'm having a spot of bother. I've got it working for round brackets as seen below, but I can't see how it should be modified to work for square brackets. I would have thought replacing the round for square and vice versa...