Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Syntax error
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Computer science concept}} {{for|the 2003 Australian film|Syntax Error (film)}} In [[computer science]], a '''syntax error''' is an error in the [[Syntax (programming languages)|syntax]] of a sequence of characters that is intended to be written in a particular [[programming language]]. For [[compiled language]]s, syntax errors are detected at [[compiler|compile-time]]. A program will not compile until all syntax errors are corrected. For [[interpreted language]]s, a syntax error may be detected during [[Run time (program lifecycle phase)|program execution]], and an interpreter's error messages might not differentiate syntax errors from errors of other kinds. There is some disagreement as to just what errors are "syntax errors". For example, some would say that the use of an uninitialized variable's value in Java code is a syntax error, but many others would disagree<ref>[https://stackoverflow.com/questions/8803718/issue-of-syntax-or-semantics/8803765#8803765 Issue of syntax or semantics?]</ref><ref name="uninitialized var" /> and would classify this as a [[Programming language#Static semantics|(static) semantic]] error. In 8-bit [[home computer]]s that used [[BASIC]] interpreter as their primary user interface, the {{mono|SYNTAX ERROR}} [[error message]] became somewhat notorious, as this was the response to any command or user input the interpreter could not parse. A syntax error can occur or take place, when an invalid equation is being typed on a calculator. This can be caused, for instance, by opening brackets without closing them, or less commonly, entering several [[decimal point]]s in one number. In [[Java (programming language)|Java]] the following is a syntactically correct statement: :<syntaxhighlight lang="java">System.out.println("Hello World");</syntaxhighlight> while the following is not: :<pre>System.out.println(Hello World);</pre> The second example would theoretically print the variable <code>Hello World</code> instead of the [[string literal|words]] "Hello World". A variable in Java cannot have a space in between, so the syntactically correct line would be <code>System.out.println(Hello_World)</code>. A compiler will flag a syntax error when given source code that does not meet the requirements of the language's grammar. Type errors (such as an attempt to apply the ++ increment operator to a Boolean variable in Java) and undeclared variable errors are sometimes considered to be syntax errors when they are detected at compile-time. It is common to classify such errors as [[Programming language#Static semantics|(static) semantic]] errors instead.<ref name="uninitialized var">[http://www.dummies.com/how-to/content/semantic-errors-in-java.html Semantic Errors in Java]</ref><ref>{{cite book|last=Aho|first=Alfred V.|author2=Monica S. Lam|author3=Ravi Sethi|author4=Jeffrey D. Ullman|title=Compilers: Principles, Techniques, and Tools|publisher=Addison Wesley|date=2007|edition=2nd|isbn=978-0-321-48681-3|url-access=registration|url=https://archive.org/details/compilers00alfr_0}} Section 4.1.3: Syntax Error Handling, pp.194–195.</ref><ref>{{cite book|last=Louden|first=Kenneth C.|title=Compiler Construction: Principles and Practice|publisher=Brooks/Cole|date=1997|isbn=981-243-694-4}} Exercise 1.3, pp.27–28.</ref> ==Syntax errors on calculators== [[File:Syntax error.JPG|thumb|Syntax error in a scientific calculator]] <!-- This section may need sources so it is not just original research, as well as better wording on what a syntax error is on calculators, or be removed, though it is probably important to cover this type of syntax error.-->A syntax error is one of several types of errors on [[calculator]]s (most commonly found on [[scientific calculator]]s and [[graphing calculator]]s), representing that the [[equation]] that has been input has incorrect syntax of numbers, operations and so on. It can result in various ways, including but not limited to: *An open [[Bracket#usage in mathematics|bracket]] without closing parenthesis (unless missing closing parenthesis is at very end of equation) *Using [[minus sign]] instead of negative symbol (or vice versa), which are distinct on most scientific calculators. Note that while some scientific calculators allow a minus sign to stand in for a negative symbol, the reverse is less common. ==See also== *[[Tag soup]] ==References== {{Reflist}} [[Category:Programming language syntax|Error]] [[Category:Computer errors]] [[Category:Parsing]] [[Category:Programming language theory]] {{compu-prog-stub}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Compu-prog-stub
(
edit
)
Template:For
(
edit
)
Template:Mono
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)