review last time programming language history
play

Review Last Time: Programming Language History 50s, 60s: Exciting - PDF document

Review Last Time: Programming Language History 50s, 60s: Exciting Time Invention of: assemblers, compilers, interpreters, first high- CSCI: 4500/6500 Programming level languages, structured programming , abstraction, formal syntax,


  1. Review Last Time: Programming Language History � 50s, 60s: Exciting Time » Invention of: assemblers, compilers, interpreters, first high- CSCI: 4500/6500 Programming level languages, structured programming , abstraction, formal syntax, object-oriented programming, LISP, program Languages verification � 70s, 80s, 90s: Boring Time » Refinement of earlier ideas, better implementations, making theory more practical Natural and Programming Languages » A few new/refined ideas: functional languages, data abstraction, concurrent languages, data flow, type theory, etc. Syntactic Structures � 00+s: Party Time » New Environment: Internet, large scale distributed computing, the grid, Java, C#, Maria at UGA � Alan Kay: “The best way to predict the future is to invent it.” Portions of this lecture thanks to: Prof David Evans, U Virginia and Prof Spencer Rugaber, GTech 1 2 Maria Hybinette, UGA Maria Hybinette, UGA This Week: Programming Language Implementation Formal System & Language Source program Scanner Formal System: Lexical � This week and next we Analyzer � Set of symbols: Lexical units, token stream will talk about the first » the primitives Parser two phases of Syntax � Set of rules for manipulating symbols compilation, namely, Analyzer Parse tree Intermediate » Rules of production scanning and parsing. Code Generator Symbol Optimizer What is a Language (theoretically)?: Table (optional) Semantic Analyzer � Formal System + (mapping of sequence of symbols and their meaning) Abstract syntax tree or other intermediate form Code Generator Machine Language Computer 3 4 Maria Hybinette, UGA Maria Hybinette, UGA Linguist’s Language What are languages made of? � Description of pairs (S, M) � Primitives » S is the “sound”, or any kind of surface forms, and » The smallest units of meaning, or the simplest surface forms ( pronunciation). » M is the meaning. � Means of Combination (all languages have � Language specifies properties of sound and these) meaning and how they relate (Aristotle characterize language as a system than links » Like Rules of Production for Formal Systems sound and meaning) » Creates new surface forms from the ones you have � Means of Abstraction (all powerful languages � Aristotle: 384-322 B.C. Greek have these) philosopher, father of deductive logic, » Ways to use simple surface forms to represent Meta physics, “Physics”, teacher of complicated ones Alexander the Great. 5 6 Maria Hybinette, UGA Maria Hybinette, UGA

  2. What is longest word in the English language? Creating longer words � Supercalifragilisticexpialidocious � Floccinaucinihilipilification » Popularized by Mary Poppins » Oxford English Dictionary, 34 letters » The estimation of something as worthless, the act of estimating something as useless » Nonsense word meaning fantastic � Pneumonoultramicroscopicsilicovolcanoconiosis � Anti-floccinaucinihilipilification » Factious word to mean: 'a lung disease caused by the » The estimation of something as not worthless inhalation of very fine silica dust’, 45 letters � Antifloccinaucinihilipilification-or » 207,000+ mitochondrial DNA » The one who does the act of not rendering useless � Floccinaucinihilipilification » The estimation of something as worthless (usage dated � Anti- antifloccinaucinihilipilification since 1741) » 27 letters, longest non-technical word according first edition of Oxford English Dictionary (floccus - I don’t care, I don’t make wool, naucum - little value, nihilum - nothing, pilus - a bit or whit, something small and insignificant 7 8 Maria Hybinette, UGA Maria Hybinette, UGA Natural Languages What are languages made of? � Are there any non recursive languages? � Primitives � No, we would run out of things to say » The smallest units of meaning, the “ simplest” surface forms. Lexemes lowest level of meaning. � So, we only need to start with a few building � Means of Combination (all languages have these) blocks and from there we can create infite » Creates new surface forms from the ones you have things » Sentences and works on word parts too! � Means of Abstraction (all powerful languages have MU! these) » Ways to use simple surface forms to represent more complicated ones » Example: prounouns: “I in English; or Phom, Dichan is the polite way of saying I in Thai depending on gender (Dichan for females). 9 10 Maria Hybinette, UGA Maria Hybinette, UGA Primitives/Tokens Means of Combination � Described by regular expressions » First phase of compilation process converts strings/lexemes of � Allow us to say infinitely many things with a the programming language to tokens (a representation of the finite set of primitives lexeme in the computer) � We can create sentences using primitives – Example: letter (letter | digit ) * � Regular expression (over some given alphabet) » In English “words” are really not the primitives » 3 operations: since we can create longer words – Concatenation � How can we describe “means of – Repetition combinations” the syntax of a language? – Alternation (Choice) » Computer Scientists: � Corresponds to type-3 grammars in Chomsky hierarchy and is the most restrictive A -> a, A-> aB or A -> Ba – Backus-Normal-Form -> Backus- Naur -Form (BNF) » We will talk about semantics later � Many utilities exist that use regular expressions » grep (global regular expression print) » Lex/flex, turn a regular expression of tokens into a scanner, so they are generators 11 12 Maria Hybinette, UGA Maria Hybinette, UGA

  3. BNF Example BNF Example Sentence ::= Noun-Phrase Verb-Phrase Sentence ::= Noun-Phrase Verb-Phrase Non-Phrase Noun-Phrase ::= Maria | Microsoft Noun-Phrase ::= Noun | Adjective Noun-Phrase Verb-Phrase := Rocks | Jumps Noun := Maria | Microsoft | Home | Feet Adjective := Yellow | Smelly Verb-Phrase := Skips | Runs | Rocks � What are the terminals? » Maria, Microsoft, Rocks, Jumps � Now we can express infinitely many things with this little language… � How many different things can we express with this language? » 4 » … but only 1 is true 13 14 Maria Hybinette, UGA Maria Hybinette, UGA Definition of Languages BNF and Context Free Grammars � Recognizers � Context Free Grammars » Reads input string and accepts or rejects if the » Developed by Noam Chomsky in the 1950s string is in the language » Define a class of languages called context-free � Generators languages (type 2) � Backus Naur Form » Generate sentences of a language » Example: Grammars are language generators » Equivalent to context-free grammars » BNF is a meta-language used to describe antother language 15 16 Maria Hybinette, UGA Maria Hybinette, UGA BNF Basics BNF details A BNF grammar consists of four parts: � The tokens are the smallest units of syntax » Strings of one or more characters of program text � Tokens: tokens of the language, the terminals » They are atomic: not treated as being composed from � Non-terminal symbols: BNF abstractions in <> smaller parts brackets � The non-terminal symbols stand for larger pieces of syntax � A start symbol » They are strings enclosed in angle brackets, as in <NP> � Grammar: The set of productions or rules » They are not strings that occur literally in program text » The grammar says how they can be expanded into strings of tokens � The start symbol is the particular non-terminal that forms the root of any parse tree for the grammar 17 18 Maria Hybinette, UGA Maria Hybinette, UGA

  4. BNF Productions (Grammar) Alternatives � The productions are the tree-building rules � The BNF grammar can give the left-hand side, the separator ::= , and then a list of possible � Each one has a left-hand side, the separator ::=, and a right-hand side right-hand sides separated by the special symbol | » The left-hand side is a single non-terminal » The right-hand side is a sequence of one or more things, each of which can be either a token or a non- terminal � A production gives one possible way of building a parse tree: it permits the non- terminal symbol on the left-hand side to have the things on the right-hand side, in order, as its children in a parse tree 19 20 Maria Hybinette, UGA Maria Hybinette, UGA Example Extensions to BNF - EBNF < exp > ::= < exp > + < exp > | < exp > * < exp > | ( < exp > ) � BNF is sufficient to describe context free | a | b | c languages � Various extensions and modifications have been made to ease the expression of programming � Equivalent to six productions: language grammars < exp > ::= < exp > + < exp > » The extensions can be bee describe in the original BNF < exp > ::= < exp > * < exp > » Collectively these are called EBNF extended BNF < exp > ::= ( < exp > ) < exp > ::= a < exp > ::= b < exp > ::= c 21 22 Maria Hybinette, UGA Maria Hybinette, UGA Example EBNF extensions Concrete Syntax � Remove brackets for non-terminal � To build a parse tree, put the start symbol at � Replace ::= with � the root � Replace vertical bars with spaces � Add children to every non-terminal, following � + for one or more occurrences any one of the productions for that non- terminal in the grammar » EBNF: A � X (Y) + » BNF: A := XB � Done when all the leaves are tokens – B := Y | YB � Read off leaves from left to right—that is the � * for zero or more occurrences string derived by the tree 23 24 Maria Hybinette, UGA Maria Hybinette, UGA

Recommend


More recommend