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
3 answers

Difference between decorator classes and decorator functions

I guess that's how they are called, but I will give examples just in case. Decorator class: class decorator(object): def __init__(self, func): self.func = func def __call__(self, *args, **kwargs): print 'something' …
Juliusz Gonera
  • 4,658
  • 5
  • 32
  • 35
13
votes
5 answers

What does the bash command "rm *~" do?

Does the bash command rm *~ just remove files ending in tilde or is there a more advanced bash or gnu make pattern here? Google does not seem able to search for this two symbol combination. I found this in a Makefile clean: target. Would gnu…
Mike
  • 2,637
  • 5
  • 29
  • 40
13
votes
2 answers

Unexpected token }

I have a script to open a model window.. Chrome gives me "Uncaught SyntaxError: Unexpected token }" on a line that doesn't even have a closing curly brace. Here is the portion of the script that has the error: function showm(id1){ …
Tanner Ottinger
  • 2,970
  • 4
  • 22
  • 28
13
votes
3 answers

How can I use a wildcard in uBlock Origin?

How can I use a wildcard in uBlock Origin? I've tried to figure out how to do it, but I'm a little bit confused. I just want to simplify all of these rules into one rule: www.dailymail.co.uk###js-article-text > div:nth-of-type(2) >…
grgoelyk
  • 397
  • 1
  • 3
  • 12
13
votes
5 answers

Ruby operator method calls vs. normal method calls

I'm wondering why calls to operator methods don't require a dot? Or rather, why can't normal methods be called without a dot? Example class Foo def +(object) puts "this will work" end def plus(object) puts "this won't" end end f =…
mpd
  • 2,223
  • 1
  • 19
  • 23
13
votes
3 answers

UPDATE based on if value exist in another table

I have two tables Table A Number 111 222 333 444 Table B Number Another 111 AAA 222 BBB 666 CCC 777 DDD What I am would like to do, is apply an UPDATE statement conditional on whether the…
user3580480
  • 442
  • 7
  • 14
  • 45
13
votes
3 answers

Converting IO Int to Int

I've created a combobox from converting a xmlWidget to a comboBox with the function castTocomboBox and now I want to get the text or the index of the active item. The problem is that if I use the comboBoxGetActive function it returns an IO Int…
izayoi
  • 405
  • 1
  • 4
  • 9
13
votes
6 answers

Iterating over all unsigned integers in a for loop

Let's say I want to iterate over all integers in a for loop. For the sake of discussion, assume I am calling some unknown function f(unsigned x) for each integer: for (unsigned i = 0; i < UINT_MAX; i++) { f(i); } Of course, the above fails to…
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
13
votes
2 answers

Swift 'open' keyword & overridable method/properties in extension?

With introduction of open keyword in Swift 3.0 (What is the 'open' keyword in Swift?). Note: Limited to extensions on NSObject derived classes or @objc attributed method/properties. Code which declared and used public (class) methods/properties in…
Nocross
  • 251
  • 1
  • 4
  • 6
13
votes
3 answers

What is the "()" type in Rust?

As a simple exercise to learn Rust, I've decided to implement a simple binary search: pub fn binary_search(arr: &[i32], key: i32) -> usize { let min: usize = 0; let max: usize = arr.len(); while max >= min { let mid: usize = (max…
revington
  • 160
  • 1
  • 8
13
votes
1 answer

Pandoc, Markdown to Doc, how to use variables?

AFAIK, variables can be defined in a YAML external file or inside the Markdown file in a header. Then they can be used in the document. I have found examples with two different sytaxes: $variable$ will convert variable to math mode, which is great…
Trylks
  • 1,458
  • 2
  • 18
  • 31
13
votes
6 answers

How to use C# constant at ASP.Net page?

The examples given below could make little sense, but it is because I am focusing on syntax. Let's say I have such C# code: public static class Foo { public const string Bar = "hello world."; } Now, I would like to use Foo.Bar constant in ASP.Net…
greenoldman
  • 16,895
  • 26
  • 119
  • 185
13
votes
1 answer

How do I check the equality of three values elegantly?

Say I have values a, b and c. I want to find out if they are equal. If I do if a == b == c{...} Then I get a compile error invalid operation: a == b == c (mismatched types bool and TypeOfABandC) This is pretty obvious, because this parses to: (a…
timthelion
  • 2,636
  • 2
  • 21
  • 30
13
votes
4 answers

What's the reason of using ; in F# lists instead of ,?

This might be a strange question but if I want to define a list of integers from: 1, 2, 3, 4, 5, 6, 7, 8, 9 Do I need to do it using the ; character? [ 1; 2; 3; 4; 5; 6; 7; 8; 9 ] instead of?: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] It just seems to me ,…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689