160 likes | 298 Views
High-level Languages. Grammars Parsers Constructs Compilers. Advantages. More powerful Enforce structure easier to read fewer bugs Portable. Grammars. Definition: A system of rules that defines the structure of a language
E N D
High-level Languages • Grammars • Parsers • Constructs • Compilers
Advantages • More powerful • Enforce structure • easier to read • fewer bugs • Portable
Grammars Definition: A system of rules that defines the structure of a language Identification of which rules were used in a sentence allows us to interpret its meaning
Examples • You are welcome. • You should welcome the guests. • I am blue. • The wall is blue.
Examples II • Cool… • Turn left at the light.
Parsers • Parsing • The act of resolving a sentence into its component pieces according to the rules of a specific grammar A parser matches words to predicates to determine which rules were used
Concepts to Code Branching LDA x BRP y BRA z y … BRA *** z … *** … x > 0? y z
Constructs • Do one of two things based on a condition • Do the first thing or the second thing based on a condition • Do the first thing based on a condition, otherwise do the second thing • If a condition is true, then do the first thing. Otherwise, do the second thing if (condition) then {first thing} else {second thing}
Conversion Examples Explain the following to a computer: • A passed student is allowed to continue • Don’t drink and drive
Compilers Translate high-level language programs into Assembly • Identify constructs • Translate into specified Assembly • No interpretation!!
Similarities… • First flowchart has “large” boxes • Boxes expand into more flowcharts • Compiler checks that each level is correct
Summary • Must use restricted syntax to express ideas • Must be explicit with description of ideas