葡萄球菌用什么抗生素| 阿鼻地狱是什么意思| 区长什么级别| 什么肉好消化| 回头是岸是什么意思| zing是什么意思| 西同念什么| 人为什么会得抑郁症| 鸡头上长痘痘用什么药| 梦见自己会飞是什么意思| 什么叫袖珍人| 免费婚检都检查什么项目| 梦到门坏了是什么意思| 眼睛干涩用什么眼药水好| 脱臼是指什么从什么中滑脱| 夏至为什么吃馄饨| 什么是挠脚心| 925银和s925银有什么区别| 什么情况需要根管治疗| 喜极而泣的意思是什么| 人参什么时候吃最好| 大小便失禁是什么原因| 今天生日什么星座| 脸发黄是什么原因| 吗丁啉是什么药| zorro是什么牌子的打火机| TA什么意思| 福寿螺为什么不能吃| skg是什么品牌| 乳房疼挂什么科室| 植物生长需要什么| 一劳永逸什么意思| 2月18号是什么星座| 腹部疼挂什么科| 膀胱炎吃什么药好得快| 尿道疼吃什么药| 猫爪草长什么样| 方方土是什么字| 虚张声势是什么生肖| 试管婴儿什么价格| 肝郁气滞有什么症状| 青海有什么特产| 一般什么时候排卵| 什么是音程| 天空像什么的比喻句| 白带清洁度lll度是什么意思| 枸杞加什么泡水喝壮阳| 嘴歪是什么病的前兆| 1978属什么| 为什么硬起来有点疼| 2月24号是什么星座| 廿二是什么意思| 笋吃多了有什么危害| 红细胞平均体积偏低是什么意思| 生化全套主要检查什么| 为什么要延迟退休| 惊艳是什么意思| 肝不好的人有什么症状| 为什么尿酸高| 兔子的耳朵有什么作用| 翻过山越过海是什么歌| 物心念什么| 克罗恩病是什么病| 2024年五行属什么| 每晚都做梦是什么原因| 皮内瘤变到底是什么意思| 梦见新房子是什么意思| 五月23是什么星座| 海虾不能和什么一起吃| cas是什么意思| 纳囊是什么妇科病| 洋葱什么时候种植| 低压高是什么原因| 猥琐男是什么意思| 气血不足是什么引起的| 夜郎自大是什么意思| 面粉和淀粉有什么区别| 眼睛肿疼是什么原因引起的| 相恋纪念日送什么礼物| 龋齿是什么样子的图片| 总胆红素高是怎么回事有什么危害| 脾胃气滞吃什么中成药| 宫腔粘连有什么症状| 爱发朋友圈的女人是什么心态| 为什么要延迟退休| 什么是公主病| 心悸气短是什么症状| 批发零售属于什么行业| o型血和a型血生的孩子是什么血型| 火加同念什么| 卡宾男装属于什么档次| 辟邪剑谱和葵花宝典有什么关系| 嬗变什么意思| 10086查话费发什么短信| 百什么争鸣成语| epa是什么意思| 新生儿贫血是什么原因造成的| 对偶是什么| 做蛋糕用什么面粉| 检查胰腺挂什么科| 烫伤起水泡涂什么药膏| 鸽子配什么煲汤最好| loc是什么意思| 头孢和什么不能一起吃| hpv16阳性有什么症状| N1是什么| 血脂高吃什么好| 石英表不走了是什么原因| 12颗珠子的手串什么意思| sunnyday是什么意思| pdw偏低是什么意思| 憋尿有什么危害| 后背的骨头叫什么| 风花雪月什么意思| 金牛座后面是什么星座| 什么是心脏造影| 2006属狗的五行缺什么| 着床是什么意思| 六月初五是什么星座| 上环要做什么检查| 马为什么站着睡觉| 气虚吃什么| 一般什么时候排卵| 结婚婚检都检查什么项目| 天罗地网是什么意思| 盆腔炎用什么药好| 领事是什么级别| 艾滋病英文缩写是什么| 戒色是什么意思| 鬼怕什么| 月经快来了有什么征兆| 只欠东风的上一句是什么| 靴型心见于什么病| 孕妇缺铁吃什么| 两个土念什么字| 老豆腐和嫩豆腐有什么区别| 脑膜瘤钙化意味着什么| 为什么听力会下降| 巴扎是什么意思| 瘿病是什么病| 血压低压高是什么原因造成的| 出生证明有什么用| 鼓动是什么意思| 榴莲壳有什么用处| 脂溢性皮炎有什么症状| 胃胀吃什么药效果好| 什么是质子重离子治疗| 做完胃肠镜后可以吃什么| 梦见怀孕是什么预兆| 靓仔是什么意思| 女人吃槐花有什么好处| 六月生日是什么星座| 晚餐吃什么菜谱大全| 子宫直肠窝积液是什么意思| 胆囊结石吃什么药| 婴儿口臭是什么原因引起的| 抑郁症挂什么科室| 大小三阳是什么病| 彼岸花是什么花| 26岁属什么生肖| 小孩老是肚子疼是什么原因| 眼睛为什么会肿| 肠胃蠕动慢吃什么药| samsonite什么牌子| 授受不亲什么意思| 治飞蚊症用什么眼药水| 每天早上起床头晕是什么原因| 6月28什么星座| 什么药治脂肪肝| 去取环前需做什么准备| 1985年属什么生肖| 植株是什么意思| 用什么点豆腐最健康| 变节是什么意思| bitch是什么意思| 捡什么废品最值钱| 小腿骨头疼是什么原因| 希腊脚是什么意思| 失眠吃什么中成药| 男士补肾吃什么| 润肺吃什么| 腋毛什么时候开始生长| 狮子男和什么星座最配| 黑指甲是什么症状图片| 吃什么可以增加黄体酮| 大雪是什么意思| 咪咪头疼是什么原因| 翡翠的种水是什么意思| 喝茶什么意思| 鹤顶红是什么| 周正是什么意思| cl是什么单位| 为什么叫西瓜| 腰间盘突出有什么症状| 手指头抽筋是什么原因| 皮肤白斑点是什么原因| 2月20是什么星座| ba是什么元素| 优势是什么意思| 胸腺癌早期有什么症状| 王一博是什么星座| 安全期是什么意思| 睡觉咬牙是什么原因| 什么是低筋面粉| 苹果补充什么维生素| 血光之灾是什么意思| 参透是什么意思| 早上尿黄是什么原因| 梦见锁门是什么意思| 女生喜欢什么| 大家闺秀是什么生肖| 什么叫窝沟封闭| 雅字取名的寓意是什么| 空灵是什么意思| 1976年五行属什么| 蚊子最喜欢什么血型| 痈疡是什么意思| 建军节是什么时候| 甘少一横是什么字| 瓜子脸适合剪什么刘海| pre是什么的缩写| 长颈鹿吃什么树叶| 157是什么意思| 宝格丽手表什么档次| 注意力不集中是什么原因| 什么是动车| 八大菜系之首是什么菜| 糖尿病吃什么菜最好| 新陈代谢慢吃什么药| imax电影是什么意思| 地铁站务员是干什么的| 头发油是什么原因| 广西属于什么方向| 牛肉不能和什么食物一起吃| 九孔藕和七孔藕有什么区别| 土是什么颜色| 剃光头有什么好处| 绿萝叶子发黄是什么原因| 电母是什么意思| 办健康证要带什么证件| 什么鱼红烧最好吃| 血清是什么| 怀孕有褐色分泌物是什么原因| 肥皂是什么做的| 咳嗽适合吃什么水果| 甘露醇是什么| 睡觉手麻是什么原因| 全身发烫但不发烧是什么原因| 棕色短裤配什么颜色上衣| 打九价是什么意思| 想要孩子需要做什么检查| 宫颈囊肿是什么意思| 一什么陆地| 美甲做多了有什么危害| 什么是数位板| 心电图j点抬高什么意思| 什么头十足| 蒸鱼豉油什么时候放| 氪金是什么意思| 脖子粗是什么原因| 总是头疼是什么原因| 小孩睡觉流鼻血是什么原因引起的| 乙肝表面抗体高是什么意思| 36计第一计是什么| 百度

十二团以实际行动让兵团第七次党代会精神落地生根

百度 如今,截污纳管和雨污分流工程还在持续进行中。

In computer programming, a statement is a syntactic unit of an imperative programming language that expresses some action to be carried out.[1] A program written in such a language is formed by a sequence of one or more statements. A statement may have internal components (e.g. expressions).

Many programming languages (e.g. Ada, Algol 60, C, Java, Pascal) make a distinction between statements and definitions/declarations. A definition or declaration specifies the data on which a program is to operate, while a statement specifies the actions to be taken with that data.

Statements which cannot contain other statements are simple; those which can contain other statements are compound.[2]

The appearance of a statement (and indeed a program) is determined by its syntax or grammar. The meaning of a statement is determined by its semantics.

Simple statements

edit

Simple statements are complete in themselves; these include assignments, subroutine calls, and a few statements which may significantly affect the program flow of control (e.g. goto, return, stop/halt). In some languages, input and output, assertions, and exits are handled by special statements, while other languages use calls to predefined subroutines.

  • assignment
    • Fortran: variable = expression
    • Pascal, Algol 60, Ada: variable := expression;
    • C, C#, C++, PHP, Java: variable = expression;
  • call
    • Fortran: CALL subroutine name(parameters)
    • C, C++, Java, PHP, Pascal, Ada: subroutine name(parameters);
  • assertion
    • C, C++, PHP: assert(relational expression);
    • Java: assert relational expression;
  • goto
    • Fortran: GOTO numbered-label
    • Algol 60: goto label;
    • C, C++, PHP, Pascal: goto label;
  • return
    • Fortran: RETURN value
    • C, C++, Java, PHP: return value;
  • stop/halt/exit
    • Fortran: STOP number
    • C, C++: exit(expression)
    • PHP: exit number;

Compound statements

edit

Compound statements may contain (sequences of) statements, nestable to any reasonable depth, and generally involve tests to decide whether or not to obey or repeat these contained statements.

Notation for the following examples:
  • <statement> is any single statement (could be simple or compound).
  • <sequence> is any sequence of zero or more <statements>
Some programming languages provide a general way of grouping statements together, so that any single <statement> can be replaced by a group:
  • Algol 60: begin <sequence> end
  • Pascal: begin <sequence> end
  • C, PHP, Java: { <sequence> }
Other programming languages have a different special terminator on each kind of compound statement, so that one or more statements are automatically treated as a group:
  • Ada: if test then <sequence> end if;

Many compound statements are loop commands or choice commands. In theory only one of each of these types of commands is required. In practice there are various special cases which occur quite often; these may make a program easier to understand, may make programming easier, and can often be implemented much more efficiently. There are many subtleties not mentioned here; see the linked articles for details.

  • count-controlled loop:
    • Algol 60: for index := 1 step 1 until limit do <statement> ;
    • Pascal: for index := 1 to limit do <statement> ;
    • C, Java: for ( index = 1; index <= limit; index += 1) <statement> ;
    • Ada: for index in 1..limit loop <sequence> end loop
    • Fortran 90:
      DO index = 1,limit
          <sequence>
      END DO
      
  • condition-controlled loop with test at start of loop:
    • Algol 60: for index := expression while test do <statement> ;
    • Pascal: while test do <statement> ;
    • C, Java: while (test) <statement> ;
    • Ada: while test loop <sequence> end loop
    • Fortran 90:
      DO WHILE (test)
          <sequence>
      END DO
      
  • condition-controlled loop with test at end of loop:
    • Pascal: repeat <sequence> until test; { note reversed test }
    • C, Java: do { <sequence> } while (test) ;
    • Ada: loop <sequence> exit when test; end loop;
  • condition-controlled loop with test in the middle of the loop:
    • C: do { <sequence> if (test) break; <sequence> } while (true) ;
    • Ada: loop <sequence> exit when test; <sequence> end loop;
  • if-statement simple situation:
    • Algol 60:if test then <unconditional statement> ;
    • Pascal: if test then <statement> ;
    • C, Java: if (test) <statement> ;
    • Ada: if test then <sequence> end if;
    • Fortran 77+:
      IF (test) THEN
          <sequence>
      END IF
      
  • if-statement two-way choice:
    • Algol 60: if test then <unconditional statement> else <statement> ;
    • Pascal: if test then <statement> else <statement> ;
    • C, Java: if (test) <statement> else <statement> ;
    • Ada: if test then <sequence> else <sequence> end if;
    • Fortran 77+:
      IF (test) THEN
          <sequence>
      ELSE
          <sequence>
      END IF
      
  • case/switch statement multi-way choice:
    • Pascal: case c of 'a': alert(); 'q': quit(); end;
    • Ada: case c is when 'a' => alert(); when 'q' => quit(); end case;
    • C, Java: switch (c) { case 'a': alert(); break; case 'q': quit(); break; }
  • Exception handling:
    • Ada: begin protected code except when exception specification => exception handler
    • Java: try { protected code } catch (exception specification) { exception handler } finally { cleanup }
    • Python: try: protected code except exception specification: exception handler else: no exceptions finally: cleanup

Syntax

edit

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.[3]
  • Up until Fortran 77, the language was described in English prose with examples,[4] From Fortran 90 onwards, the language was described using a variant of BNF.[5]
  • Cobol used a two-dimensional metalanguage.[6]
  • Pascal used both syntax diagrams and equivalent BNF.[7]

BNF uses recursion to express repetition, so various extensions have been proposed to allow direct indication of repetition.

Statements and keywords

edit

Some programming language grammars reserve keywords or mark them specially, and do not allow them to be used as identifiers. This often leads to grammars which are easier to parse, requiring less lookahead.

No distinguished keywords

edit

Fortran and PL/1 do not have reserved keywords, allowing statements like:

  • in PL/1:
    • IF IF = THEN THEN ... (the second IF and the first THEN are variables).
  • in Fortran:
    • IF (A) X = 10... conditional statement (with other variants)
    • IF (A) = 2 assignment to a subscripted variable named IF
As spaces were optional up to Fortran 95, a typo could completely change the meaning of a statement:
  • DO 10 I = 1,5 start of a loop with I running from 1 to 5
  • DO 10 I = 1.5 assignment of the value 1.5 to the variable DO10I

Flagged words

edit

In Algol 60 and Algol 68, special tokens were distinguished explicitly: for publication, in boldface e.g. begin; for programming, with some special marking, e.g., a flag ('begin), quotation marks ('begin'), or underlined (begin 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

edit

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.

Semantics

edit

Semantics is concerned with the meaning of a program. The standards documents for many programming languages use BNF or some equivalent to express the syntax/grammar in a fairly formal and precise way, but the semantics/meaning of the program is generally described using examples and English prose. This can result in ambiguity.[8] In some language descriptions the meaning of compound statements is defined by the use of 'simpler' constructions, e.g. a while loop can be defined by a combination of tests, jumps, and labels, using if and goto.

The semantics article describes several mathematical/logical formalisms which have been used to specify semantics in a precise way; these are generally more complicated than BNF, and no single approach is generally accepted as the way to go. Some approaches effectively define an interpreter for the language, some use formal logic to reason about a program, some attach affixes to syntactic entities to ensure consistency, etc.

Expressions

edit

A distinction is often made between statements, which are executed, and expressions, which are evaluated. Expressions always evaluate to a value, which statements do not. However, expressions are often used as part of a larger statement.

In most programming languages, a statement can consist of little more than an expression, usually by following the expression with a statement terminator (semicolon). In such a case, while the expression evaluates to a value, the complete statement does not (the expression's value is discarded). For instance, in C, C++, C#, and many similar languages, x = y + 1 is an expression that will set x to the value of y plus one, and the whole expression itself will evaluate to the same value that x is set to. However, x = y + 1; (note the semicolon at the end) is a statement that will still set x to the value of y plus one because the expression within the statement is still evaluated, but the result of the expression is discarded, and the statement itself does not evaluate to any value.[9]

Expressions can also be contained within other expressions. For instance, the expression x = y + 1 contains the expression y + 1, which in turn contains the values y and 1, which are also technically expressions.

Although the previous examples show assignment expressions, some languages do not implement assignment as an expression, but rather as a statement. A notable example of this is Python, where = is not an operator, but rather just a separator in the assignment statement. Although Python allows multiple assignments as each assignment were an expression, this is simply a special case of the assignment statement built into the language grammar rather than a true expression.[10]

Extensibility

edit

Most languages have a fixed set of statements defined by the language, but there have been experiments with extensible languages that allow the programmer to define new statements.

See also

edit

References

edit
  1. ^ "statement". webopedia. September 1996. Retrieved 2025-08-05.
  2. ^ Backus, J.W.; Bauer, F.L.; Green, J.; Katz, C.; McCarthy, J.; Naur, P.; Perlis, A.J.; Rutishauser, H.; Samuelson, K.; Vauquois, B.; Wegstein, J.H.; van Wijngaarden, A.; Woodger, M. Naur, Peter (ed.). "Revised Report on the Algorithmic Language Algol 60". mass:werk. Section "4.1". Retrieved January 23, 2021.
  3. ^ Backus, J.W.; Bauer, F.L.; Green, J.; Katz, C.; McCarthy, J.; Naur, P.; Perlis, A.J.; Rutishauser, H.; Samuelson, K.; Vauquois, B.; Wegstein, J.H.; van Wijngaarden, A.; Woodger, M. Naur, Peter (ed.). "Revised Report on the Algorithmic Language Algol 60". mass:werk. Section "1.1". Retrieved January 23, 2021.
  4. ^ "FORTRAN" (PDF). United States of America Standards Institute. 1966. Retrieved February 19, 2021 – via WG5 Fortran Standards.
  5. ^ "Working draft J3/04-007" (PDF). J3 Fortran. May 10, 2004. Retrieved February 19, 2021.
  6. ^ "ASCII COBOL Programming Reference Manual" (PDF). unisys. June 2010. Retrieved January 23, 2021.
  7. ^ Jensen, Kathleen; Wirth, Niklaus (1974). Goos, G.; Hartmanis, J. (eds.). "PASCAL User Manual and Report" (PDF). Lecture Notes in Computer Science. Appendix D. Retrieved February 19, 2021.
  8. ^ Knuth, D. E. (Jul 1967). "The Remaining Trouble Spots in Algol 60" (PDF). The ALGOL Family. Retrieved February 24, 2021.
  9. ^ "ISO/IEC 9899:1999 (E)" (PDF). ISO/IEC. Archived (PDF) from the original on Feb 7, 2024.
  10. ^ "7. Simple statements". Python 3.10.8 documentation.
edit
盲肠憩室是什么意思 睡觉手发麻是什么原因 眼睛痛吃什么药好得快 动手术后吃什么对伤口恢复比较快 母螳螂为什么要吃公螳螂
什么的雾 桎梏是什么意思 睡觉容易醒是什么原因 后腰左侧疼痛是什么原因男性 小便发红是什么原因
间质瘤是什么性质的瘤 社会保险费是什么 咖啡喝了有什么好处 男人皮肤黑穿什么颜色的衣服好看 音容笑貌的意思是什么
着床出血什么时候出现 肠镜检查挂什么科室 泡沫尿挂什么科 性格是什么意思 是什么样的感觉我不懂是什么歌
天涯是什么意思hcv8jop6ns9r.cn 塔罗牌逆位是什么意思hcv8jop9ns6r.cn 出入是什么意思hcv7jop5ns1r.cn yaoi是什么hcv9jop0ns8r.cn 祠堂是什么意思hcv8jop1ns0r.cn
女性更年期在什么年龄段mmeoe.com 金匮肾气丸有什么功效hcv8jop7ns9r.cn 身份证后四位代表什么hcv9jop8ns3r.cn 伤口增生是什么原因造成的hcv8jop7ns0r.cn 顺遂是什么意思hcv8jop8ns1r.cn
虱子长什么样子图片hcv8jop1ns1r.cn ce是什么元素hcv9jop3ns8r.cn 什么是讨好型人格hcv8jop6ns7r.cn 试管都有什么方案hcv7jop5ns1r.cn 12月27号是什么星座hcv9jop0ns5r.cn
捞佬是什么意思hcv8jop2ns2r.cn 桂皮是什么树的皮hcv7jop6ns8r.cn 嗓子疼吃什么食物好hcv7jop7ns3r.cn 小腿发麻是什么原因naasee.com 孕妇适合喝什么茶ff14chat.com
百度