[go: up one dir, main page]

0% found this document useful (0 votes)
38 views6 pages

Lecture1 4

This document discusses key aspects of programming languages including primitives, syntax, semantics, and where things can go wrong. It notes that each language provides primitive operations and mechanisms for combining them into expressions. It defines syntax as the rules for well-formed strings, static semantics as determining meaning of syntactically valid strings, and semantics as the meaning associated with syntactically correct expressions. Errors can occur at the syntactic, static semantic, or semantic levels. The goal is to learn a language's syntax and semantics to translate problem solutions into a form a computer can execute.

Uploaded by

Denisho Dee
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views6 pages

Lecture1 4

This document discusses key aspects of programming languages including primitives, syntax, semantics, and where things can go wrong. It notes that each language provides primitive operations and mechanisms for combining them into expressions. It defines syntax as the rules for well-formed strings, static semantics as determining meaning of syntactically valid strings, and semantics as the meaning associated with syntactically correct expressions. Errors can occur at the syntactic, static semantic, or semantic levels. The goal is to learn a language's syntax and semantics to translate problem solutions into a form a computer can execute.

Uploaded by

Denisho Dee
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Crea%ng

recipes
Each programming language provides a set of primi%ve opera%ons Each programming language provides mechanisms for combining primi%ves to form more complex, but legal, expressions Each programming language provides mechanisms for deducing meanings or values associated with computa%ons or expressions

Aspects of languages
Primi%ve constructs
Programming language numbers, strings, simple operators English words Programming language well get to specics shortly, but for example 3.2 + 3.2 is a valid Python expression English cat dog boy is not syntac%cally valid, as not in form of acceptable sentence

Syntax which strings of characters and symbols are well-formed

Aspects of languages
Sta%c seman%cs which syntac%cally valid strings have a meaning
English I are big has form <noun> <intransi%ve verb> <noun>, so syntac%cally valid, but is not valid English because I is singular, are is plural Programming language for example, <literal> <operator> <literal> is a valid syntac%c form, but 2.3/abc is a sta%c seman%c error!

Aspects of languages
Seman%cs what is the meaning associated with a syntac%cally correct string of symbols with no sta%c seman%c errors
English can be ambiguous
I cannot praise this student too highly

Programming languages always has exactly one meaning


But meaning (or value) may not be what programmer intended

Where can things go wrong?


Syntac%c errors Sta%c seman%c errors
Common but easily caught by computer Some languages check carefully before running, others check while interpre%ng the program If not caught, behavior of program unpredictable Crashes (stops running) Runs forever Produces an answer, but not programmers intent

Programs dont have seman%c errors, but meaning may not be what was intended

Our goal
Learn the syntax and seman%cs of a programming language Learn how to use those elements to translate recipes for solving a problem into a form that the computer can use to do the work for us Computa%onal modes of thought enable us to use a suite of methods to solve problems

You might also like