Jump to content

Linear syntax

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by The Transhumanist (talk | contribs) at 05:25, 21 June 2017 (add cat). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Linear syntax is a computer-programming term for an expression that can be parsed from left to right. Linear syntax implies the ability to write code without the use of line-feed or carriage-return characters. Although the use of such characters is recommended for code readability, they are optional, as compilers do not rely on them to parse and compile the code. HTML, C, and SQL code are examples of languages that employ linear syntax; they all rely on commas, semicolons, and parentheses to separate code blocks.

Example

C

Linear example in C:

void main() { printf("Hello world!"); }

Non-linear example in C:

void main() {
    printf("Hello world!");
}

HTML

Linear example in HTML:

<ul><li>Foo</li><li>Bar</li><li>Baz</li></ul>

Non-linear example in HTML:

<ul>
  <li>Foo</li>
  <li>Bar</li>
  <li>Baz</li>
</ul>

SQL

Linear example in SQL:

SELECT name FROM users WHERE lvl > 10 ORDER BY firstname

Non-linear example in SQL:

SELECT name
FROM users
WHERE lvl > 10
ORDER BY firstname