Lexical grammar

lexical specificationlexical syntax
In computer science, a lexical grammar is a formal grammar defining the syntax of tokens.wikipedia
16 Related Articles

Syntax (programming languages)

syntaxsyntacticallysyntactic
In computer science, a lexical grammar is a formal grammar defining the syntax of tokens.
Words are in a regular language, specified in the lexical grammar, which is a Type-3 grammar, generally given as regular expressions.

Lexical analysis

tokenslexical analyzertoken
In computer science, a lexical grammar is a formal grammar defining the syntax of tokens.
The specification of a programming language often includes a set of rules, the lexical grammar, which defines the lexical syntax.

Reserved word

keywordkeywordsreserved keyword
Further, certain sequences are categorized as keywords – these generally have the same form as identifiers (usually alphabetical words), but are categorized separately; formally they have a different token type.
The distinct definitions are clear when a language is analyzed by a combination of a lexer and a parser, and the syntax of the language is generated by a lexical grammar for the words, and a context-free grammar of production rules for the phrases.

Computer science

computer scientistcomputer sciencescomputer scientists
In computer science, a lexical grammar is a formal grammar defining the syntax of tokens.

Formal grammar

grammargrammarsformal grammars
In computer science, a lexical grammar is a formal grammar defining the syntax of tokens.

Regular expression

regular expressionsregexregexp
This is frequently defined in terms of regular expressions.

Programming language

programming languageslanguagedialect
For instance, the lexical grammar for many programming languages specifies that a string literal starts with a " character and continues until a matching " is found (escaping makes this more complicated), that an identifier is an alphanumeric sequence (letters and digits, usually also allowing underscores, and disallowing initial digits), and that an integer literal is a sequence of digits.

String literal

stringraw stringliteral string
For instance, the lexical grammar for many programming languages specifies that a string literal starts with a " character and continues until a matching " is found (escaping makes this more complicated), that an identifier is an alphanumeric sequence (letters and digits, usually also allowing underscores, and disallowing initial digits), and that an integer literal is a sequence of digits.

Escape character

escapeESCescaped
For instance, the lexical grammar for many programming languages specifies that a string literal starts with a " character and continues until a matching " is found (escaping makes this more complicated), that an identifier is an alphanumeric sequence (letters and digits, usually also allowing underscores, and disallowing initial digits), and that an integer literal is a sequence of digits.

Identifier

IDidentifiersidentification number
For instance, the lexical grammar for many programming languages specifies that a string literal starts with a " character and continues until a matching " is found (escaping makes this more complicated), that an identifier is an alphanumeric sequence (letters and digits, usually also allowing underscores, and disallowing initial digits), and that an integer literal is a sequence of digits.

Alphanumeric

alphanumericsAlphamericalphanumeric characters
For instance, the lexical grammar for many programming languages specifies that a string literal starts with a " character and continues until a matching " is found (escaping makes this more complicated), that an identifier is an alphanumeric sequence (letters and digits, usually also allowing underscores, and disallowing initial digits), and that an integer literal is a sequence of digits.

Integer literal

digit separatorInteger literal: Digit separators
For instance, the lexical grammar for many programming languages specifies that a string literal starts with a " character and continues until a matching " is found (escaping makes this more complicated), that an identifier is an alphanumeric sequence (letters and digits, usually also allowing underscores, and disallowing initial digits), and that an integer literal is a sequence of digits.

Stropping (syntax)

stroppingstroppeddesignating
The various rules regimes are a lexical specification for stropped characters, though in some cases these have simple interpretations: in the single apostrophe and dot regimes, the first character is functioning as an escape character, while in the matched apostrophes regime the apostrophes are functioning as delimiters, as in string literals.

Identifier (computer languages)

identifieridentifiersname
Which character sequences constitute identifiers depends on the lexical grammar of the language.

Maximal munch

longest matchlongest-match principle
For instance, the lexical syntax of many programming languages requires that tokens be built from the maximum possible number of characters from the input stream.