PROGLANG MIDTERM

0.0(0)
Studied by 4 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/154

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:43 AM on 3/12/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

155 Terms

1
New cards

Lexical analysis

It involves reading the source code character from left to right and organizing them into tokens.

2
New cards

Tokens

Lexical analysis aims to read the input code and break it into meaningful elements called _________ for a computer to understand easily.

3
New cards

comments and whitespace

Lexical analysis eliminates ___________ and ____________ within the source code.

4
New cards

Lexical analyzer

This collects characters into logical groupings and assigns internal codes to the groupings based on their structure. These logical groupings are called lexemes, and the internal codes for categories of these groupings are the tokens.

5
New cards

Lexemes and Tokens

A lexical analyzer collects characters into logical groupings and assigns internal codes to the groupings based on their structure. These logical groupings are called _______, and the internal codes for categories of these groupings are the _________.

6
New cards

regular expressions

In programming language, tokens can be described using __________ ____________.

7
New cards

Deterministic Finite Automaton (DFA)

A lexical analyzer uses a __________ _____________ ____________ to recognize these tokens, as they can identify regular languages.

8
New cards

token type

Each final state of the DFA corresponds to a specific ________ ______, allowing the analyzer to classify the input.

9
New cards

Automated

The process of creating a DFA from regular expressions can be ____________ to make handling token recognition easier.

10
New cards

Deterministic Finite Automaton (DFA)

They can identify regular languages.

11
New cards

Input Preprocessing

Involves cleaning up the input text and preparing it for lexical analysis.

12
New cards

comments, whitespaces

Input Preprocessing covers the removal of ___________, ____________, and other non-essential characters from the input text.

13
New cards

Tokenization

Involves the process of breaking the input text into a sequence of tokens.

14
New cards

regular expressions

Tokenization is done by matching the characters in the input text against a set of patterns or ___________ ___________ that define the different types of tokens.

15
New cards

Token Classification

The analyzer determines the type of each token. For instance, the analyzer might classify the keywords, identifiers, operators, and punctuation symbols as separate token types.

16
New cards

Token Validation

The analyzer checks if each token is valid based on the rules of the programming language. For instance, the analyzer might check that a variable name is a valid identifier or that an operator has the correct syntax.

17
New cards

Output Generation

The analyzer generates the output of the lexical analysis process, typically a list or sequence of tokens (token stream).

18
New cards

Syntax analysis

In Output Generation, the list of tokens can then be passed to the next stage of compilation or interpretation, which will be sent to the parser for _________ __________.

19
New cards

Token stream

These are the sequence of tokens.

20
New cards

Input Preprocessing, Tokenization, Token Classification, Token Validation, Output Generation

Lexical Analyzer process; HINT: IP T TC TV OG

21
New cards

Tokens

It can be individual words or symbols in a sentence, such as keywords, variable names, numbers, and punctuation.

22
New cards

Alphabets

All the numbers and alphabets are considered hexadecimal alphabets by language.

23
New cards

hexadecimal alphabets

Alphabets: All the numbers and alphabets are considered __________ ____________ by language.

24
New cards

Strings

The collection of different alphabets occurring continuously.

25
New cards

String length

It is defined by the number of characters or alphabets occurring together. For example, the length of |STIisthebest

26
New cards

Alphabets, Symbols, Non-token

Tokens can be specified in different sets: HINT: A S NT

27
New cards

Punctuation

Name: ___________ Symbols: Comma (,), Semicolon(:)

28
New cards

Assignment

Name: ___________ Symbols: =

29
New cards

Special Assignment

Name: ___________ Symbols: +=, -=, *=, /=

30
New cards

Comparison

Name: ___________ Symbols: ==, ≠,

31
New cards

Preprocessor

Name: ___________ Symbols: #

32
New cards

Location Specifier

Name: ___________ Symbols: &

33
New cards

Logical

Name: ___________ Symbols: &&, |, ||, !

34
New cards

Shift Operator

Name: ___________ Symbols: >>, <

35
New cards

Lexemes

These are the sequence of characters matched by a pattern to form the token or a sequence of input characters that comprises a single token.

36
New cards

string patterns

Lexemes are recognized by matching the input character string against character __________ _________, while tokens are represented as integer values.

37
New cards

Integer values

Tokens are represented as __________ ________.

38
New cards

IDENT

Example: result = oldsum – value / 50;

Lexemes: result Token: ________

39
New cards

ASSING_OP

Example: result = oldsum – value / 50;

Lexemes: = Token: ________

40
New cards

IDENT

Example: result = oldsum – value / 50;

Lexemes: oldsum Token: _________

41
New cards

SUB_OP

Example: result = oldsum – value / 50;

Lexemes: - Token: ________

42
New cards

IDENT

Example: result = oldsum – value / 50;

Lexemes: value Token: _______

43
New cards

DIV_OP

Example: result = oldsum – value / 50;

Lexemes: / Token: _________

44
New cards

INT_LIT

Example: result = oldsum – value / 50;

Lexemes: 50 Token: ________

45
New cards

SEMICOLON

Example: result = oldsum – value / 50;

Lexemes: ; Token: ________

46
New cards

single token

Everything inside a double quote ("") in print() statements is counted as a _______ ________.

47
New cards

Token Stream

This output is generated from lexical analysis and will be sent to the syntax analyzer for syntax analysis

48
New cards

Syntax analysis or parsing

It is the process of analyzing a string of symbols according to the rules of formal grammar.

49
New cards

Syntax

Syntax analysis or parsing checks the source code to ensure that it follows the correct ________ of the programming language it is written.

50
New cards

Syntax errors

These errors are identified and flagged in the syntax analysis phase and must be corrected before the program can be successfully compiled.

51
New cards

Syntax analysis or parsing

Syntax errors are identified and flagged in this phase and must be corrected before the program can be successfully compiled.

52
New cards

Syntax analysis or parsing

It is the phase after the lexical analysis in the compiling process.

53
New cards

Syntax analyzer or parser

This takes the token streams from a lexical analyzer and analyzes them against production rules to detect errors in the code.

54
New cards

production rules

A syntax analyzer or parser takes the token streams from a lexical analyzer and analyzes them against ________ ______ to detect errors in the code.

55
New cards

Parse tree or Abstract Syntax Tree (AST)

It is the output of the syntax analysis phase, representing the program’s structure.

56
New cards

Parse tree or Abstract Syntax Tree (AST)

It represents the program’s structure.

57
New cards

Parenthesis

A lexical analyzer can identify tokens using regular expressions and pattern rules. Still, it cannot check the syntax of a given sentence since regular expressions cannot check balancing tokens such as __________.

58
New cards

Context-Free Grammar (CFG)

Syntax analysis uses __________ ____ ___________ to define the syntax rules of a programming language.

59
New cards

production rules

Context-Free Grammar (CFG) includes __________ _________ that describe how valid strings (token streams) are formed.

60
New cards

Grammar

CFGs also specify the ___________ of a language to ensure that the source code adheres to the language’s syntax.

61
New cards

Parsing

The tokens are analyzed based on the grammar rules of the programming language. A parse tree or AST is constructed to represent the hierarchical structure of the program.

62
New cards

Error Handling

If the input program contains syntax errors, the syntax analyzer detects and flags them to the user, indicating where the error occurred.

63
New cards

Symbol Table Creation

The syntax analyzer creates this, a data structure that stores information about the identifiers used in the program, such as type, scope, and location.

64
New cards

Parsing, Error Handling, Symbol Table Creation

The parser accomplishes the following steps: HINT: P EH STC

65
New cards

Derivation

It is the process of applying the rules of Context-Free Grammar to generate a sequence of tokens to form a valid structure.

66
New cards

Derivation

Simply, it is a sequence of production rules to get the input string for the parser.

67
New cards

Non-terminal

There are two (2) decisions for some sentential form of input during parsing: Deciding on the __________ to be replaced

68
New cards

production rule

There are two (2) decisions for some sentential form of input during parsing: Deciding the ___________ _________ by which the non-terminal will be replaced

69
New cards

Left-most derivation

It is called ________ ________ _____________ if the sentential form of an input is scanned and replaced from left to right.

70
New cards

Left-sentential form

The left-most derived sentential form is called the _____ __________ ____.

71
New cards

Right-most derivation

It is called the ________ ____________ _________ if the input is scanned and replaced with production rules.

72
New cards

Right-sentential form

The right-most derived sentential form is called the _______ ___________ _______.

73
New cards

Parse Tree

It is the graphical representation of a derivation. It is convenient to see how strings are derived from the start symbol, which becomes the root of the parse tree.

74
New cards

Terminals

In a parse tree, all leaf nodes are ____________.

75
New cards

Non-terminals

In a parse tree, all interior nodes are _____________.

76
New cards

In-order traversal

This traversal gives the original input string in a parse tree. A parse tree represents associativity and precedence of operators.

77
New cards

Deepest sub-tree

This is traversed first, allowing the operator in that sub-tree to get precedence over the operator in the parent nodes.

78
New cards

Ambiguity

The grammar is ___________ if it has more than one parse tree, either left or right derivation, for at least one (1) string.

79
New cards

Associativity and Precedence

No method can detect and remove ambiguity automatically. Still, it can be removed by either re-writing the whole grammar without ambiguity or by setting and following _____________ and __________________ constraints. These methods decrease the chances of ambiguity in a language or its grammar.

80
New cards

Associativity

When an operand has operators on both sides, the side on which the operator takes this operand is decided by the association of those operators. The operand will be taken by the left operator if the operation is left associative, and the right operator will take the operand if the operation is right-associative.

81
New cards

Left-associative

Its operations include Addition, Multiplication, Subtraction, and Division.

For example: id op id op id will be evaluated as (id op id) op id

Simply, 2 + 3 + 4 will be evaluated as (2 + 3) + 4

82
New cards

Right-associative

Its operations such as exponentiation will have the following evaluation in the same expression as above. For example: id op id op id will be evaluated as id op (id op id) Simply, 2 ^ 3 ^ 4 will be evaluated as 2 ^ (3 ^ 4)

83
New cards

Precedence

When two (2) different operators share a common operand, the precedence of operators decides which will take the operand.

84
New cards

Hierarchy of priorities

In Python, some operators are performed before others. It is called the ____________ __ ______________.

85
New cards

1

Priority: _____ Operator: ** or Exponentiation Operator

86
New cards

2

Priority: _____ Operator: Unary + and –, where unary operators located next to the right of the power operator bind more strongly. For example, 4 ** -1 equals 0.25.

87
New cards

3

Priority: _____ Operator: *, /, //, %

88
New cards

4

Priority: _____ Operator: Binary + (Addition) and – (Subtraction)

89
New cards

Name

It is a string of characters used to identify some entity in a program.

90
New cards

Letters, digits, and underscore (_)

Names in programming languages have the same form: starting with a letter followed by a string consisting of ________, ________, and ______________ characters.

91
New cards

Identifier

The term “__________” can be used interchangeably with “name”.

92
New cards

Underscore

The use of ____________ to form names was used in the 1970s-1980s but is now far less popular.

93
New cards

Camel notation or Camel case

In the C-based languages, the use of underscore has been replaced by __________ __________ or _________ __________, in which all of the words of a multiple-word name except the first are capitalized, as in myFirstCode. It is called “camel” as words written as names often have embedded uppercase letters, making it look like a camel’s hump.

94
New cards

Java and C#

The naming conventions of this programming languages have no length limit, with all characters being significant

95
New cards

C++

The naming conventions of this programming languages does not specify length limits, but implementors sometimes do

96
New cards

PHP

All the variable names in this programming language must begin with a dollar ($) sign

97
New cards

dollar ($)

All variable names in PHP must begin with a ________ sign

98
New cards

Perl

The special character at the beginning of a variable’s name in this programming language, such as $, @, or %, specifies its type

99
New cards

$, @, or %

In Perl, these special characters at the beginning of a variable’s name specifies its type.

100
New cards

Ruby

The special characters at the beginning of a variable’s name in programming language, such as @ or @@, specify that the variable is an instance or a class variable, respectively

Explore top notes

note
APHUG Unit 4 Summary
Updated 431d ago
0.0(0)
note
Vocabulary
Updated 1372d ago
0.0(0)
note
Conservation of Mass
Updated 1221d ago
0.0(0)
note
Chapter 12 - The Family
Updated 563d ago
0.0(0)
note
Chapter 9: Transitions
Updated 1022d ago
0.0(0)
note
Fluid Pressure
Updated 1264d ago
0.0(0)
note
APHUG Unit 4 Summary
Updated 431d ago
0.0(0)
note
Vocabulary
Updated 1372d ago
0.0(0)
note
Conservation of Mass
Updated 1221d ago
0.0(0)
note
Chapter 12 - The Family
Updated 563d ago
0.0(0)
note
Chapter 9: Transitions
Updated 1022d ago
0.0(0)
note
Fluid Pressure
Updated 1264d ago
0.0(0)

Explore top flashcards

flashcards
psych exam 5
58
Updated 699d ago
0.0(0)
flashcards
Chemistry Midterm #6
21
Updated 844d ago
0.0(0)
flashcards
HEAL 2600 Midterm **UPDATED**
117
Updated 470d ago
0.0(0)
flashcards
tale of 2 cities vocab 10-13
20
Updated 700d ago
0.0(0)
flashcards
Elements
30
Updated 415d ago
0.0(0)
flashcards
unit 1
62
Updated 1202d ago
0.0(0)
flashcards
psych exam 5
58
Updated 699d ago
0.0(0)
flashcards
Chemistry Midterm #6
21
Updated 844d ago
0.0(0)
flashcards
HEAL 2600 Midterm **UPDATED**
117
Updated 470d ago
0.0(0)
flashcards
tale of 2 cities vocab 10-13
20
Updated 700d ago
0.0(0)
flashcards
Elements
30
Updated 415d ago
0.0(0)
flashcards
unit 1
62
Updated 1202d ago
0.0(0)