Podcast
Questions and Answers
______ refers to the structure or form of a language, outlining the rules for how symbols can be combined to create valid expressions.
______ refers to the structure or form of a language, outlining the rules for how symbols can be combined to create valid expressions.
Syntax
______ deals with the meaning of a language, focusing on the interpretation of symbols, words, phrases, and sentences to understand their significance.
______ deals with the meaning of a language, focusing on the interpretation of symbols, words, phrases, and sentences to understand their significance.
Semantics
A ______ is a language used to describe another language, specifying rules, patterns, or structures of the target language.
A ______ is a language used to describe another language, specifying rules, patterns, or structures of the target language.
metalanguage
Regular expressions use the symbol *
to denote ______ occurrence(s) of the preceding character or group.
Regular expressions use the symbol *
to denote ______ occurrence(s) of the preceding character or group.
The +
symbol in regular expressions is used to describe ______ between different characters or sets of characters, allowing for a choice in the pattern.
The +
symbol in regular expressions is used to describe ______ between different characters or sets of characters, allowing for a choice in the pattern.
Parentheses, ( )
, in regular expressions are used to denote ______ among strings or characters, affecting the order of operations in pattern matching.
Parentheses, ( )
, in regular expressions are used to denote ______ among strings or characters, affecting the order of operations in pattern matching.
A regular expression is a ______ represented as a string that concisely and formally denotes the strings of a language.
A regular expression is a ______ represented as a string that concisely and formally denotes the strings of a language.
Unlike syntax, we lack easily implemented formal models of ______ in a computer system.
Unlike syntax, we lack easily implemented formal models of ______ in a computer system.
Addressing semantics during parsing can eliminate the need for multiple passes through the ______ string.
Addressing semantics during parsing can eliminate the need for multiple passes through the ______ string.
Part of the meaning (or semantics) should be determined directly from the ______ (or syntax).
Part of the meaning (or semantics) should be determined directly from the ______ (or syntax).
The underlying cause of shift-reduce and reduce-reduce conflicts is often an ______ grammar.
The underlying cause of shift-reduce and reduce-reduce conflicts is often an ______ grammar.
A grammar is considered ______ if a sentence within it can be parsed in more than one distinct way.
A grammar is considered ______ if a sentence within it can be parsed in more than one distinct way.
A parse of a sentence can be graphically represented using a ______ tree.
A parse of a sentence can be graphically represented using a ______ tree.
In a parse tree, the root is the start symbol of the grammar, non-leaf vertices are non-terminals, and leaves are ______.
In a parse tree, the root is the start symbol of the grammar, non-leaf vertices are non-terminals, and leaves are ______.
A parse tree is considered fully ______ when all its leaves are terminal nodes.
A parse tree is considered fully ______ when all its leaves are terminal nodes.
From a recognition standpoint, having multiple derivations is not a problem but, having multiple ______ tree is a problem.
From a recognition standpoint, having multiple derivations is not a problem but, having multiple ______ tree is a problem.
The dual use of grammars involves generation for constructing a derivation and ______ for constructing a parse tree.
The dual use of grammars involves generation for constructing a derivation and ______ for constructing a parse tree.
In shift-reduce parsing, if the items at the top of the stack match the right-hand side of a production rule, those items are replaced with the non-terminal on the left-hand side of that rule; this process is known as ______.
In shift-reduce parsing, if the items at the top of the stack match the right-hand side of a production rule, those items are replaced with the non-terminal on the left-hand side of that rule; this process is known as ______.
When performing a bottom-up parse, the process starts with the string of terminals and non-terminals, working back towards the ______ symbol.
When performing a bottom-up parse, the process starts with the string of terminals and non-terminals, working back towards the ______ symbol.
A bottom-up parse of an input string constructs a ______ derivation of the string in reverse.
A bottom-up parse of an input string constructs a ______ derivation of the string in reverse.
A ______ conflict arises in parsing when the parser cannot decide whether to shift the next input symbol onto the stack or reduce a sequence of symbols on top of the stack.
A ______ conflict arises in parsing when the parser cannot decide whether to shift the next input symbol onto the stack or reduce a sequence of symbols on top of the stack.
In the context of parsing, ______ primarily deals with the structure and syntax of the input, ensuring it conforms to the grammar's rules rather than focusing on the meaning.
In the context of parsing, ______ primarily deals with the structure and syntax of the input, ensuring it conforms to the grammar's rules rather than focusing on the meaning.
If the stack contains only the start symbol when the input string is entirely consumed, the string is considered a ______.
If the stack contains only the start symbol when the input string is entirely consumed, the string is considered a ______.
The .
symbol typically denotes the ______ of the stack in parsing contexts.
The .
symbol typically denotes the ______ of the stack in parsing contexts.
When a shift-reduce conflict occurs and a shift operation is preferred to give multiplication higher precedence, reducing would incorrectly give ______ higher precedence.
When a shift-reduce conflict occurs and a shift operation is preferred to give multiplication higher precedence, reducing would incorrectly give ______ higher precedence.
Parsers often integrate techniques originally intended for syntactic validity to also address certain aspects of ______.
Parsers often integrate techniques originally intended for syntactic validity to also address certain aspects of ______.
The last two rows of a table, when having multiple meanings, illustrate ______ problems.
The last two rows of a table, when having multiple meanings, illustrate ______ problems.
______ ambiguity may exist independently of context.
______ ambiguity may exist independently of context.
In the English language, syntactic ambiguity often leads to ______ ambiguity.
In the English language, syntactic ambiguity often leads to ______ ambiguity.
A sentence containing ______ words can be semantically ambiguous even without syntactic ambiguity.
A sentence containing ______ words can be semantically ambiguous even without syntactic ambiguity.
In programming languages, ______ ambiguity can occur independently of syntactic ambiguity.
In programming languages, ______ ambiguity can occur independently of syntactic ambiguity.
To prove a grammar is ambiguous, one must generate an expression from the grammar and provide two valid ______ trees for that expression.
To prove a grammar is ambiguous, one must generate an expression from the grammar and provide two valid ______ trees for that expression.
When constructing parse trees to prove grammar ambiguity, the leaves of the tree must consist of ______.
When constructing parse trees to prove grammar ambiguity, the leaves of the tree must consist of ______.
When proving grammar ambiguity with parse trees, the ______ leaves in each parse tree must constitute the expression.
When proving grammar ambiguity with parse trees, the ______ leaves in each parse tree must constitute the expression.
When building parse trees to demonstrate ambiguity, it is important that you do not change the ______ while creating the trees.
When building parse trees to demonstrate ambiguity, it is important that you do not change the ______ while creating the trees.
Demonstrating grammar ambiguity through parse trees requires that you do not alter the ______ while constructing the trees.
Demonstrating grammar ambiguity through parse trees requires that you do not alter the ______ while constructing the trees.
When there are no curly braces for disambiguation, ambiguity may exist in an if-else
statement. This is known as the classical ______ else
problem.
When there are no curly braces for disambiguation, ambiguity may exist in an if-else
statement. This is known as the classical ______ else
problem.
In C, in the absence of curly braces to resolve ambiguity in nested if-else
statements, the else
is assigned to the closest ______ if
.
In C, in the absence of curly braces to resolve ambiguity in nested if-else
statements, the else
is assigned to the closest ______ if
.
The source of the dangling else
problem lies in an ______ grammar, where the same code structure can be interpreted in multiple ways, leading to different parse trees.
The source of the dangling else
problem lies in an ______ grammar, where the same code structure can be interpreted in multiple ways, leading to different parse trees.
______-Free Grammars cannot, by definition, represent context in a language, which limits their ability to enforce context-sensitive rules.
______-Free Grammars cannot, by definition, represent context in a language, which limits their ability to enforce context-sensitive rules.
One way to address ambiguity in a grammar is to introduce a new ______ to add another level of indirection, which can help to clarify the structure of the language and resolve conflicts.
One way to address ambiguity in a grammar is to introduce a new ______ to add another level of indirection, which can help to clarify the structure of the language and resolve conflicts.
Flashcards
Grammar
Grammar
Defines the structure of a language.
Syntax
Syntax
Structure/form of a language.
Semantics
Semantics
The meaning of a language.
Regular Expression
Regular Expression
Signup and view all the flashcards
Metalanguage
Metalanguage
Signup and view all the flashcards
"+" in Regular Expressions
"+" in Regular Expressions
Signup and view all the flashcards
"*" in Regular Expressions
"*" in Regular Expressions
Signup and view all the flashcards
.(dot) in Parsing
.(dot) in Parsing
Signup and view all the flashcards
Parsing Step
Parsing Step
Signup and view all the flashcards
Reducing (Parsing)
Reducing (Parsing)
Signup and view all the flashcards
Shifting (Parsing)
Shifting (Parsing)
Signup and view all the flashcards
Bottom-Up Parsing
Bottom-Up Parsing
Signup and view all the flashcards
Bottom-Up Derivation
Bottom-Up Derivation
Signup and view all the flashcards
Shift-Reduce Conflict
Shift-Reduce Conflict
Signup and view all the flashcards
Ambiguity
Ambiguity
Signup and view all the flashcards
Syntax in Parsing
Syntax in Parsing
Signup and view all the flashcards
Semantics in Parsing
Semantics in Parsing
Signup and view all the flashcards
Reduce-Reduce Conflict
Reduce-Reduce Conflict
Signup and view all the flashcards
Ambiguous Grammar
Ambiguous Grammar
Signup and view all the flashcards
Parse Tree
Parse Tree
Signup and view all the flashcards
Parse Tree Components
Parse Tree Components
Signup and view all the flashcards
BNF Grammars
BNF Grammars
Signup and view all the flashcards
Purpose of a Parse Tree
Purpose of a Parse Tree
Signup and view all the flashcards
Multiple Parse Trees
Multiple Parse Trees
Signup and view all the flashcards
Interpretation Standpoint
Interpretation Standpoint
Signup and view all the flashcards
Ambiguous Grammar Consequence
Ambiguous Grammar Consequence
Signup and view all the flashcards
Dangling Else Problem
Dangling Else Problem
Signup and view all the flashcards
Left-Associative Grammar
Left-Associative Grammar
Signup and view all the flashcards
Backus-Naur Form (BNF)
Backus-Naur Form (BNF)
Signup and view all the flashcards
Context-Free Grammars Limitation
Context-Free Grammars Limitation
Signup and view all the flashcards
Context-Sensitive Grammar (CSG)
Context-Sensitive Grammar (CSG)
Signup and view all the flashcards
Syntactic Ambiguity
Syntactic Ambiguity
Signup and view all the flashcards
Semantic Ambiguity
Semantic Ambiguity
Signup and view all the flashcards
Context-Independent Ambiguity
Context-Independent Ambiguity
Signup and view all the flashcards
Context-Dependent Ambiguity
Context-Dependent Ambiguity
Signup and view all the flashcards
Syntactic Ambiguity's Impact
Syntactic Ambiguity's Impact
Signup and view all the flashcards
Polysemy's Role
Polysemy's Role
Signup and view all the flashcards
Semantic Ambiguity (programming)
Semantic Ambiguity (programming)
Signup and view all the flashcards
Interdependence of Ambiguity Types
Interdependence of Ambiguity Types
Signup and view all the flashcards
Proving Grammar Ambiguity
Proving Grammar Ambiguity
Signup and view all the flashcards
Study Notes
Chapter Objectives
- Introduce syntax and semantics needed to define a language
- Describe formal methods for defining the syntax of a programming language
- Establish understanding of regular languages, expressions, and grammars
- Discuss the use of the Backus-Naur Form to define grammars
- Establish an understanding of context-free languages and grammars
- Introduce the role of context in programming languages and the challenges in modeling context
Introduction to Formal Languages
- Alphabet: A finite set of symbols, denoted by Σ, for example {a, b, c}.
- Strings: Combinations of symbols (characters) over an alphabet.
- If the alphabet (Σ) = {a, b, c}, then examples of strings include: a, aa, ab, abc, aba, bb, etc.
- The Kleene closure of an alphabet, denoted Σ*, represents the set of all possible strings over that alphabet.
- While an alphabet (Σ) is always finite, its Kleene closure (Σ*) is always infinite.
- Σ* always contains a null character or ε.
- A formal language (L) is a set of strings, specifically a subset of Σ*; each string from Σ* in L is called a sentence.
- Formal language is denoted by L.
- A formal language (L) can be either finite or infinite.
- Formal languages are defined by a set of sentences (strings) over some alphabet where the legal strings comprise the sentences
- Formal languages are defined by a grammar including the syntax of the language
- Syntax refers to the structure or form of a language
- Semantics refers to the meaning of a language
- There are both finite and infinite languages
- The most interesting languages are infinite
Progressive Validity Examples
- Lexically valid means the words are valid.
- Syntactically valid means the sentence structure is valid.
- Semantically valid means the sentence makes sense.
- In natural language: "Augustine is a saint" is lexically, syntactically, and semantically valid.
Regular expressions
- A concise and formal method for describing languages is needed because languages can be infinite.
- A regular expression (r) is a pattern, represented as a string, that concisely and formally denotes the strings of a language.
- The regular expression (r) itself is a string in a language termed the metalanguage, utilized to describe another language with its own alphabet and syntax
- Lexemes can be formally described by regular grammars.
- '+' describes "or".
- '*' denotes "0 or more occurrences of the previous character".
- '()' denotes "precedence among strings".
- Examples:
opus*
results in {opu, opus, opuss, opusss, ...}(ab)*
results in {É›, ab, abab, ababab, ...}opus(1+2+3+4+5+6+7+8+9)
results in {opus1, opus2, opus6, ...}opus(1+2+3+4+5+6+7+8+9)(0+1+2+3+4+5+6+7+8+9)*
results in {opus1, opus2, ..., opus10, ..., opus21, ..., opus99}
Finite-State Automata
- Elements of a set of sentences enumerate a formal language extensionally
- Denoting the set of sentences of languages defines a regular language intensionally with a regular expression
- A finite-state automaton (FSA) recognizes whether a string is a sentence (legal string denoted by regular expressions) in a particular language
- Deciding whether a string is a sentence in a particular language is a simplified computational mechanism that can be thought of as an automaton
Regular Languages
- Regular grammars define or generate regular languages and are also called linear grammars
- Any finite language is regular, but the reverse is not true
- The finite language {a, b, c} is denoted by the regular expression a+b+c
- Sentences from regular languages are recognized using finite state automata (FSA)
Grammars and Backus-Naur Form (BNF)
- Grammars define languages like the regular expression and is also a Metalanguage like regular expressions.
- A grammar has its own syntax, different from the language it defines.
- A metalanguage defines grammar called Backus-Naur Form (BNF).
- Named after John Backus and Peter Naur, who respectively developed and extended the notation for ALGOL 58 (1958) and ALGOL 60 (1960)
- A formal grammar can be used to define a formal language.
- A formal grammar example defined in BNF representing the language denoted by the a* regular expression is:
- S → a S
- S → ε
Grammar Formal Definition
- The formal definition of a grammar is G = (V, Σ, P, S)
- V is a set of non-terminal symbols, like {S}.
- Σ is an alphabet, where Σ = {a}.
- P is a finite set of production rules, of the form x → y, where x and y are strings over Σ ∪ V and x ≠€.
- S is the start symbol such that S ∈ V.
- V represents the set of non-terminal alphabet, while ∑ is set of terminal alphabet and V ∩ Σ = Ø
- Formally, for each terminal symbol t, t ∈ Σ* (Σ set of all strings over Σ)
- Strings of symbols from ∑ are called terminals.
- Terminals are the atomic lexical units of a program commonly called lexemes (identifiers in programming languages).
- G = ({S}, {a}, {S → aS, S → ε}, S) is an example of a formal declaration of a language grammar with BNF (see prev. slides)
Grammar As Generative Device
-
A stream of tokens must conform to a Grammar and must be arranged in a particular order
-
Grammars define how sentences are constructed
-
Sentences from the language it defines are generated when applying the production rules starting with the start symbol
-
An example of a derivation of the sentence aaaa in a given language illustrates:
S ⇒ aS ⇒ aaS ⇒ aaaS ⇒ aaaaS ⇒ aaaa
-
Tokens must adhere to a Grammar and possess a certain order.
-
Grammars specify how sentences get constructed. Beginning with the start symbol, generate a sentence to define the language. For G (V, Σ, P, S),
- The language generated by G is represented as L(G) = {x | x ∈ Σ* and s * x}
- * means finally derives
-
A grammar in BNF for language denoted by regular expression opur*
- (V={S,W}, Σ={o, p, u, r}, P= {S → opuW, W → rW, W → ε}, {S})
Chompsky Hierarchy
- Linguist Noam Chomsky formulated a set of grammars used to describe language syntax in the late 1950s, called as Chomsky hierarchy. The hierarchy consists of the following
- Level 1: Regular Grammar
- Regular Grammar use includes lexeme descriptions of programming languages
- C Keywords
- Complete sets of lexemes in a language are referred to as a lexicon
- Level 2: Context-Free Grammar
- Level 3: Context-Sensitive Grammar
- Level 1: Regular Grammar
Regular Grammar (Type 1)
-
A grammar is regular if and only if every production rule is in one of the following two forms:
X → zY
X → z where X ∈ V, Y ∈ V, and z∈ Σ* -
Grammars conforming to these patterns are also called right-linear grammars
-
Grammars whose production rules follow the pattern X → Yz and X → z are called left-linear grammars:
-
Right-linear and Left-linear grammars generate regular languages
-
Regular grammars are referred to as linear grammars.
Regular Grammar and Regular Language
- Regular grammars define regular languages.
- A regular gamma is a generative device for a regular languages, where it generates sentences from the regular languages that it defines
- A grammar does not have to be regular to generate a regular language
- Non regular grammars can generate a regular language
Finite-State Automota / Regular Expressions
- Regular expressions, regular grammars, and finite-state automata are equivalent in their power to denote, generate, and recognize regular languages.
- No regular language could be denoted with a regular expression that could not be decided by a FSA or generated by a regular grammar
- An enumeration of the elements of a set of sentences defines a regular language extensionally, while a regular expression, finite-state automata, and regular grammar each define a regular language intensionally.
Regular Grammar Limitations
-
Regular grammars cannot express language syntactic structures that nest arbitrarily, including:
- Balanced pairs of lexemes "{}"
- Checking palindromes
- Begin/End keyword pairs
- Parentheses in mathematical expressions
-
Expressions are expressive enough to denote lexemes, but not the programming languages' higher-order syntactic structures
Context Free Grammars
-
Context-free grammar (CFG): a grammar is a context-free grammar if and only if every production rule is in the following form:
X → Y where X ∈ V and Y ∈ (Σ ∪ V)*
-
There is only one non-terminal on the left-hand side of any context-free grammar rule, can be replaced anywhere.
-
Less restrictive form can be found in the right-hand rule. CFGs are less restrictive than regular grammars
-
Context-free grammars define a class of formal languages called context-free languages.
Regular Grammar vs Context Free Grammar
- Balanced pairs of syntactic entities is the essence of a Dyck language and is at the heart of context-free languages.
- The ability to express balanced pairs and a single syntactic feature is the essence of a context-free grammars
- Regular grammar is context-free grammar, but the reverse is not correct
Language Generation: Sentence Derivations
- Given a set of context free grammars an English vocabulary set of
→ . -
→ a -
→ an -
→ the → apple → rose → umbrella → is → appears → here - and
→ there - Non terminals include the basic parts of speech. Terminals include common English words.
- Grammar is the set of production rules and starting symbol is
- Language is generated by conforming to top-down construction using grammar, creating a construct derivation. For example the sentence "the apple is there" is derived as follows.
⇒ . -
there. -
is there. -
apple is there. - the apple is there.
- The grammar above uses the vertical bar | indicating the "alternation symbol" when the rules are in "Extended version of BNF"
Parsing
- Grammar can be one of two devices
- Generative: grammar >- sentence
- Recognition: sentence >- grammar
- Parsing is for recognition. Parsers do the reverse operation starting with the sentence and conforming to a grammar
- The production rules of a grammar move forward
- The derivation rules of a grammar move backwards
- Parsing proceeds from left-to-right
- The dot . indicates progress
- The left of the . is considered the "stack"
- The right of the . is the "handle"
Shift Reduce or Bottom-Up Parsing
- Shift-reduce, also known as "bottom up parsing" starts with terminals and is reduced back to the start signal
- It constructs a rightmost derivation in reverse using the terminals
Parsing Examples
-
Bottom up parsing takes the general form
.x + y*z
x. + y*z
id . + y * z
expr . + y*z
expr + . y * z
expr + y. * z
expr + id . * z
expr + expr . * z
-
Two types of conflicts arise at the "shift" in
+ .* z -Shift action * -Reduce action +
Shift Reduce conflict
- A shift reduce results from having two different choices during reduction
- Shift for * gives multiplication precedence "desireable outcome"
- Reduce gives addition precedence "undesirable outcome"
- These parse processes deal with syntax over semantics
Reduce Reduce Conflicts
- A reduce-reduce conflict will result in multiple parse trees that represent the syntax
- Formal grammars define syntax only
- BNF grammars define both syntax and semantics
Parse Trees
- An ambiguous grammar is the underlying source of shift-reduce and reduce-reduce conflicts.
- Ambigious grammars occurs if parsing is possible in one way.
- The parse tree for a sentence is a graphical representation of its derivation.
- Rooted at starting symbol.
- Non-leaf vertices/nodes are non-terminals. Leaves are terminals. Trees are fully expanded
- The parse tree for a sentence is a graphical representation of its derivation.
Effect of Ambiguity Semantics
- The grammar must be ambiguous if a sentence from that language has more than one parse tree
- Last three rows of a table will show the grammar as ambiguous, last two will have interpretation problems
- Syntactic Ambiguity
- Multiple syntactic structures
- Example: They are moving pictures
- Semantical Ambiguity
- Only one: syntactic structures
- Multiples meanings
- Example: The mouse correct on my computer
Effects Of Semantics
- Ambiguity in the context of independence and expressions such as precedence and / or associativity and the operations
- Ambiguity can occur with context dependence in English such language as syntactic ambiguity
- Syntactic ambiguity leads to semantical ambiguity, consider "Time flies like an arrow" or "They are moving pictures"
- Semantical ambiguity can occur with context independence such polyseme languages with words including mouse, book, or flies
- Consider "I see a mouse on top of the computer"
- The mouse is the species or the computer
- Programming Languages are ambiguous like (Integer)-a
Interdependance of Types of Ambiguity
- Lexical, and semantic ambiguities exist, and are context dependent
Grammar Determination is Ambiguous
- Grammar is ambiguous as follows
- Generate the expression from grammar
- Give two syntax trees in the grammar for that expression
- Note that
- Grammar comes from the grammar code expression;
- Parse trees must have expression codes at the leaves
- Parse trees cannot violate rules
- Terminals are always trees
Disambiguating Grammar
- Two choices exists to resolve grammar issues
- Create grammar documentation specifying operations ordering
- Inherent grammatical ambiguity and ambiguation in English exist
- Disambiguation
- Create grammar documentation specifying operations ordering
Grammar Resolution
- Syntax implies semantics and desideratum.
- Precedence
- Associativity
- Occurs lower in parse threes because of bottom up evaluation when discussing higher precedence.
- State a disabmiguating rule such as order of precedence. Most languages provide an inherent order for addition and multiplication but other languages including APL don't
- Some grammar is inherently ambiguous with the rules and Context Free Grammars can resolve
- To resolve, grammar can be revised
- Not always possible
- Some are inherently ambiguous in context free
Operator Resolution
Introduce new steps
- Implement an operation within existing structure, will always be lower than edits in the tree"Work out solution for x + y ∗ z
- Express ::=Express + Term
- Express ::=Express − Term
- Express ::=Term
- Term ::=Term ∗ Factor
- Term ::=Term / Factor
- Factor ::= (Express)
- Factor::= Number
- Yes, is the term till ambiguous? Yes.Why? What about associativity problems?How can we disambiguate it?。
Associates Of Operators
-
Associativity
- Use same precedence in the operator when handling
- (6-3)-2 = 1 is left associative
-
- (-(-6))) = -6 is a right associative
- Addition + for floating point operations.
- C is a right associative
Overcoming ambiguity of association;
-Right recursive rules lead to right association; 。
- Use same precedence in the operator when handling
Dangling ELSE
-
When curly braces are not present and are not used for disimbiguation, if statements can cause ambiguity errors
if exprl
if expr2
- To which does else associate with
if (if b 3) x −4;else y - 5
Source : is from ambiguous grammar.if condstmt or if cond stmt, then else state occurs
Parse tree of the conditional can illustrate ambiguity during (if) state, or (else) state.
For example, two derivations of the number 132:
Ambiguous Grammar
- The grammar must be ambiguous if a sentence from that language has more than one parse tree
Derivations of 132
-
LeftMost derivation:
⇒ ⇒ <number> <digit> ⇒ <number><digit> <digit> ⇒ <digit><digit><digit> ⇒ 1 <digit><digit> ⇒ 13 <digit> ⇒ 132
-
Right Most Derivation
⇒ ⇒ <number><digit> ⇒ <number> 2 \ ⇒<number><digit>2 ⇒ number 32 ⇒ d322 ⇒ 132
The two parse trees for the expression "x"
- If the same expression produces multiple syntactic derivations it's said to have the syntactive ambiguation.
Types of Grammar
-
Context free grammar - Cannot represent count. By definition
+Context sensitive or not context free . Ex Capitalization of initial number. S starts with <startarticle
Context Sensitive Grammar:
-
In context free grammar, the left-hand side of the production rule is not limited to one
-
is the second production provides context
-
only applies in context of
The Chomsky Hierarchy
- Type 3 regular language
- Regular grammar
- Deterministic finite automaton
- X = zY
- X = Z
- Type2 context-free language
- Context-free grammar
- Pushdown automaton X
- Gamma
- Type 1 context-sensitive language
- Context-free grammar
- Linear bounded automaton
- Alpha - beta greater Aybeta. 1
Takeaways
- Identifiers and numerals can be described in programming in languages languages by regular.
- Nested experiences in program languages can be described in contact numbers.
- Neither is regular not a context free grammar can describe the data of a variables that must be.
- Grammas are language recognition devices.
- An ambiguous grammar poses a problem a language recognition too par trees of our language prove.
- Semantic properties including precedence and associativity can in a grammar.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This lesson defines language structure and semantics. It also explain metacharacters used in regular expressions like *, +, and ( ). Regular expressions are patterns that describe strings of a language.