Week 12 Flashcards
What does the c preprocessor do?
Makes changes to your program before code generation begins
What are the typical uses of a c preprocessor?
Including other files like .h files
Defining constants
Defining macros
Selectively include or exclude some parts of a program
Give additional details to the compiler
What do all preprocessor commands begin with?
#
What does #include do?
Include the contents of one file directly into another file
What does #define symbol value do?
Replace all occurences of symbol with the value
What does #define do?
Can be used to make macros with parameters
The don’t fully behave like function calls
Is it a good practice to hae parameters in parantheses?
Yes, it helps to make sure we get the result we expected.
What does FILE do?
the name of the file being compiled
What is LINE?
The line number where symbol was found.
What is DATE and TIME
indicates when the compilation happened
What is FILE and LINE
Would most typically be used in other macros where you dn’t know immediately where the macro is being used.
What do #if, #else, #endif do?
LEts you use an expression to determine what to include in a compilation
Exclude temporary code with #if 0 …#endif
Include OS-specific code based on the expression
What is the shorthand for #if defined(X)…#endif
Becomes #ifdef X….#endif
What is the shorthand for #if_defined(x)…#endif
Becomes #ifndef X ….#endif
How are compiler specific commands defined?
by #pragma statements
What do #error and #warning do?
Lets you print messages at compile time
What is the set L?
Called the language
What are the elements of Chomsky Hierarchy?
Different levels of complexity for matching patterns of data.
Regular expressions
Context-free grammars
Context-sensitive grammars
Unrestricted grammars
What are the elements of regular expressions?
Simplest of rules
Cannot match the numbe of pairs of things like matching parantheses
Can be handled by finite state machine
What are the elements of context-free grammars?
Needs a non-deterministic pushdown automaton
What are the elements of context-sensitive grammars?
Needs a non-deterministic Turing machine
What are the elements of the unrestricted grammars?
Allows for the most complx rules
What are some different symbols to represent the regular expressions in different tools?
Grep, sed
bash pathname expansion, find
perl
Grep/sed syntax: What are the basic operations?
Character specification
Catenation
Repetition
Grouping
Alternation