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
1 answer

Is there a multiline in SASS?

I couldn't figure out that from SASS documentation. For example I would like to use Compass mixin with 5 parameters: =link-colors(!normal, !hover = false, !active = false, !visited = false, !focus = false) I would like to declare 5 constants with…
Voldy
  • 12,829
  • 8
  • 51
  • 67
13
votes
4 answers

Why the c# compiler requires the break statement in switch construction?

I'm having hard time understanding, why the compiler requires using break statement. It's not possible to miss it since the fall through is now allowed. I see the reason for the break in C or C++, but is it needed here. Why it's not a built-in…
anthares
  • 11,070
  • 4
  • 41
  • 61
13
votes
9 answers

Getting captured group in one line

There is a known "pattern" to get the captured group value or an empty string if no match: match = re.search('regex', 'text') if match: value = match.group(1) else: value = "" or: match = re.search('regex', 'text') value = match.group(1) if…
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
13
votes
4 answers

Why can this kind of statement work in PHP?

$user->Phonenumbers[]->phonenumber = '123 123'; $user->Phonenumbers[]->phonenumber = '456 123'; $user->Phonenumbers[]->phonenumber = '123 777'; I've never seen this kind of syntax EDIT This seems more probably a feature,do you guys know how can I…
ORM
  • 465
  • 1
  • 4
  • 8
13
votes
1 answer

Old Style Oracle Outer Join Syntax - Why locate the (+) on the right side of the equals sign in a Left Outer join?

I always tell new people that an easy way to remember the old-style, Oracle outer-join syntax is that the (+) sign is on opposite side of where you think it should be. Left join: select * from foo, bar where foo.id = bar.id(+) Right join: select…
Matthew Moisen
  • 16,701
  • 27
  • 128
  • 231
13
votes
1 answer

Operators indirectly forbidden (or not?) in defining integer constant expressions (in C)

In standard C (C99/C11) we have the so-called integer constant expressions, which are constant expressions whose operands are all constant integers. The following definition applies: Standard C99, Section 6.6(par.6): An integer constant…
pablo1977
  • 4,281
  • 1
  • 15
  • 41
13
votes
3 answers

What is the @ operator (at sign) in MATLAB?

I have some MATLAB programs that use the @ (at sign) as an operator. What does it mean? Does MATLAB 6.5 support this operator?
Yin Zhu
  • 16,980
  • 13
  • 75
  • 117
13
votes
3 answers

/ipad/i.test() how syntax works?

I am new to /ipad/i.test(navigator.userAgent.toLowerCase()) syntax. I know the results it returns true for ipad and false for remaining browsers. please any body explain /ipad/i what it means and how it works
user2349539
  • 161
  • 1
  • 1
  • 7
13
votes
3 answers

Odd CSS syntax. [class^='icon-'], [class*=' icon-']

I am going through someone else's CSS code at the moment and found something I have not seen before, nor am I able to find anything on W3C schools about these types of selectors. Google also doesn't return anything if I type in "class^=" …
SixfootJames
  • 1,841
  • 5
  • 26
  • 42
13
votes
2 answers

Is there a difference between Enumerable#each and Enumerable#each_entry in Ruby?

The Enumerable documentation does not state explicitly that each is an alias for each_entry, but the description of each_entry matches exactly what I would expect from each. In the examples of both answers new classes are defined, which implement…
Alexander Popov
  • 23,073
  • 19
  • 91
  • 130
13
votes
3 answers

Eclipse (with Pydev) keeps throwing SyntaxError

My code: print "Hello World!" I even tried adding a semicolon behind, but everytime I save and run (as Python run) it says: File "E:\Software\Eclipse\Workspace\Python1\src\main.py", line 1 print "Hello World!"; SyntaxError: invalid syntax I have…
user149135
13
votes
2 answers

What does ".line" mean in smali code syntax? (Android-Smali Code)

Please take a look at this question Decompiled smali code contains things like .line 3 or .line 7. I cannot understand what .line is supposed to be, please elaborate on the usage.
Behzad Gh
  • 325
  • 1
  • 2
  • 10
13
votes
2 answers

What is the advantage of "lambda expressions"?

The reason for lambda expressions is implicitly generate function objects in a "more convenient way". As you can see from the example below, it is not only less convenient and longer, but also has a confusing syntax and notation. Are there any uses…
Oleksiy
  • 37,477
  • 22
  • 74
  • 122
13
votes
6 answers

Why is the usage of "#" comments frequently discouraged in PHP?

As far as I know, there are 3 types of comments recognized by PHP: /* A block comment */ // A single-line comment # Also a single-line comment However, many coding standards, for example, those of PEAR or Kohana, discourage the last type of…
Ignas R
  • 3,314
  • 2
  • 23
  • 27
13
votes
4 answers

No semicolon before [] is causing error in JavaScript

var a = [1, 2, 3, 4]; var b = [10, 20, 30, 40]; console.log([a, b].length) [a, b].some(function(x) { x.push(x.shift()) }); I was extremely surprised today when this code caused [a,b].some(function(x){ x.push(x.shift()) }); …
exebook
  • 32,014
  • 33
  • 141
  • 226