Compiler Fundamentals: Translators and Lexical Analysis

1. Who is a translator?

A program that receives source code as input and produces output in another language.

2. Examples of Translators

Assemblers and compilers.

3. What is an Assembler?

A program that translates assembly language to machine language.

4. Programming Language Definition

Defined by its syntax and semantics.

5. Compiler Structure

Source code → Preprocessor → Compiler → Assembler code → Assembler → Object code → Linker → Executable code.

6. Lexical Analysis Stage

Reads characters

Read More

Understanding File Systems and Viruses

File Allocation Table (FAT)

The first file system used by Microsoft operating systems was FAT. It uses a file allocation table, which is an index listing the disk’s contents and recording file locations. Since a file’s data blocks aren’t always stored contiguously (fragmentation), the allocation table maintains the file system structure by linking these blocks.

FAT16, a 16-bit system, allows file names up to eight characters with a three-character extension. Windows 95, originally using FAT16, introduced

Read More

Computer Security: Threats, Standards, and Protection

What is Security?

Achieving a completely secure computer system is challenging. Reliability is key, focusing on building reliable rather than simply secure systems. A secure system hinges on three core aspects:

  • Confidentiality: Preventing unauthorized access to system objects and ensuring authorized entities do not leak information.
  • Integrity: Allowing only authorized modifications to objects in a controlled manner.
  • Availability: Maintaining accessibility of system objects for authorized users.

Logical

Read More

Memory Management: Address Spaces, Translation, and Allocation

Address Space

Address space: The illusion of infinite memory presented to a program, representing a process’s memory. Virtual memory creates this illusion, extending RAM to the physical drive, allowing larger programs to run by swapping inactive components to disk.

Memory Allocation

Malloc – Allocates memory and returns a pointer to the block without initializing it.

Calloc – Allocates and initializes memory to zero.

Realloc – Resizes previously allocated blocks, trimming or expanding as needed without

Read More

Mastering CSS: Stylesheets, Syntax, and Visual Enhancements

CSS Essentials

Why Use CSS?

  • Greater control over typography and layout
  • Separates style from structure
  • Allows styles to be stored externally, making documents smaller and easier to maintain

Types of CSS

  1. Inline Styles: Written within HTML tags
  2. Embedded Styles: Added within <style> tags in the <head>
  3. External Styles: Stored in separate .css files, linked to HTML
  4. Imported Styles: Styles from one CSS file imported into another

CSS Syntax

  • Rule Structure: Each rule has a selector and a declaration
  • Example:
Read More

Essential String Algorithms in C++

Find the Longest Common Prefix

#include <iostream>
#include <vector>
#include <string>

using namespace std;

string longestCommonPrefix(vector<string>& strs) {
    if (strs.empty()) return "";
    string prefix = strs[0];

    for (int i = 1; i < strs.size(); i++) {
        int j = 0;
        while (j < strs[i].length() && j < prefix.length() && strs[i][j] == prefix[j]) {
            j++;
        }
        prefix = prefix.substr(0, j);
       
Read More