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
Statement (computer science)
(section)
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!
==Syntax== {{main|Syntax (programming languages)}} Apart from assignments and subroutine calls, most languages start each statement with a special word (e.g. goto, if, while, etc.) as shown in the above examples. Various methods have been used to describe the form of statements in different languages; the more formal methods tend to be more precise: * Algol 60 used [[Backus–Naur form]] (BNF) which set a new level for language grammar specification.<ref name=ALGOL60RPT>{{cite web|url=http://www.masswerk.at/algol60/report.htm |at=Section "1.1" |title=Revised Report on the Algorithmic Language Algol 60 |first1=J.W. |last1=Backus |first2=F.L. |last2=Bauer |first3=J. |last3=Green |first4=C. |last4=Katz |first5=J. |last5=McCarthy |first6=P. |last6=Naur |first7=A.J. |last7=Perlis |first8=H. |last8=Rutishauser |first9=K. |last9=Samuelson |first10=B. |last10=Vauquois |first11=J.H. |last11=Wegstein |first12=A. |last12=van Wijngaarden |first13=M. |last13=Woodger |editor-first1= Peter |editor-last1=Naur |website=mass:werk |access-date=January 23, 2021}}</ref> * Up until Fortran 77, the language was described in English prose with examples,<ref name=FORTRAN66>{{cite web|url=https://wg5-fortran.org/ARCHIVE/Fortran66.pdf|title=FORTRAN |date=1966 |publisher=United States of America Standards Institute |via=WG5 Fortran Standards |access-date=February 19, 2021}}</ref> From Fortran 90 onwards, the language was described using a variant of BNF.<ref name=FORTRAN95>{{cite web|url=https://j3-fortran.org/doc/year/04/04-007.pdf|title=Working draft J3/04-007 |date=May 10, 2004 |publisher=J3 Fortran |access-date=February 19, 2021}}</ref> * Cobol used a two-dimensional metalanguage.<ref name=COBOL1959>{{cite web|url=https://public.support.unisys.com/2200/docs/CP18.0/PDF/78307709-002.pdf|title=ASCII COBOL Programming Reference Manual |date= June 2010 |publisher=unisys |access-date=January 23, 2021}}</ref> * Pascal used both [[syntax diagram]]s and equivalent BNF.<ref name=PASCAL>{{cite web|url=http://prog.vub.ac.be/~tjdhondt/ESL/Pascal_files/PASCAL%20user%20manual%20and%20report.pdf|title=PASCAL User Manual and Report |first1=Kathleen |last1=Jensen |first2=Niklaus |last2=Wirth |editor-first1=G. |editor-last1=Goos |editor-first2=J. |editor-last2=Hartmanis |date=1974 |work=Lecture Notes in Computer Science |at=Appendix D |access-date=February 19, 2021}}</ref> BNF uses recursion to express repetition, so various [[Extended Backus–Naur form|extensions]] have been proposed to allow direct indication of repetition. ===Statements and keywords=== Some programming language grammars [[reserved word|reserve keywords]] or [[Stropping (syntax)|mark them specially]], and do not allow them to be used as [[Identifier (computer languages)|identifiers]]. This often leads to [[Formal grammar|grammars]] which are easier to [[parsing|parse]], requiring less [[Parsing#Lookahead|lookahead]]. ====No distinguished keywords==== Fortran and PL/1 do not have reserved keywords, allowing statements like: * in PL/1: **<code>IF IF = THEN THEN ...</code> (the second <code>IF</code> and the first <code>THEN</code> are variables). * in Fortran: **<code>IF (A) X = 10... </code> conditional statement (with other variants) **<code>IF (A) = 2 </code> assignment to a subscripted variable named <code>IF</code> ::As spaces were optional up to Fortran 95, a typo could completely change the meaning of a statement: :*<code>DO 10 I = 1,5 </code> start of a loop with I running from 1 to 5 :*<code>DO 10 I = 1.5 </code> assignment of the value 1.5 to the variable <code>DO10I</code> ====Flagged words==== {{main|Stropping (syntax)}} In Algol 60 and Algol 68, special tokens were distinguished explicitly: for publication, in boldface e.g. <code>'''begin'''</code>; for programming, with some special marking, e.g., a flag (<code>'begin</code>), quotation marks (<code>'begin'</code>), or underlined (<code><u>begin</u></code> on the [[Elliott 503]]). This is called "stropping". Tokens that are part of the language syntax thus do not conflict with programmer-defined names. ====Reserved keywords==== {{main|Reserved word}} Certain names are reserved as part of the programming language and can not be used as programmer-defined names. The majority of the most popular programming languages use reserved keywords. Early examples include [[FLOW-MATIC]] (1953) and [[COBOL]] (1959). Since 1970 other examples include Ada, C, C++, Java, and Pascal. The number of reserved words depends on the language: C has about 30 while COBOL has about 400.
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)