-1

In programming language theory semantics, semantic is the field concerned with the rigorous mathematical study of the meaning of programming languages. It does so by evaluating the meaning of syntactically legal strings defined by a specific programming language, showing the computation involved.

According to the definition quoted above, what does "syntactically legal strings" mean?

Laiv
  • 14,283
  • 1
  • 31
  • 69
coding_ninza
  • 117
  • 5
  • 1
    Strings that contain things that are valid syntax in the language in question. There's not much point in considering strings that aren't, as their behaviour is a trivial syntax error. – jonrsharpe Sep 01 '17 at 12:15

2 Answers2

1

Syntax is one layer up from semantics. This concerns that braces and parenthesis must match, keywords and in what constructs they have to be, how expressions should look like, etc.

A syntactically correct string is a string that follows all the syntax rules. Though not necessarily the semantical rules.

ratchet freak
  • 25,706
  • 2
  • 62
  • 97
1

A syntactically legal string would be a text that matches the grammar of the language. A grammar specifies the keywords, operators, and other textual constructs and how they must appear to form expressions and statements, and ultimately programs. As others are saying this includes, for example, putting ; to terminate statements, balancing brackets of various types [, (, {, etc...

The grammar doesn't specify everything about the language, though of course.

A text matching the grammar of the language is still not necessarily a legal program, it still has to pass semantic concerns, for example, you can't use a break; without being in a loop (though such a text would pass the grammar, which is to say it would parse).

Erik Eidt
  • 33,282
  • 5
  • 57
  • 91