Knowledge

Terminal and nonterminal symbols

Source 📝

142: 20: 78:
Terminal symbols are symbols that may appear in the outputs of the production rules of a formal grammar and which cannot be changed using the rules of the grammar. Applying the rules recursively to a source string of symbols will usually terminate in a final output string consisting only of terminal
176:
are those grammars in which the left-hand side of each production rule consists of only a single nonterminal symbol. This restriction is non-trivial; not all languages can be generated by context-free grammars. Those that can are called context-free languages. These are exactly the languages that
375: 166:, a designated member of the set of nonterminals from which all the strings in the language may be derived by successive applications of the production rules. In fact, the language defined by a grammar is precisely the set of 466:
symbol. That is, each production rule maps from one string of symbols to another, where the first string contains at least one nonterminal symbol. In the case that the body consists solely of the
563: 719: 680: 456: 584:
is a notation for expressing certain grammars. For instance, the following production rules in Backus-Naur form are used to represent an integer (which may be signed):
197:(or just 'productions') that specify which symbols may replace which other symbols; these rules may be used to generate strings, or to parse them. Each such rule has a 511: 405: 291: 814: 600:'0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' 918: 882: 779:
This example supports strings with leading zeroes like "0056" or "0000", as well as negative zero strings like "-0" and "-00000".
149:
was formed by the grammar defined by the given production rules. This grammar can create strings with any number of the symbol Б
141: 194: 40: 741: 23:
The string "the dog ate the bone" was created using production rules that replaced non-terminal with terminal symbols.
524: 945: 940: 19: 570: 90:
is both a non-terminal symbol and the start symbol. The production rules for creating strings are as follows:
688: 205:, or right-hand side, which consists of a string that may replace it. Rules are often written in the form 122:
is a terminal symbol because no rule exists which would change it into something else. On the other hand,
422: 657: 182: 581: 851: 173: 898: 178: 910: 831: 416: 914: 878: 856: 751: 746: 902: 870: 823: 566: 490: 384: 28: 158:
Nonterminal symbols are those symbols that can be replaced. They may also be called simply
802:
Rosen, K. H. (2012). Discrete mathematics and its applications. McGraw-Hill. pages 847-851
127: 52: 903: 44: 370:{\displaystyle (\Sigma \cup N)^{*}N(\Sigma \cup N)^{*}\rightarrow (\Sigma \cup N)^{*}} 934: 264: 67: 835: 467: 233: 36: 134:
by a particular grammar is the set of strings that can be produced by the grammar
408: 63:) are replaced by groups of terminal symbols according to the production rules. 201:, or left-hand side, which consists of the string that may be replaced, and a 827: 181:. Context-free languages are the theoretical basis for the syntax of most 138:. Diagram 1 illustrates a string that can be produced with this grammar. 812:
Chomsky, Noam (1956). "Three Models for the Description of Language".
232:
In the classic formalization of generative grammars first proposed by
82:
Consider a grammar defined by two rules. In this grammar, the symbol
140: 66:
The terminals and nonterminals of a particular grammar are in two
18: 875:
Algebraic and automata theoretic properties of formal languages
909:. Reading, Mass.: Addison-Wesley Publishing Company. pp.  126:
has two rules that can change it, thus it is nonterminal. A
521:
A grammar is formally defined as the ordered quadruple
691: 660: 527: 493: 425: 387: 294: 470:, it may be denoted with a special notation (often 713: 674: 557: 505: 450: 399: 369: 558:{\displaystyle \langle N,\Sigma ,P,S\rangle } 8: 552: 528: 565:. Such a formal grammar is often called a 702: 692: 690: 661: 659: 526: 492: 442: 424: 391: 389: 386: 361: 336: 311: 293: 177:can be recognized by a non-deterministic 136:and that consist only of terminal symbols 16:Categories of symbols in formal grammars 795: 763: 905:Introduction to Formal Language Theory 815:IRE Transactions on Information Theory 714:{\displaystyle {\ce {A -> a | ab}}} 240:consists of the following components: 55:defined as part of a formal grammar. 458:represents zero or more symbols, and 7: 675:{\displaystyle {\ce {S -> cAd}}} 645: 641: 451:{\displaystyle (\Sigma \cup N)^{*}} 537: 429: 348: 323: 298: 51:are the elementary symbols of the 14: 170:strings that can be so derived. 33:terminal and nonterminal symbols 877:. North-Holland. pp. 8–9. 770:It contains no symbols at all. 703: 696: 665: 636:In this example, the symbols ( 482:) in order to avoid confusion. 439: 426: 358: 345: 342: 333: 320: 308: 295: 162:. A formal grammar includes a 1: 724:In this example, the symbols 742:Alphabet (formal languages) 640:) are terminal symbols and 962: 648:are nonterminal symbols. 732:are nonterminal symbols. 728:are terminal symbols and 86:is a terminal symbol and 828:10.1109/TIT.1956.1056813 586: 571:phrase structure grammar 236:in the 1950s, a grammar 193:A grammar is defined by 68:completely separate sets 487:A distinguished symbol 282:, each rule of the form 39:used in specifying the 849:Chomsky, Noam (1957). 715: 676: 559: 507: 506:{\displaystyle S\in N} 452: 401: 400:{\displaystyle {}^{*}} 371: 150: 145:Diagram 1. The string 24: 716: 677: 638:-,0,1,2,3,4,5,6,7,8,9 560: 508: 453: 402: 372: 183:programming languages 174:Context-free grammars 144: 22: 899:Harrison, Michael A. 852:Syntactic Structures 689: 658: 651:Another example is: 525: 491: 423: 385: 292: 573:in the literature. 250:nonterminal symbols 225:can be replaced by 179:push down automaton 160:syntactic variables 154:Nonterminal symbols 61:syntactic variables 57:Nonterminal symbols 711: 672: 555: 503: 448: 397: 367: 151: 25: 871:Ginsburg, Seymour 752:Recursive grammar 747:Chomsky Hierarchy 709: 701: 695: 670: 664: 213:; e.g., the rule 953: 946:Pattern matching 941:Formal languages 925: 924: 908: 895: 889: 888: 867: 861: 860: 846: 840: 839: 809: 803: 800: 780: 777: 771: 768: 731: 727: 720: 718: 717: 712: 710: 707: 706: 699: 693: 681: 679: 678: 673: 671: 668: 662: 647: 643: 639: 631: 628: 625: 621: 618: 615: 612: 609: 606: 603: 599: 596: 593: 590: 582:Backus–Naur form 567:rewriting system 564: 562: 561: 556: 512: 510: 509: 504: 481: 477: 473: 461: 457: 455: 454: 449: 447: 446: 414: 406: 404: 403: 398: 396: 395: 390: 376: 374: 373: 368: 366: 365: 341: 340: 316: 315: 280:production rules 277: 270: 261:terminal symbols 258: 247: 195:production rules 189:Production rules 148: 125: 121: 114: 110: 104: 101: 97: 89: 85: 74:Terminal symbols 49:Terminal symbols 41:production rules 37:lexical elements 29:formal languages 961: 960: 956: 955: 954: 952: 951: 950: 931: 930: 929: 928: 921: 897: 896: 892: 885: 869: 868: 864: 848: 847: 843: 811: 810: 806: 801: 797: 792: 786: 784: 783: 778: 774: 769: 765: 760: 738: 729: 725: 687: 686: 656: 655: 646:<integer> 637: 634: 633: 629: 626: 623: 619: 616: 613: 610: 607: 604: 601: 597: 594: 591: 588: 579: 523: 522: 489: 488: 479: 475: 471: 459: 438: 421: 420: 412: 388: 383: 382: 357: 332: 307: 290: 289: 275: 268: 256: 245: 221:specifies that 191: 156: 146: 128:formal language 123: 119: 112: 108: 102: 99: 95: 87: 83: 76: 43:constituting a 17: 12: 11: 5: 959: 957: 949: 948: 943: 933: 932: 927: 926: 919: 890: 883: 862: 841: 822:(3): 113–123. 804: 794: 793: 791: 788: 782: 781: 772: 762: 761: 759: 756: 755: 754: 749: 744: 737: 734: 722: 721: 705: 698: 683: 682: 667: 587: 578: 575: 554: 551: 548: 545: 542: 539: 536: 533: 530: 519: 518: 502: 499: 496: 484: 483: 445: 441: 437: 434: 431: 428: 394: 379: 378: 377: 364: 360: 356: 353: 350: 347: 344: 339: 335: 331: 328: 325: 322: 319: 314: 310: 306: 303: 300: 297: 284: 283: 272: 253: 190: 187: 155: 152: 116: 115: 105: 75: 72: 45:formal grammar 15: 13: 10: 9: 6: 4: 3: 2: 958: 947: 944: 942: 939: 938: 936: 922: 920:0-201-02955-3 916: 912: 907: 906: 900: 894: 891: 886: 884:0-7204-2506-9 880: 876: 872: 866: 863: 858: 855:. The Hague: 854: 853: 845: 842: 837: 833: 829: 825: 821: 817: 816: 808: 805: 799: 796: 789: 787: 776: 773: 767: 764: 757: 753: 750: 748: 745: 743: 740: 739: 735: 733: 685: 684: 654: 653: 652: 649: 642:<digit> 585: 583: 576: 574: 572: 568: 549: 546: 543: 540: 534: 531: 516: 500: 497: 494: 486: 485: 469: 465: 443: 435: 432: 418: 411:operator and 410: 392: 380: 362: 354: 351: 337: 329: 326: 317: 312: 304: 301: 288: 287: 286: 285: 281: 274:A finite set 273: 266: 262: 255:A finite set 254: 251: 244:A finite set 243: 242: 241: 239: 235: 230: 228: 224: 220: 216: 212: 208: 204: 200: 196: 188: 186: 184: 180: 175: 171: 169: 165: 161: 153: 143: 139: 137: 133: 129: 106: 93: 92: 91: 80: 73: 71: 69: 64: 62: 58: 54: 50: 46: 42: 38: 34: 30: 21: 904: 893: 874: 865: 850: 844: 819: 813: 807: 798: 785: 775: 766: 723: 650: 635: 580: 520: 515:start symbol 514: 513:that is the 468:empty string 463: 279: 260: 249: 237: 234:Noam Chomsky 231: 226: 222: 218: 214: 210: 206: 202: 198: 192: 172: 167: 164:start symbol 163: 159: 157: 135: 131: 117: 81: 77: 65: 60: 56: 48: 32: 26: 464:nonterminal 409:Kleene star 130:defined or 111:can become 107:The symbol 98:can become 94:The symbol 935:Categories 790:References 462:means one 697:⟶ 666:⟶ 553:⟩ 538:Σ 529:⟨ 498:∈ 444:∗ 433:∪ 430:Σ 417:set union 393:∗ 363:∗ 352:∪ 349:Σ 343:→ 338:∗ 327:∪ 324:Σ 313:∗ 302:∪ 299:Σ 132:generated 79:symbols. 901:(1978). 873:(1975). 836:19519474 736:See also 415:denotes 265:disjoint 263:that is 168:terminal 53:language 35:are the 726:a,b,c,d 605:integer 577:Example 413:∪ 407:is the 147:Б Б Б Б 917:  881:  857:Mouton 834:  480:ε 472:Λ 381:where 257:Σ 832:S2CID 758:Notes 627:digit 617:digit 592:digit 569:or a 419:, so 267:from 118:Here 915:ISBN 879:ISBN 644:and 630:> 624:< 620:> 614:< 608:> 602:< 595:> 589:< 211:body 207:head 203:body 199:head 59:(or 824:doi 730:S,A 669:cAd 611:::= 598:::= 478:or 278:of 259:of 248:of 47:. 27:In 937:: 913:. 911:13 830:. 818:. 708:ab 632:} 474:, 229:. 217:→ 209:→ 185:. 70:. 31:, 923:. 887:. 859:. 838:. 826:: 820:2 704:| 700:a 694:A 663:S 622:{ 550:S 547:, 544:P 541:, 535:, 532:N 517:. 501:N 495:S 476:e 460:N 440:) 436:N 427:( 359:) 355:N 346:( 334:) 330:N 321:( 318:N 309:) 305:N 296:( 276:P 271:. 269:N 252:. 246:N 238:G 227:b 223:a 219:b 215:a 124:Ψ 120:Б 113:Б 109:Ψ 103:Ψ 100:Б 96:Ψ 88:Ψ 84:Б

Index


formal languages
lexical elements
production rules
formal grammar
language
completely separate sets
formal language

Context-free grammars
push down automaton
programming languages
production rules
Noam Chomsky
disjoint
Kleene star
set union
empty string
rewriting system
phrase structure grammar
Backus–Naur form
Alphabet (formal languages)
Chomsky Hierarchy
Recursive grammar
IRE Transactions on Information Theory
doi
10.1109/TIT.1956.1056813
S2CID
19519474
Syntactic Structures

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.