Knowledge

Lexical grammar

Source 📝

43:. The program is written using characters that are defined by the lexical structure of the language used. The character set is equivalent to the alphabet used by any written language. The lexical grammar lays down the rules governing how a character sequence is divided up into subsequences of characters, each part of which represents an individual token. This is frequently defined in terms of 98:(plus whitespace tokens) because the space character terminates the sequence of characters forming the identifier. Further, certain sequences are categorized as 102:– these generally have the same form as identifiers (usually alphabetical words), but are categorized separately; formally they have a different token type. 219: 192: 99: 36: 78:
sequence (letters and digits, usually also allowing underscores, and disallowing initial digits), and that an
253: 119:
Escaped string literal (quote, followed by escaped characters or non-quotes, ending in a quote):
182: 71: 209: 51: 8: 44: 215: 188: 238: 258: 161: 67: 20: 79: 55: 40: 32: 247: 113:
Unescaped string literal (quote, followed by non-quotes, ending in a quote):
75: 110:
Regular expressions for common lexical rules follow (for example, C).
184:
Object-oriented Programming with Java: Essentials and Applications
82:
is a sequence of digits. So in the following character sequence
245: 207: 214:. Addison-Wesley Professional. pp. 9–. 187:. Tata McGraw-Hill Education. pp. 57–. 16:Formal grammar defining the syntax of tokens 131:Decimal integer literal (no leading zero): 50:For instance, the lexical grammar for many 62:character and continues until a matching 246: 70:makes this more complicated), that an 180: 174: 13: 14: 270: 239:ANSI C grammar, Lex specification 232: 211:The Java Language Specification 201: 1: 167: 137:Hexadecimal integer literal: 7: 155: 105: 10: 275: 143:Octal integer literal: 208:James Gosling (2000). 52:programming languages 45:regular expressions 221:978-0-201-31008-5 194:978-0-07-066908-6 125:Integer literal: 54:specifies that a 29:lexical structure 266: 254:Formal languages 226: 225: 205: 199: 198: 178: 162:Lexical analysis 85: 65: 61: 21:computer science 274: 273: 269: 268: 267: 265: 264: 263: 244: 243: 235: 230: 229: 222: 206: 202: 195: 179: 175: 170: 158: 153: 147: 141: 135: 129: 123: 117: 108: 86:the tokens are 83: 80:integer literal 63: 59: 25:lexical grammar 17: 12: 11: 5: 272: 262: 261: 256: 242: 241: 234: 233:External links 231: 228: 227: 220: 200: 193: 181:Buyya (2009). 172: 171: 169: 166: 165: 164: 157: 154: 151: 145: 139: 133: 127: 121: 115: 107: 104: 58:starts with a 56:string literal 33:formal grammar 15: 9: 6: 4: 3: 2: 271: 260: 257: 255: 252: 251: 249: 240: 237: 236: 223: 217: 213: 212: 204: 196: 190: 186: 185: 177: 173: 163: 160: 159: 150: 144: 138: 132: 126: 120: 114: 111: 103: 101: 97: 93: 89: 84:"abc" xyz1 23 81: 77: 73: 69: 57: 53: 48: 46: 42: 38: 35:defining the 34: 30: 26: 22: 210: 203: 183: 176: 149:Identifier: 148: 142: 136: 130: 124: 118: 112: 109: 95: 91: 87: 76:alphanumeric 49: 28: 24: 18: 248:Categories 168:References 92:identifier 72:identifier 66:is found ( 122:"(\.|)*" 156:See also 106:Examples 100:keywords 68:escaping 259:Parsing 218:  191:  96:number 88:string 74:is an 41:tokens 37:syntax 31:is a 216:ISBN 189:ISBN 134:*|0 116:"*" 94:and 23:, a 146:0+ 140:0+ 39:of 27:or 19:In 250:: 152:* 128:+ 90:, 47:. 224:. 197:. 64:" 60:"

Index

computer science
formal grammar
syntax
tokens
regular expressions
programming languages
string literal
escaping
identifier
alphanumeric
integer literal
keywords
Lexical analysis
Object-oriented Programming with Java: Essentials and Applications
ISBN
978-0-07-066908-6
The Java Language Specification
ISBN
978-0-201-31008-5
ANSI C grammar, Lex specification
Categories
Formal languages
Parsing

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