Understanding Computer Programs

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Match each programming language generation with its primary characteristic:

First Generation (1GL) = Machine-level language using binary code Second Generation (2GL) = Assembly language using mnemonic abbreviations Third Generation (3GL) = High-level languages with control structures Fourth Generation (4GL) = Non-procedural languages focused on databases and application generation

Match the programming task with the most suitable programming language:

Web Front-End Development = JavaScript Mobile App Development (Android) = Kotlin Data Science and Machine Learning = Python System Programming = C

Match each programming language paradigm with its defining characteristic:

Imperative/Procedural = Breaks problems into procedures or blocks of code that perform one task each Functional/Applicative = Uses mathematical functions and avoids assignment statements Logic/Declarative = Uses facts and rules to represent information and infer solutions Object-Oriented = Revolves around entities or objects that are part of the problem

Match the computer hardware trend with the corresponding generation of computers:

<p>First Generation = Vacuum tubes Second Generation = Transistors Third Generation = Integrated circuits Fourth Generation = Microprocessors</p> Signup and view all the answers

Match each type of semantic analysis with its description:

<p>Static Semantics = Defines restrictions on the structure of valid texts that can be checked at compile time Dynamic Semantics = Strategy by which expressions are evaluated to values during runtime Operational Semantics = Steps necessary to idealized execution of a program, as it relates to the language Denotational Semantics = Expressing the meaning of a program as abstract mathematical structures</p> Signup and view all the answers

Match the following concepts with their descriptions in programming languages:

<p>Scope = The portion of the program code for which the variable’s name has meaning and is visible Syntax = The set of rules that define what the various combinations of symbols mean in a programming language Semantics = It emphasizes the interpretation of a program so that the programmer could understand it in an easy way or predict the outcome of program execution Binding = Describes how a variable is created and used or bound, by and within the given program</p> Signup and view all the answers

Match each language evaluation criteria with its definition:

<p>Expressivity = The ability of a language to clearly reflect the meaning intended by the algorithm designer Readability = The ease with which programs can be read and understood Portability = The ability of a language to be implemented on a variety of computers Orthogonality = A relatively small set of primitive constructs can be combined in a relatively small number of ways</p> Signup and view all the answers

Match each declaration type with its description:

<p>Explicit Declaration = A statement that lists data object names and defines them as a specific type Implicit Declaration = A declaration that holds when no explicit declarations are given Type Checking = Allows programmers for static type checking i.e., checking the types of data objects at compile time rather than at execution time Storage Management = Serves to indicate the desired lifetime of the data object that creates it possible to use a more effective storage management process during program execution</p> Signup and view all the answers

Match each type of programming language implementation with its characteristic:

<p>Compilation = Programs are translated into machine language for fast execution Interpretation = Programs are executed by another program (an interpreter) without translation Hybrid Implementation = High-level programs are translated to an intermediate language for easy interpretation Just-in-Time (JIT) = Subprograms are compiled the first time they are called</p> Signup and view all the answers

Match the following types of program scope with what they limit declaration too:

<p>File Scope = If the declaration of an identifier is outside any block or list of parameters, it has file scope Block Scope = If the declaration of an identifier is inside a block, it has block scope and the scope ends with the end of the block Function Scope = If the declaration of an identifier is inside a list of parameters in function definition, it has function scope, which ends with the end of function definition Function Prototype Scope = If the declaration of identifier appears within the list of parameters of a function prototype, which is not part of function definition</p> Signup and view all the answers

Match the term with its definition.

<p>Computer program = A sequence of instructions written using a computer programming language to perform a specified task by the computer. Programming language = A computer language that is used by programmers to communicate with computers. Compiler = A program that translates source code into machine code. Interpreter = A program that executes high-level language statements directly.</p> Signup and view all the answers

Match the generation of programming languages with how programmers interact with the computer:

<p>1st Generation = Programmers directly used 0's and 1's to program computers. 2nd Generation = Programmers started to use symbolic names and mnemonics. 3rd Generation = Programmers could focus on the problem to be solved. 4th Generation = Programmers describe what needs to be solved rather than how to solve it.</p> Signup and view all the answers

Match the functional language in the options to the description.

<p>Erlang = Designed for concurrent and distributed systems. Used in telecommunications. LISP (including Scheme and Clojure) = One of the earliest functional languages used in artificial intelligence. Haskell = A purely functional language that features lazy evaluation. Scala = Combines object-oriented and functional programming features.</p> Signup and view all the answers

Match the logic language to the description.

<p>Prolog = Logic programming language suited for tasks involving symbolic reasoning and manipulation, such as natural language processing. Mercury = A purely declarative, logic/functional programming language the allows creating efficient, reliable, and maintainable code in various applications. Logtalk = An object-oriented extension of Prolog, Logtalk adds modularity, encapsulation, and inheritance. Datalog = A subset of Prolog, Datalog is a rule-based language focused on deductive database queries and reasoning.</p> Signup and view all the answers

Match how languages handle trade-offs with the definition.

<p>Reliability = This takes into account the time required for malfunction detection and reconfiguration or repair Expandability = Measures the computer system's ability to conveniently accommodate increased requirements by higher speed or by physical expansion Programmability = balance between programming simplicity and hardware complexity Maintainability = Repair should be readily accomplished during ground operation.</p> Signup and view all the answers

Match the following

<p>A good programming style = semantics should follow directly from syntax Languages differ = In terms of what type of projects they are most practical for Logic behind paradigms = Each has a set of ideas that a programming language can use to perform tasks. Top-down approach = The problem is broken down into smaller units.</p> Signup and view all the answers

Match the language with its use.

<p>HTML = Not technically a programming language Java = General-purpose PHP = server-side scripting python = artificial intelligence</p> Signup and view all the answers

Match the description to whether is it syntax or semantics

<p>Syntax = errors are handled at compile time Semantics = errors are difficult to find and encounters at the runtime</p> Signup and view all the answers

Macth the description to the variable.

<p>The scope of a variable = describes where in a program's text, the variable may be used The extent of a variable = describes when in a program's execution a variable has a value Static scope = each reference to a variable is statically bound to a particular variable declaration Dynamic scope = each variable declaration extends its effects over all subsequent statement execution, until a new declaration for identifier is encountered</p> Signup and view all the answers

Match the following definitions.

<p>Language Generator = A device that can be used to generate the sentences of a language. Language Recognizer = Part of a compiler that determines whether given programs are syntactically correct. Parsers = analyzers, which syntax. Determines what is the structure. Parsing = determining its grammatical structure with respect to a given grammar</p> Signup and view all the answers

Macth the phase with the function.

<p>Lexical analysis = converts characters in the source program into lexical units Syntactic analysis = transforms lexical units into parse trees Semantics analysis = check for errors hard to detect during syntactic analysis Code generation = Machine code is generated.</p> Signup and view all the answers

Match the generation to the example.

<p>First Generation = ENIAC, UNIVAC, Mark –I Second Generation = IBM-7000 Third Generation = IBM-307 Fourth Generation = CRAY 2</p> Signup and view all the answers

Match is appropriate

<p>Fortran = Designed for scientific and engineering computations Cobol = application, Cobol is used primarily for data processing Ada = safety-critical and real-time systems Pascal = aimed at encouraging good programming practices.</p> Signup and view all the answers

Match the description.

<p>The program counter = is often the fastest register in the machine</p> Signup and view all the answers

Matching between the name and the type of programming language

<p>A general-purpose = C++ data definition language = SQL mark up language = HTML Dynamic = PHP</p> Signup and view all the answers

Match the term with its description

<p>Denotational = Determining the meaning of a program as elements of a number of abstract mathematical structures Operational = Determining the meaning of a program in place of the calculation steps which are necessary to idealized execution Axiomatic = The definition of a program defining indirectly, by providing the axioms of logic to the characteristics of the program Static semantics = the static semantics essentially include those semantic rules that can be checked at compile time</p> Signup and view all the answers

Match how declarative languages allow.

<p>ASP = Declarative language used to solve complex search problems Prolog = a logic programming language suited for tasks involving symbolic reasoning Mercury = Offers strong typing, mode, and determinism systems for creating efficient, reliable, and maintainable code in various applications. Datalog = is a rule-based language focused on deductive database queries and reasoning,</p> Signup and view all the answers

What are the benefits of choosing a certain programming language

<p>Project goals = Clarify and follow through on the objectives of your project and list the features Applicability = Some are more suited to specific types of projects Development speed = Enable quick prototyping and iteration Community Support = Solve problems quickly and provide resources</p> Signup and view all the answers

When it comes to code that is written a lot for web development match what type of language.

<p>For Front-end = Javascript, and CSS For server-side = Python, with Django or Flask, For Full stack = Javascript with frameworks like Node.js, Mobile development code = use java or kotlin</p> Signup and view all the answers

Flashcards

Computer Program

A sequence of instructions written to perform a specific task on a computer.

Programming Language

A language used by programmers to communicate instructions to a computer.

Computer Programming

The process of writing code to instruct a computer how to perform specific tasks.

First Generation Language (1GL)

Machine-level programming language used in first-generation computers, using binary code.

Signup and view all the flashcards

Second Generation Language (2GL)

Programming languages that use mnemonic abbreviations and symbolic names.

Signup and view all the flashcards

Third Generation Language (3GL)

High-level languages that allow control structures based on logical data objects.

Signup and view all the flashcards

Fourth Generation Language (4GL)

Non-procedural languages focused on database and query languages, and program or application generators.

Signup and view all the flashcards

Fifth Generation Language (5GL)

Programming languages based on solving problems using constraints, associated with AI.

Signup and view all the flashcards

Expressivity

Being able to clearly reflect the meaning intended by the programmer.

Signup and view all the flashcards

Well-Definiteness

Language syntax and semantics are free of ambiguity, internally consistent and complete.

Signup and view all the flashcards

Data Types and Structures

A language supports a variety of data values and non-elementary collections

Signup and view all the flashcards

Readability

The ease with which programs can be read and understood.

Signup and view all the flashcards

Overall Simplicity

The overall simplicity of a programming language strongly affects its readability.

Signup and view all the flashcards

Modularity

The language's support for sub-programming and the language's extensibility

Signup and view all the flashcards

Portability

A language which is implemented on a variety of computers.

Signup and view all the flashcards

Programming Language Implementation

A system for executing computer programs, including compilation, interpretation, hybrid and JIT.

Signup and view all the flashcards

Compilation

Translating programs into machine language for direct computer execution.

Signup and view all the flashcards

Interpretation

Having the computer itself act as a software simulation that executes a program.

Signup and view all the flashcards

Hybrid Implementation

Compromise between compilers and pure interpreters, translating to an intermediate language.

Signup and view all the flashcards

Syntax

The form of expressions, statements, and program units in a programming language.

Signup and view all the flashcards

Semantics

Meaning of expressions, statements and program units.

Signup and view all the flashcards

Syntax Analysis

A task performed by a compiler which examines whether the program has a proper derivation tree or not.

Signup and view all the flashcards

Static Semantics

Checking that identifiers are used in the appropriate context (e.g. not adding an integer to a function name).

Signup and view all the flashcards

Dynamic Semantics

Defines the strategy by which expressions are evaluated to values.

Signup and view all the flashcards

Declaration

Provides data about the name and type of data objects to the programming language translators.

Signup and view all the flashcards

Explicit Declaration

Statement in a program that list data object names and defines that they are a specific type.

Signup and view all the flashcards

Implicit Declaration

Declaration that holds when no explicit declarations are given.

Signup and view all the flashcards

Scope

Range of Program statements that access that variables.

Signup and view all the flashcards

Static Scope

Defines the scope of a variable in terms of lexical structure of a program.

Signup and view all the flashcards

Dynamic Scope

Defines the scope of a variable in terms of program execution.

Signup and view all the flashcards

Referencing Environment

The collection of variables which can be used in a static scoped langauge.

Signup and view all the flashcards

Binding

How a variable is created abd used by and within the program.

Signup and view all the flashcards

Dynamic Binding

Mapping a message to a specific sequence of code (method) at runtime.

Signup and view all the flashcards

Static Binding

Relates to variables being declared

Signup and view all the flashcards

Study Notes

Introduction to Computer Programs

  • A computer program comprises a sequence of instructions.
  • These instructions are written in a computer programming language.
  • They instruct the computer to perform a specified task.
  • Key terminology includes "sequence of instructions" and "computer programming language".
  • Computer programming instructs a computer, application, or software program.
  • A programming language is a set of instructions used in order to communicate with computers.
  • Programming languages serve as a bridge, translating human thoughts into computer instructions.

How Programs Work

  • A program instructs a computer to perform tasks by providing a sequence of steps, similar to how humans give directions.
  • Program instructions can be called program source code.
  • Computer programming can also be called program coding.
  • Without programs, computers are inactive. It's actually programs that make computers active.

Classification of Programming Languages (Generations)

  • Computer generations evolve with changing technologies, leading to miniaturization, increased speed and memory, and improved reliability.
  • Generations are based on evolving chip technology, not specific time frames.
  • Five generations are characterized by electrical current flowing through processing mechanisms:

Five Generations of Computers

  • Vacuum tubes were the hallmark of the first generation.
  • Transistors defined the second generation.
  • Integrated circuits marked the third generation.
  • Microprocessors characterized the fourth generation.
  • Artificial intelligence is the foundation of the fifth generation.

First Generation Languages (1GL)

  • Machine-level language is an early form of programming for first-generation computers, operating on a binary level (sequences of 0s and 1s).
  • No translators were used.
  • Binary programming directly reflects the hardware structure, controlling actions in processing, control, and memory units.
  • Binary programming on the flip-flop level was deemed troublesome and impractical for complex problems.

Second Generation Languages (2GL)

  • Assembly languages introduce symbolic names and commands, simplifying programming compared to binary.
  • Assemblers translate assembly language to machine code.
  • Assembly languages reflect the register level hardware structure.
  • Instruction set determines an assembly language scope.
  • Linking mechanisms enabled separate code assembly, with beginnings of program structuring.

Third Generation Languages (3GL)

  • Allow control structures based on logical data objects, offering machine-independent specifications for data, functions, and processes.
  • Programmers can focus on problems instead of hardware structure.
  • Four programming language groups exist: imperative, declarative, object-oriented, and functional.

Fourth Generation Languages (4GL)

  • Deal with databases/query languages and program or application generators.
  • Software packages necessitate easy-to-use control mediums for non-specialists.
  • Users specify what needs solving instead of how, unlike procedural languages.
  • Interactive programming environments are an integral part.

Fifth Generation Languages (5GL)

  • Solve problems based on constraints rather than programmer algorithms, enabling computers to "think".
  • Artificial Intelligence and Fuzzy Logic become a reality.
  • Computers learn problem-solving through constraints.
  • Parallel processing and superconductors are used.
  • Machines make decisions, which reduces programmer effort, and is easier to learn than 3GL or 4GL.

Computer Capabilities by Generation

  • First Generation: Room-sized, slow (hundreds of instructions per second), costly, machine/assembly language, unreliable (failure per second), high power consumption.
  • Second Generation: Smaller than first, faster (thousands of instructions per second), less costly, assembly/high-level languages (FORTRAN, COBOL, BASIC), failure per day, low power.
  • Third Generation: Smaller than second (mini-computers), faster (millions of instructions per second), less costly, high-level languages (Pascal, C, etc.), failure per week, low power.
  • Fourth Generation: Typewriter-sized microcomputers, very fast (tens of millions of instructions per second), low cost, high-level languages (C++, SQL, etc.), failure per month, low power.
  • Fifth Generation: Credit card-sized microcomputers, billions of instructions per second, less costly than fourth, AI languages (LISP, PROLOG, etc.), low power.
  • First Generation: Vacuum tubes, magnetic drum memory, magnetic tape secondary memory, punched card input/output.
  • Second Generation: Transistors, magnetic core memory, magnetic tape/disk secondary memory, punched card input, punched card/print output.
  • Third Generation: Integrated circuits, magnetic core primary memory, magnetic tape/disk secondary memory, key-to-tape/disk input, printed/video output.
  • Fourth Generation: LSI microprocessors, semiconductor memory (RAM/ROM/cache), magnetic/floppy/optical disk secondary memory, keyboard input, video/audio/print output.
  • Fifth Generation: ULSI parallel processing, optical/magnetic disk memory, speech/tactile input, graphic/voice output.

Reasons to Study Programming Language Concepts

  • Enhanced ability to express ideas/algorithms.
  • Improved background for language choice.
  • Better at learning new languages.
  • Understanding implementation significance.
  • Better use of existing languages.
  • Advancement of computing.

Application Domain of Programming Languages

  • Prerequisites for developing a programming language, is to have a clear understanding of the application domain.
  • Application domain: the section of an organization for which application software is developed.

Scientific Applications

  • Characterized by manipulating numbers and arrays, using mathematical and statistical principles as a basis for algorithms.
  • Algorithms: statistical significance tests, regression analysis and numerical approximations for the solutions of differential and integral equations.
  • Languages: FORTRAN, Pascal, etc.

Data Processing Applications

  • Concerned with the creation, maintenance, extraction, and summarization of data in records and files.
  • COBOL is commonly used.
  • Characterized by facilities for producing elaborate reports, precise ways of describing/storing decimal numbers and characters, and decimal arithmetic operations.

Text Processing Applications

  • Involves manipulating natural language text rather than numbers.
  • SNOBOL and C language have strong text processing capabilities.

Artificial Intelligence Applications

  • Programs designed to emulate intelligent behavior.
  • Includes game-playing algorithms, natural language understanding programs, robotics, and expert systems.
  • LISP has been the primary AI language, along with PROLOG.
  • More Al applications are written in Java, C++ and Python.

Systems Programming Applications

  • Developing programs that interface the computer system with the operator.
  • Examples include compilers, assemblers, input-output routines, program management and schedules.
  • Ada, C, and Modula 2 are examples of programming languages used.

Web Software

  • Supported by a multitude of languages.
  • Markup languages (HTML) languages, to general-purpose programming languages (Java).
  • Dynamic web content requires computation capabilities.
  • Markup languages use: XHTML for Markup, JavaScript/PHP for Scripting, and Java/Python for general purposes.

Language Evaluation Criteria

  • Expressivity: reflects the ability to show the meaning intended.
  • Well-Definiteness: syntax and semantics free of ambiguity.
  • Data types and structures support a variety of data values.
  • Readability is the ease with which programs can be read and understood.
  • Overall Simplicity affects readability.
  • Modularity includes language's support for sub-programming and extensibility.

Additional Language Evaluation Criteria

  • Input-Output facilities: support for files and database/info retrieval functions.
  • Portability: machine independence.
  • Efficiency: fast compilation and execution.
  • Orthogonality: relatively small set of primitive that can be combined to build the control and data structures.
  • Pedagogy: easier to teach and to learn.
  • Generality: means that a language is useful in wide range of programming applications

Imperative Programming Languages

  • Describe a sequence of commands a machine executes to produce an outcome, focusing on variable and memory.
  • Examples:
  • C is used for system programming and hardware manipulation due to its low-level capabilities and efficient memory management.
  • Fortran supports numerical and array-based operations.
  • Cobol is used primarily for applications with an emphasis on readability and maintainability.
  • Ada is known for its strong type safety and run-time checks, ensuring code reliability and correctness.
  • Pascal enforces structured programming and strong typing.

Object-Oriented Programming Languages

  • Use objects, encapsulating data and behavior, to create reusable, modular code.
  • Java follows the "write once, run anywhere" philosophy, which develops portable, secure, and robust apps.
  • C++ offers classes, inheritance, and polymorphism to achieve efficient memory management and code reuse.
  • C#, developed by Microsoft, builds Windows applications and games due to its integration with the .NET framework.
  • Python's versatile nature, syntactical simplicity, and extensive libraries make it an attractive choice for various applications.
  • Ruby's expressive and readable syntax combined with an object-oriented nature make it a popular choice for web application development.

Functional Programming Languages

  • Based on mathematical functions, emphasizing immutable values and the absence of side effects easing parallel processing.
  • Haskell: a purely functional language which helps algorithmic, mathematical, and parallel computing.
  • Scala: combines object-oriented and functional programming.
  • ML: facilitating safe and efficient program execution in language compilers and theorem provers.
  • Erlang is functional in nature with lightweight and message-passing concurrency suitable for telecommunication applications and fault-tolerant systems.
  • Lisp characterized by its flexible and minimal syntax using artificial intelligence research and symbolic computation.

Logic-Based Programming Languages

  • Use declarative statements, expressing relationships and rules between facts, to enable reasoning and problem-solving using artificial intelligence.
    • Prolog is a logic programming language suited for tasks involving symbolic reasoning and manipulation, such as natural language processing.
    • Mercury offers strong typing, mode, and determinism systems creating efficient and reliable code.
    • Logtalk adds modularity, encapsulation, and inheritance, creating reusable and maintainable programs.
    • Datalog is a limited form of Prolog that is focused on deductive database queries and reasoning, and offering efficient evaluation strategies

Picking the Right Programming Language

  • Choosing the correct programming language depends on various factors:
  • Project goals: Listing the features the language should support determines required capabilities.
  • Application type: Selecting a language better suited for web, mobile, or data science applications helps determine target environment and platform.
  • Development speed: Enabling rapid development, or allowing for quick prototyping and iteration enables quick tooling.
  • Developer experience: The team's proficiency affects the quality of the final product.
  • Performance and scalability: Ensure efficient processing time and memory usage.
  • Community support: Finding help solve technical challenges quickly can lead to good documentation.
  • Maintenance and long-term support: Ensure continued availability of updates, bug fixes, and security patches.

Programming Language Suitability for Different Projects

  • Web development: HTML, CSS, and JavaScript are essential for the front end of user website.
  • Server-side or back-end development relies on Python (with Django or Flask), Ruby (with Ruby on Rails), PHP (with Laravel or Symfony), and Java (with Spring or JavaServer Faces).
  • Mobile app development is achieved with Java or Kotlin for native Android apps, Swift or Objective-C for native iOS apps, or React Native/Flutter for cross-platform apps.
  • Data science and machine learning use Python/R/Julia for data analysis, visualization, and machine learning.
  • Hardware-level or system-level projects can be achieved with C/C++/Rust with the provision of memory management and system programming.

Programming Language Paradigms

  • Programming paradigms guide problem-solving thought, influencing program genres and languages.
  • The paradigm adheres to the actual methodology of a programming language.
  • Paradigm: a model or world view and is a set of ideas language uses to perform tasks.

Imperative/Procedural Programming Languages

  • These are procedures, or blocks of code that perform one task each which are influenced by the von Neumann computer architecture.
  • Suitable for small programs with low complexity.
  • Consists of assignment statements, data structures and type binding; active procedures manipulate passive data objects.
  • Calculator programs can these languages and each of the operations can be developed as separate procedures.

Functional/Applicative Programming Languages

  • Syntax is related to the formulation of mathematical functions.
  • The solution is broken down into functional units that stitched together to form solution.
  • Payroll processing is a good example of the structure where you can maintain employee data, salary, and payments easier.

Logic/Declarative/Ruled Based Programming Languages

  • Uses facts and rules to represent information, a logical inference processes the rules to produce results, and the solution is in logical units instead of functional units.
  • School management systems can split up functions for teachers, assistants, and coordinators where each user has their own interface and permissions.

Object-Oriented Programming Languages

  • Uses data and procedures forming to form a syntactical unit.
  • The solution revolves around entities/objects that are part of problem and deals data storage, object behaviors, and interactions for a cohesive solution.
  • Payroll management system can deal with the data of employees, their leave structure, etc to build the structure.

Scripting Languages

  • A programming language automates the execution of tasks using run time.
  • Scripting languages are interpreted at runtime.
  • Simplify text processing making them suited to generating HTML pages.

Methodologies:Top-down and Bottom-up

  • The top down breaks the problem down into smaller units, and down into even smaller units that allow self-sufficient functionality.
  • In bottom-up , components are then interconnected to get higher level components.

Programming Language Trade Offs

  • Reliability assesses malfuction detection.
  • Expandability increases computer system's requirements.
  • Programmability balance programmer simplicity and hardware complexity.
  • Compatibility to develop between computer and interfaces, software, etc

Language Implementation

  • Compilation, interpretation, hybrid, and just-in-time languages may be used.
  • Compilation translates programs into machine language for very fast execution.
  • Interpretation has run-time errors than can be displayed.
  • Hybrid is a compromise between compilers and pure interpreters for a translated source language.
  • Just-in-time compiles subprograms coded the first time that are called and keep the version for subsequent calls.

Syntactic Analysis

  • Task to provide a concise description of a programming language .
  • New programming languages are subjected to a period of scrutiny by potential users, these are the initial evaluators.
  • the structure of these code bases examines the syntax and semantics.

Syntactic Analysis Explained

  • Language can be natural(English) or artificial (Java) that have a set of strings of characters from an alphabet, also called statements..
  • English has a complex collection of rules to specify it's syntax while Java is syntactically simpler.
  • The Syntax' job is to simply check for errors during compiling.

Language Recognizer

  • The syntax analysis part of a compiler is a recognizer for the language it translates.
  • Syntax analyzer determines whether given programs are syntactically correct(legal sentences).
  • Language recognizer acts like a filter, separating legal sentences.

Language Generator

  • Generator helps read and understand content.
  • If used during compiling the programmer notes if the compiler accepts.
  • This requires the programmer to determine if it's correct by comparing it with the generator.

Parsing - Grammar

  • In linguistics, parsing describes the process of determining its grammatical structure and formal languages.
  • A parser is one of the components that checks for correct syntax using parse trees in computer science.
  • Parsing determines how the input can be derived from the start symbol of the grammar:
  • Top-down parsing finds leftmost derivations, expanding alternative right-hand-sides of grammar rules.
  • Bottom-up parsing locates most basic elements and rewriting them.

Syntactic Ambiguity

  • Arises not from the range of meanings of single words, but from the relationship between the words and clauses of a sentence, and the sentence structure implied thereby.

Semantic Analysis

  • Verifies the program consists of tokens arranged in a syntactically valid combination, as well as is semantically valid.
  • Variables, functions, classes, etc. must be properly declared, access controls, etc. must be respected.
  • The compiler needs to know it understands it that is easy to read and used and that every step in that program is viable and correct..
  • Syntax-directed semantics maps syntactical to computational model, to ensure proper task acknowledgment.

Operational Semantics

  • Meaning in a program is based on necessary calculation steps for execution.

Denotational Semantics

  • Focus on the meaning based on elements of a number of abstract mathematical structures.

Axiomatic Semantics

  • Is a logic that defines what it will be.

Static Semantics

  • Defines structure of valid texts hard to express in syntactic formalisms

Dynamic Semantics

  • After specifying data, the machine is instructed to perform operations on the data.

Semantic Analyzer

  • Gathers type information.
  • The Semantic analyzer is expected to recognize:
    • Type mismatch.
    • Undeclared variable.
    • Reserved identifier misuse.
    • Multiple declaration of variable in a scope.
    • Accessing an out of scope variable.
    • Actual and formal parameter mismatch.

Semantic Analysis Functions

  • Type Checking ensures data types are used in a way consistent with their definition.
  • Label Checking ensures used in references.
  • Flow Control Check that these are used properly and safely.

Fundamental Semantic Issues (Variables, Names, Words)

  • In programming, the language uses range from a basic set of values to complex one that represent the given name.
    • The value it holds changes or varies depending on the given condition.

Common Language Differentiations

  • Differentiates between integers, non-integers, and characters
  • Has Elementary level (such as Integers) which are most common primitives supported in code.
  • Also the code can be translated by the compiler with , +, * , /
  • Has Structured levels with are structures like arrays, records, and sets as dynamic.

Abstract and Structured Type Levels

  • Structured level: Most high-level programming languages allow the definition of structured types which are based on simple types.
  • Abstract level: It Programmer defined abstract data types are a set of data objects with declared operations on these data objects.

Naming Rules

  • Programming variables and constants commonly take multiple-character names e.g. COST or total.
  • Many enforce language such as not starting with a digit (0-9) , or allow _ underscore in a character.
  • Some require certain case levels that can lead to internal errors.

Binding Explained

  • Binding describes how a variable is created and used (or "bound") by and within the given program, and, possibly, by other programs, as well.
  • There are two types of binding; Dynamic, and Static binding.

Dynamic vs Static Binding

  • is the process known as Dynamic Dispatch) is the process of mapping a message to a specific sequence of code (method) at runtime.
  • Static It occurs first before run time and remains unchanged throughout program execution
  • Scope is a lexical aspect of a variable as well.
  • Each variables in particular must have their function and scope.

Scopes

  • Static :Uses the source code with the given implicit and explicit definitions.
  • Dynamic: Each variable has a certain effect, which gives new results with running sub sequential scopes.

Additional Scope Facts

  • The scope of a variable can be either local or global.
  • Four types of scopes are defined in C language (i) File scope: outside any block or list of parameters, (ii) Block scope: the scope ends with the end of the block. (iii) Function scope: inside a list of parameters where the scope ends. (iv) Function prototype scope: the scope ends with the end of declaration.

Referencing

  • The referencing environment - collection of variables that can be used.
  • In a static scoped language, one only references variables in the static reference environment.

Syntax vs Semantics

  • Syntax refers to code in writing structure.
  • Semantics has error related issues during the run time of the coding phase.
  • If a code is correct but doesn't give what you will, that's a fault semantic coding issue.

Declarations

  • A declaration gives us the name and object details to the programming codes.
  • Also defines the binding of the data with and its lifetime.
  • The purpose of object declarations is to check that the objects are following a certain parameter in types in all kinds of program execution.

Declaration Details

  • Choice of storage representation, and other types declared for objects.
  • Types are also polymorphic operations.
  • Two types are explicit stating with clear names, and implicit declarations without names assigned.
  • Can also be a variable ,scope to define what can show .

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser