Skip to main content

Questions tagged [attribute-grammars]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
3 answers
105 views

Example of attribute grammar that is NOT l-ORD but non-circular

I am wondering if there exists an example attribute grammar that is non-circular but not l-ordered (l-ORD) as well. The reason I am asking this is one can find an attribute grammar that is circular, ...
Node.JS's user avatar
  • 151
0 votes
1 answer
68 views

Visits sequence evaluator in attribute grammar

I am failing to understand the "visits sequence evaluator in attribute grammar". Is it an order on instantiated tree nodes where on each visit to a node we evaluate a particular node and we ...
Node.JS's user avatar
  • 151
1 vote
0 answers
25 views

How do bottom up parser evaluate things that need an inherited attribute?

I learned that Bottom up parsers use only synthesized attributes to evaluate semantics. Which makes sense considering that it would be very hard to evaluate an inherited attribute in bottom up ...
JsonResponse's user avatar
0 votes
1 answer
56 views

How is $A.in$ an inherited attributed in $2nd$ production in $(1) S \rightarrow A_1A_2\{ A_1.in := 1; A_2.in := 2 \}(2) A\rightarrow a\{print(A.in)\}$

Below is an excerpt from the Red Dragon book. $$(1) \quad S \rightarrow A_1 \quad A_2 \quad\{ A_1.in : = 1;\quad A_2.in : = 2 ;\}$$ $$(2) \quad A \rightarrow a \quad \{ print(A.in) \}$$ We find that ...
Abhishek Ghosh's user avatar
0 votes
1 answer
112 views

L-attributed definitions include all syntax-directed definitions based on LL(1) grammars

I was going through the text Compilers: Principles, Techniques and Tools by Ullman et. al where I came across the following claim: L-attributed definitions include all syntax-directed definitions ...
Abhishek Ghosh's user avatar
1 vote
1 answer
125 views

In syntax-directed definition, terminals are assumed to have synthesized attributes only, definition doesn't provide any semantic rules for terminals?

I was going through the text Compilers: Principles,Techniques and Tools by Ullman et. al. where I came across the claim in the question by authors. Below is the definition and following it is the ...
Abhishek Ghosh's user avatar
1 vote
2 answers
259 views

How to evaluate a Kleene's Closure through CFG and attribute grammars

For a CFG with the production rules that can represent a regular expression. How can one calculate all the set of strings that regular expression would produce. For T = {a, b,*,(,)} and an arbitrary ...
MicroMaximus's user avatar
2 votes
0 answers
112 views

Flaw with Knuth original attribute grammar paper

Knuth's original attribute grammar paper (title: Semantics of Context-Free Languages) apparently had a flaw where circularity is always detected but some noncircular AGs may be reported to be circular....
Node.JS's user avatar
  • 151
3 votes
0 answers
112 views

Generating valid sentence with respect to attribute grammar

Given a context free grammar, both the algorithm for determining whether a given string is grammatical and the algorithm for producing a grammatical string in that language are well understood. To ...
lightning's user avatar
  • 225
2 votes
0 answers
61 views

Intuition on what an attribute grammar can achieve

I have seen attribute grammars for a small handful of tasks: Parsing simple arithmetical expressions Type checking Checking that a variable is initialized anbncn (seems to be a favorite toy example).....
lightning's user avatar
  • 225
1 vote
1 answer
7k views

Writing a Context-Free-Grammar using Backus Naur Form for a for-loop?

I'm pretty new to CFG, and I've tried out some samples as well. As of now I'm trying this for-loop to write it in CFG using BNF: ...
Kulasangar's user avatar
1 vote
0 answers
102 views

What is difference between LAG (Left Atrributed Grammar) and LATG (Left Attributed Translation Grammar)?

I am reading Compilers and am unable to understand difference between these two terms. I could not find any text which has clearly mentioned how they differ but these two separate terms are being used....
Abhishek Kumar's user avatar
5 votes
2 answers
6k views

Bottom-Up Evaluation of Inherited Attributes

I came across $2$ translation schemes of Syntax Directed Translation (SDT) in compilers which are as follows : Using a top-down translation scheme, we can implement any $L$-attributed definition ...
Garrick's user avatar
  • 482
2 votes
1 answer
289 views

Full circularity vs strong circularity for attribute grammars

Attributes of an attribute grammar can have a circular dependency. In my compiler construction course I learned, that there are two types of circularity for attribute grammars: full circularity can ...
Stefan Dollase's user avatar
-1 votes
1 answer
2k views

What is the archive attribute for windows files? [closed]

What is the archive attribute for windows files. What is Archive in file details?
Saeid M's user avatar
  • 13
1 vote
1 answer
240 views

Calculating attributes' values in the semantic analysis stage

I'm reading through the book : "Compiler Construction: Principles and Practice". In chapter 6 : semantic analysis, an example about attribute grammars is given. The example is of a simple integer ...
Sam Ibraheem's user avatar
1 vote
3 answers
421 views

Attribute grammars: How are attributes implemented?

I've read about attribute grammars, but I haven't found out, how are the attributes often implemented? To me they scream objects (of classes), but they could be also variables. But are there any ...
mavavilj's user avatar
  • 579
2 votes
2 answers
786 views

Ambiguity vs. context-sensitivity

It is said that attributes supply some semantic information to the grammar. Meantime, the same attributes let you to resolve ambiguities. Text books agree that it is worth haveing a CF grammar which ...
Valentin Tihomirov's user avatar
0 votes
1 answer
41 views

Is it "valid" for semantic functions to query outside of the grammar in attribute grammars?

Is it valid (in the sense of formal grammars or formal language theory) to refer to outside of the grammar in attribute grammars? What I mean is that since attribute grammars can contain semantic ...
mavavilj's user avatar
  • 579
0 votes
0 answers
39 views

What semantical is there in attribute grammars?

I've been reading about attribute grammars since I'm trying to extend CFGs to semantics. What I'm finding difficult to grasp is the use of the word "semantics" in the context of attribute ...
mavavilj's user avatar
  • 579
1 vote
2 answers
118 views

How can this grammar parse such an input?

I've an example which I simply don't get at all. Implement an attributed grammar that checks that either the word ends in $b$ or each prefix of the word contains at least as many $b$s ...
Stefan Falk's user avatar
7 votes
1 answer
428 views

Can abstract syntax trees be unparsed in subexponential time?

Abstract problem description The way I see it, unparsing means to create a token stream from an AST, which when parsed again produces an equal AST, i.e. ...
Stefan K.'s user avatar
  • 171