Title: Theory / Unimportant / CS / Programming / C Harbison Steele{ / 02 Lexical+13
Tags: hasNotNewEffectReturnsMeaning FromInstruction computer_to_instruction hasSeenConjDef récupéré seen_description type comment declaration has_seen_instruction_2 todo_declaration
On every note of this deck, unless a note says otherwise:
Chapter: 2

Name: Characters of a C program
Definition: Latin letters
Page: 11
Definition2: digits
Conjdef: All of
Definition3: space
Definition4: horizontal tab, vertical tab, form feed
Definition5: the 29 graphic characters

Question: Additionnal character in a C program may appear
Answer: in comment, character constant, string constant and file name
Page: 12
Chapter: 2

Name: Execution character set
Definition: Basic character set
Page: 12
Definition2: null character (encoded as the value 0)
Conjdef: Either
Definition3: New line character
Definition4: alert
Definition5: backspace
Definition6: carriage return character

Name: Whitespace character
Definition: blank
Page: 13
Section: 1.2
Definition2: end-of-line
Conjdef: All of
Definition3: vertical tab
Definition4: form feed
Definition5: horizontal tab
Definition6: comment

Question: Whitespace are considered
Answer: to separate symbols
Page: 13
Chapter: 2
Section: 1.2
Answer2: in string
Answer3: in #include file name
Answer4: character constant.

Instruction: \newline symbol
Page: 13
Effect: ignore the end of line symbol
Language: C
Chapter: 2
Section: 1.2

Name: A character encoding
Definition: An association from computer's (execution) character to integers
Page: 14
Section: 1.3

Name: A trigraph
Definition: A sequence of two question mark, and a ISO 646-1083 Invariant Code Set character
Page: 14
Section: 1.4
Intuition: Represents a character potentially absent in another language

Name: A wide character
Definition: a binary representation of an element of an extended character set
Page: 15
Section: 1.5

Typ: wchar_t
Meaning: Wide character
Page: 15
Language: C
Chapter: 2
Section: 1.5
Library: stddef.h

Typ: wint_t
Meaning: The type union of Wide character and of WEOF
Page: 15
Language: C
Chapter: 2
Section: 1.5
Library: stddef.h

Name: A wide string
Definition: A contiguous sequence of wide characters ending with a null wide character
Page: 16
Section: 1.5

Name: null wide character
Definition: The wide character whose representation is 0
Page: 16
Section: 1.5

Name: Multibyte characters
Definition: The representation of a wide character in either the source or execution character set
Page: 16
Section: 1.5

Name: Conversion state of the encoding
Definition: The current interpretation within a sequence of multi byte characters
Page: 16
Section: 1.5
Variables: \(c\) an encoding
Name2: shift state of the encoding

Name: The initial conversion (shift) state
Definition: A distinguished shift state used when starting a conversion of a sequence of multibyte
Page: 16
Section: 1.5
Variables: \(c\) an encoding

Name: A state dependent encoding
Definition: An encoding in which the interpretation of a multibyte character may depend on the occurence of previous multibyte characters.
Page: 16
Section: 1.5
Variables: \(c\) an encoding

Name: A state independent encoding
Definition: An encoding in which the interpretation of a multibyte character does not depend on the previous multibyte characters.
Page: 17
Section: 1.5
Variables: \(c\) an encoding

Name: Restriction on multibyte characters
Definition: All characters from the stand ard character set must be present in the encoding.
Page: 17
Section: 1.5
Definition2: In the initial shift state, all single-byte characters from the standard character set retain their normal interpretation and do not affect the shift state.
Definition3: A byte containing all zeroes is taken to be the null character regardless of shift state. No multibyte character can use a byte containing all zeroes as its second or subsequent character.

Language: C
Abbreviation: //foo
(new line)
Instruction: /*
foo
*/
Other fields (not shown on cards):
Chapter: 2
Page: 14

Question: when are comments removed
Answer: before preprocessing
Page: 19
Chapter: 2

Question: Restriction on multiline comment
Answer: no /* */ imbricated. Because some compiler recognize imbrication while its not standard.
Page: 19
Chapter: 2

Instruction: #if 0
foo
#endif
Page: 19
Effect: A large part of the program, foo isignored
Language: C
Chapter: 2

Name: tokens
Definition: operators
Page: 20
Section: 3
Definition2: separator
Conjdef: Either
Definition3: identifiers
Definition4: keywords
Definition5: constants

Question: During lexing, tokens are collected
Answer: left to right, taking the longest token possible
Page: 20
Chapter: 2
Section: 3

Question: b--x is tokenized as
Answer: b -- x (invalid)
Page: 20
Chapter: 2
Section: 3

Question: b---x is tokenized as
Answer: b -- - x (invalid, while b - -- x would be valid)
Page: 20
Chapter: 2
Section: 3

Name: identifier
Definition: does not start with a digit
Page: 20
Section: 5
Context: C
Definition2: distinct from a keyword
Conjdef: A sequence of latin capital and small letters, digits, underscore, lowline character
Definition3: may be limited to 31 (63) chars in C89 (C99)
Name2: name

Instruction: _ followed by _ or by a cap
Page: 20
Effect: keyword reserved for the standard
Language: C
Chapter: 2
Section: 5

Name: keyword
Definition: Words reserved by the compiler, to have a special meaning. Can not be used as a variable/function name
Page: 20
Section: 5

Name: Compound assignment operators
Definition: += -= *= /= %= <<= >>= &= ^= |=
Page: 21
Section: 4

Name: Other compound operators
Definition: -> ++ -- << >> <= >= == != && ||
Page: 21
Section: 4

Name: Separator characters
Definition: () [] {} , ; : ...
Page: 21
Section: 4

Name: identifier
Definition: must not begin with a digit
Page: 21
Section: 5
Definition2: it must not have the same spelling as a keyword.
Conjdef: a sequence of Latin capital and small letters, digits, and the underscore or LOW LINE character
Name2: name

Question: Are identifiers case-sensitive ?
Answer: Yes
Page: 21
Chapter: 2
Section: 5
Context: C

Question: Identifier starting with an underscore
Answer: Identifier reserved for C standard current or future use
Page: 22
Chapter: 2
Section: 5

Name: external identifier
Definition: Identifier declared with storage class extern
Page: 22
Section: 5

Instruction: extern declaration of foo
Page: 22
Meaning: State that foo is an external variable
Language: C
Chapter: 2
Section: 5

Question: How to use long identifier when some restriction forbid them in code
Answer: Use #define AVERYLONGDEFINITION shortDef
Page: 22
Chapter: 2
Section: 5