Questions tagged [syntax]

Syntax refers to the actual language elements and symbols themselves. Questions should be tagged as syntax when the question specifically and almost completely relates to syntax alone. This tag should be used with a specific language tag

Definition

In computer science, the syntax of a programming language is the set of rules that define the combinations of symbols that are considered to be correctly structured programs in that language. The syntax of a language defines its surface form. Text-based programming languages are based on sequences of characters, while visual programming languages are based on the spatial layout and connections between symbols (which may be textual or graphical).

The lexical grammar of a textual language specifies how characters must be chunked into tokens. Other syntax rules specify the permissible sequences of these tokens and the process of assigning meaning to these token sequences is part of semantics.

The syntactic analysis of source code usually entails the transformation of the linear sequence of tokens into a hierarchical syntax tree (abstract syntax trees are one convenient form of syntax tree). This process is called parsing, as it is in syntactic analysis in linguistics. Tools have been written that automatically generate parsers from a specification of a language grammar written in Backus-Naur form, e.g., Yacc (yet another compiler compiler).

Source: Syntax (Programming Languages) - Wikipedia

Usage

On StackOverflow, questions should be tagged as syntax when the question specifically and almost completely relates to syntax alone. Additionally, a tag should be added corresponding to the language that is being used, as the syntax only makes sense in the context of the language. Adding the correct language tag will ensure that the question will reach an audience capable of answering it.

21432 questions
13
votes
7 answers

Putting PHP code in a string

How do I put PHP Code into a string? $phpCode = ''; For some reason, when I do this and echo out the code, I don't get the opening PHP tag,
Chris Bier
  • 14,183
  • 17
  • 67
  • 103
13
votes
2 answers

Why is the 'Use of "shift" without parentheses is ambiguous' warning issued by Perl?

Does anyone know what parsing or precedence decisions resulted in the warning 'Use of "shift" without parentheses is ambiguous' being issued for code like: shift . 'some string'; # and not (shift) . 'some string'; # or shift() . 'some string'; Is…
Eric Strom
  • 39,821
  • 2
  • 80
  • 152
13
votes
5 answers

Case insensitive comparison in Bash

I'm trying to write a comparison in a while statement that's case insensitive. Basically, I'm simply trying to shorten the following to act on a yes or no question prompt to the user ... while[ $yn == "y" | $yn == "Y" | $yn == "Yes" | $yn == "yes"…
user2150250
  • 4,797
  • 11
  • 36
  • 44
13
votes
2 answers

Unknown GW-BASIC function/syntax: Q(var) = var

I'm translating an excessively old GW-BASIC program into JavaScript, and I've come across a piece of syntax that has me stumped. Note (again): totally not my code, and the variable names are all insane, which is why I'm porting it in the first…
b. e. hollenbeck
  • 6,493
  • 7
  • 32
  • 47
13
votes
2 answers

Origin of "://" in many URI syntaxes

Anybody knows where the "://" or the "//" comes from in most URIs syntaxes? For instance, why isn't it written like "http:www.example.com"?
pmezard
  • 427
  • 3
  • 11
13
votes
2 answers

How add PHP 5.4 syntax support to Aptana Studio 3?

When using the syntax features PHP 5.4 (eg [] instead of array ()) in the Aptana's code editor I get a syntax error. Is there a way to add support for PHP 5.4?
DroneZzZko
  • 496
  • 4
  • 10
13
votes
3 answers

Is there a difference between the fn and # syntax for anonymous functions in Clojure?

I'm new to clojure, and I've seen anonymous functions written like: (fn [x] (* x x)) and also like: #(* % %) Obviously, the second is more concise. Is there any relevant difference? Can every anonymous function be represented in either style? Is…
Eric Wilson
  • 57,719
  • 77
  • 200
  • 270
13
votes
9 answers

SQL: Insert all records from one table to another table without specific the columns

I want to insert all the record from the back up table foo_bk into foo table without specific the columns. if i try this query INSERT INTO foo SELECT * FROM foo_bk i'll get error "Insert Error: Column name or number of supplied values does not…
Jack
  • 9,843
  • 23
  • 78
  • 111
13
votes
3 answers

Java - quick way of assigning array values to individual variables

I have a method which will return two strings in an array, split(str, ":", 2) to be precise. Is there a quicker way in java to assign the two values in the array to string variables than String[] strings = str.split(":", 2); String string1 =…
Michael
  • 5,994
  • 7
  • 44
  • 56
13
votes
1 answer

Is Boost using legal C++ preprocessing directive syntax?

My (relatively old) C++ compiler choked on this file in Boost, which starts out as: # /* Copyright (C) 2001 # * Housemarque Oy # * http://www.housemarque.com # * # * Distributed under the Boost Software License, Version 1.0. (See # *…
user541686
  • 205,094
  • 128
  • 528
  • 886
13
votes
4 answers

Square braces not required in list comprehensions when used in a function

I submitted a pull request with this code: my_sum = sum([x for x in range(10)]) One of the reviewers suggested this instead: my_sum = sum(x for x in range(10)) (the difference is just that the square braces are missing). I was surprised that the…
Matt Fenwick
  • 48,199
  • 22
  • 128
  • 192
13
votes
4 answers

Methods inside namespace c#

Is there any way to call a function that is inside of a namespace without declaring the class inside c#. For Example, if I had 2 methods that are the exact same and should be used in all of my C# projects, is there any way to just take those…
rkrishnan2012
  • 368
  • 1
  • 2
  • 13
13
votes
2 answers

SQL Server: What does 1 ++ 2 mean?

SQL Server's T-SQL syntax seems to allow multiple plus signs in succession: SELECT 1 + 2 --3 SELECT 1 ++ 2 --3 SELECT 1 ++++++ 2 --3 SELECT 1 + '2' --3 SELECT 1 ++ '2' --3 SELECT '1' + '2' --'12' SELECT '1' ++ '2' --'12' Multiple pluses seem to…
usr
  • 168,620
  • 35
  • 240
  • 369
13
votes
3 answers

Groovy vs. Java syntax discrepancy

In Java I can do this: return a && b && c; In Groovy, it returns a compile error: unexpected token: &&. It also occurs if I omit the return keyword in Groovy. However if I wrap the statement in parentheses, it works fine. In all the Groovy…
Travis Webb
  • 14,688
  • 7
  • 55
  • 109
13
votes
1 answer

Cant get symbolic link to work (windows 7) cmd

Am trying to create a symbolic hard link so that I can move chrome's cache to another harddrive, I have been trying to get it to work, but every variation I have tried has come back from the command line that my syntax is incorrect. From what ive…
VK27
  • 515
  • 2
  • 9
  • 19
1 2 3
99
100