110 likes | 276 Views
Method of Language Definition. A Language is defined by: A: Lexical = Valid Tokens & Words B: Syntax = The GRAMMER of the Language C : Semantics = The MEANING of valid syntactical statement. Language. A: Lexical B: Syntax. Written English
E N D
Method of Language Definition • A Language is defined by: • A: Lexical = Valid Tokens & Words • B: Syntax = The GRAMMER of the Language • C: Semantics = The MEANING of valid syntactical statement Language
A: Lexical B: Syntax Written English 26 letter and . ? ! Special Characters Words Obj of Preposition Verb Clause Sentences The Valid Tokens create “Words” - Expression then become Statement – Complete Statement Rules – Spelling of Words – Completing a sentence
C. Semantics • Semantics • Meaning of a valid syntactical statement • Context free • Context sensitive
Let’s Study language • First, let’s look at a programming language • Java • A: Syntax • Valid Token Alphabet & Spec. Char Words Class, Private, Public Statement – if (A < B) {B = A;}
Let’s look at another programming language • A Language is defined <N, T, S, P> where • T is a finite set of terminal symbols, • N is a finite set of non-terminal symbols, • S is the start symbol, S, • P is a finite set of production rules of the form, • Let’s see the grammar of Arithmetic expressions in the next slide.
Language is defined <N, T, S, P> where • N= Non-terminal symbols: • <Exp>, <Term>, <Factor> • T= Terminal symbols: • +, -, *, /, (, ), x, y, z, ... • S= Start symbol: • <Exp> • P= Production rules: • <Exp> ::= <Exp> + <Term> | • <Exp> - <Term> | • <Term> • <Term> ::= <Term> * <Factor> | • <Term> / <Factor> | • <Factor> • <Factor> ::= x | y | ... | • ( <Exp> ) | • - <Factor> • A grammar for the concrete syntax of simple arithmetic expressions
Semantics “The MEANING of a correct … • If A + 2 > B then A = 10; • Logic that decomposes to “machine activity” • Register • ACU
Think! Your Project • Possible expressions: • Registering • Log in • Search • Find home • For Log in • Mouse Travel • define : 1) Tokens = Mouse Selection • Ind. on screen Obj. • Mult. On screen Obj. • valid expressions Words • Define criteria
Possible tokens in your interaction Language • MT : Mouse Travel • MS: Mouse Selection • – indicate the on screen object • Mult: Multiple Selection • multiple screen objects selected Alph + Specific (except + ENTER TAB) • S: String
Example • Goal - Login • A valid syntactical login: • MT => Click when on B1 • => S • => Tab • => SH • => Enter P1 B1 B2 B3