1"use strict";(self.webpackChunkada_lang_io=self.webpackChunkada_lang_io||[]).push([["2756"],{8754(e,s,n){n.r(s),n.d(s,{metadata:()=>t,default:()=>j,frontMatter:()=>l,contentTitle:()=>h,toc:()=>x,assets:()=>A});var t=JSON.parse('{"id":"arm/AA-5/AA-5.8","title":"5.8. Goto Statements","description":"This Reference Manual output has not been verified,","source":"@site/docs/arm/AA-5/AA-5.8.mdx","sourceDirName":"arm/AA-5","slug":"/arm/AA-5/AA-5.8","permalink":"/docs/arm/AA-5/AA-5.8","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":49,"frontMatter":{"sidebar_position":49},"sidebar":"referenceManualSidebar","previous":{"title":"5.7. Exit Statements","permalink":"/docs/arm/AA-5/AA-5.7"},"next":{"title":"6. Subprograms","permalink":"/docs/arm/AA-6/"}}'),r=n(74848),a=n(28453),c=n(98113),i=n(60271),o=n(9011),d=n(48554);n(94029);let l={sidebar_position:49},h="5.8. Goto Statements",A={},x=[{value:"Syntax",id:"syntax",level:4},{value:"Name Resolution Rules",id:"name-resolution-rules",level:4},{value:"Legality Rules",id:"legality-rules",level:4},{value:"Dynamic Semantics",id:"dynamic-semantics",level:4},{value:"Examples",id:"examples",level:4}];function m(e){let s={a:"a",admonition:"admonition",h1:"h1",h4:"h4",header:"header",p:"p",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s.header,{children:(0,r.jsx)(s.h1,{id:"58-goto-statements",children:"5.8. Goto Statements"})}),"\n",(0,r.jsx)(s.admonition,{type:"danger",children:(0,r.jsxs)(s.p,{children:["This Reference Manual output has not been verified,\nand may contain omissions or errors.\nReport any problems on the ",(0,r.jsx)(s.a,{href:"https://github.com/ada-lang-io/ada-lang-io/issues/20",children:"tracking issue"})]})}),"\n","\n",(0,r.jsx)(d.A,{children:"1"}),"\n",(0,r.jsxs)("p",{children:["[A ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.8#S0194",children:"goto_statement"})})," specifies an explicit transfer of control from this ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0167",children:"statement"})})," to a target statement with a given label.] ",(0,r.jsx)("br",{})]}),"\n",(0,r.jsx)(s.h4,{id:"syntax",children:"Syntax"}),"\n",(0,r.jsx)(d.A,{children:"2"}),"\n",(0,r.jsx)(o.A,{children:(0,r.jsxs)(s.p,{children:[(0,r.jsxs)("code",{children:["goto","_","statement"]}),(0,r.jsx)("a",{id:"S0194"}),(0,r.jsx)("code",{children:" ::= "}),(0,r.jsx)("b",{children:"goto"})," ",(0,r.jsxs)("i",{children:["label","_"]}),(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-4/AA-4.1#S0091",children:"name"})}),";",(0,r.jsx)("br",{})]})}),"\n",(0,r.jsx)(s.h4,{id:"name-resolution-rules",children:"Name Resolution Rules"}),"\n",(0,r.jsx)(d.A,{children:"3"}),"\n",(0,r.jsxs)("p",{children:["The ",(0,r.jsxs)("i",{children:["label","_"]}),(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-4/AA-4.1#S0091",children:"name"})})," shall resolve to denote a ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0171",children:"label"})}),"; the ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0167",children:"statement"})})," with that ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0171",children:"label"})})," is the ",(0,r.jsx)("i",{children:"target statement"}),". ",(0,r.jsx)("br",{})]}),"\n",(0,r.jsx)(s.h4,{id:"legality-rules",children:"Legality Rules"}),"\n",(0,r.jsx)(d.A,{children:"4"}),"\n",(0,r.jsxs)("p",{children:["The innermost ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0166",children:"sequence_of_statements"})})," that encloses the target statement shall also enclose the ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.8#S0194",children:"goto_statement"})}),". Furthermore, if a ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.8#S0194",children:"goto_statement"})})," is enclosed by an ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-9/AA-9.5#S0258",children:"accept_statement"})})," or a body, then the target statement shall not be outside this enclosing construct. ",(0,r.jsx)("br",{})]}),"\n",(0,r.jsxs)(i.A,{children:[(0,r.jsx)(d.A,{children:"4.a"}),(0,r.jsx)(c.A,{type:"aarm",aarm:"ramification",children:(0,r.jsxs)(s.p,{children:[(0,r.jsx)("b",{}),"The ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.8#S0194",children:"goto_statement"})})," can be a ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0167",children:"statement"})})," of an inner ",(0,r.jsxs)("code",{children:["sequence","_"]}),".",(0,r.jsx)("br",{})]})})]}),"\n",(0,r.jsxs)(i.A,{children:[(0,r.jsx)(d.A,{children:"4.b"}),(0,r.jsx)(c.A,{type:"aarm",aarm:"note",children:(0,r.jsxs)(s.p,{children:["It follows from the second rule that if the target ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0167",children:"statement"})})," is enclosed by such a construct, then the ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.8#S0194",children:"goto_statement"})})," cannot be outside. ",(0,r.jsx)("br",{})]})})]}),"\n",(0,r.jsx)(s.h4,{id:"dynamic-semantics",children:"Dynamic Semantics"}),"\n",(0,r.jsx)(d.A,{children:"5"}),"\n",(0,r.jsxs)("p",{children:["The execution of a ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.8#S0194",children:"goto_statement"})})," transfers control to the target statement, completing the execution of any ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0169",children:"compound_statement"})})," that encloses the ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.8#S0194",children:"goto_statement"})})," but does not enclose the target. ",(0,r.jsx)("br",{})]}),"\n",(0,r.jsxs)(i.A,{children:[(0,r.jsx)(d.A,{children:"6"}),(0,r.jsx)(c.A,{type:"aarm",aarm:"note",children:(0,r.jsxs)(s.p,{children:["NOTE The above rules allow transfer of control to a ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0167",children:"statement"})})," of an enclosing ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.1#S0166",children:"sequence_of_statements"})})," but not the reverse. Similarly, they prohibit transfers of control such as between alternatives of a ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.4#S0176",children:"case_statement"})}),", ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-5/AA-5.3#S0175",children:"if_statement"})}),", or ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-9/AA-9.7#S0269",children:"select_statement"})}),"; between ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-11/AA-11.2#S0305",children:"exception_handler"})}),"s; or from an ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{href:"/docs/arm/AA-11/AA-11.2#S0305",children:"exception_handler"})})," of a ",(0,r.jsx)("code",{children:(0,r.jsxs)("a",{href:"/docs/arm/AA-11/AA-11.2#S0304",children:["handled","_","sequence","_","of","_","statements"]})})," back to its ",(0,r.jsx)("code",{children:(0,r.jsxs)("a",{href:"/docs/arm/AA-5/AA-5.1#S0166",children:["sequence","_","of","_","statements"]})}),". ",(0,r.jsx)("br",{})]})})]}),"\n",(0,r.jsx)(s.h4,{id:"examples",children:"Examples"}),"\n",(0,r.jsx)(d.A,{children:"7"}),"\n",(0,r.jsxs)("p",{children:[(0,r.jsx)("i",{children:"Example of a loop containing a goto statement:"})," ",(0,r.jsx)("br",{})]}),"\n",(0,r.jsx)(d.A,{children:"8"}),"\n",(0,r.jsx)(o.A,{language:"ada",children:(0,r.jsxs)(s.p,{children:["<","<","Sort",">",">","\n","for I in 1 .. N-1 loop","\n"," if A(I) ",">"," A(I+1) then","\n"," Exchange(A(I), A(I+1));","\n"," goto Sort;","\n"," end if;","\n","end loop;","\n"]})})]})}function j(e={}){let{wrapper:s}={...(0,a.R)(),...e.components};return s?(0,r.jsx)(s,{...e,children:(0,r.jsx)(m,{...e})}):m(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.