Abstract
Attribute grammars enable complex algorithms to be defined on tree and graph structures by declarative equations. An understanding of how the equations cooperate is necessary to gain a proper understanding of an algorithm defined by an attribute grammar. Existing attribute grammar tools and libraries provide little assistance with understanding the behaviour of an attribute evaluator. To do better, we need a way to summarise behaviour in terms of attributes, their values, their relationships, and the structures that are being attributed. A simple approach to program profiling is presented that models program execution as a hierarchy of domain-specific profile records. An abstract event for attribute evaluation is defined and evaluators are modified to collect event instances at run-time and assemble the model. A flexible report writer summarises the event instances along both intrinsic and derived dimensions, including ones defined by the developer. Selecting appropriate dimensions produces reports that expose complex properties of evaluator behaviour in a convenient way. The approach is illustrated and evaluated using the profiler we have built for the Kiama language processing library. We show that the method is both useful and practical.
Matt Roberts, Nikki Lesley and Suzana Andova provided helpful feedback on this work. Much of the project was performed while the author was a guest of Mark van den Brand’s group at TU Eindhoven. The author thanks the anonymous reviewers for their useful suggestions.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Bergel, A., Nierstrasz, O., Renggli, L., Ressia, J.: Domain-Specific Profiling. In: Bishop, J., Vallecillo, A. (eds.) TOOLS 2011. LNCS, vol. 6705, pp. 68–82. Springer, Heidelberg (2011)
Bouchou, B., Halfeld Ferrari, M., Lima, M.A.V.: Attribute Grammar for XML Integrity Constraint Validation. In: Hameurlain, A., Liddle, S.W., Schewe, K.-D., Zhou, X. (eds.) DEXA 2011, Part I. LNCS, vol. 6860, pp. 94–109. Springer, Heidelberg (2011)
Davidson, D., Smith, R., Doyle, N., Jha, S.: Protocol Normalization Using Attribute Grammars. In: Backes, M., Ning, P. (eds.) ESORICS 2009. LNCS, vol. 5789, pp. 216–231. Springer, Heidelberg (2009)
Ekman, T., Hedin, G.: The JastAdd extensible Java compiler. In: Proceedings of the ACM SIGPLAN Conference on Object-oriented Programming Systems and Applications, pp. 1–18. ACM, New York (2007)
Fernandes, J.P., Saraiva, J., Seidel, D., Voigtländer, J.: Strictification of circular programs. In: Proceedings of the 20th ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM 2011, pp. 131–140. ACM, New York (2011)
Graham, S.L., Kessler, P.B., Mckusick, M.K.: gprof: A call graph execution profiler. In: Proceedings of the 1982 SIGPLAN Symposium on Compiler Construction, SIGPLAN 1982, pp. 120–126. ACM, New York (1982)
Han, F., Zhu, S.-C.: Bottom-up/top-down image parsing with attribute grammar. IEEE Transactions on Pattern Analysis and Machine Intelligence 31(1), 59–73 (2009)
Hedin, G.: Reference Attributed Grammars. Informatica 24(3), 301–317 (2000)
Hedin, G., Magnusson, E.: JastAdd: an aspect-oriented compiler construction system. Science of Computer Programming 47(1), 37–58 (2003)
Jourdan, M.: An Optimal-Time Recursive Evaluator for Attribute Grammars. In: Paul, M., Robinet, B. (eds.) Programming 1984. LNCS, vol. 167, pp. 167–178. Springer, Heidelberg (1984)
Karim, M.R., Ryan, C.: A New Approach to Solving 0-1 Multiconstraint Knapsack Problems Using Attribute Grammar with Lookahead. In: Silva, S., Foster, J.A., Nicolau, M., Machado, P., Giacobini, M. (eds.) EuroGP 2011. LNCS, vol. 6621, pp. 250–261. Springer, Heidelberg (2011)
Kastens, U.: Ordered attribute grammars. Acta Informatica 13, 229–256 (1980)
Kastens, U., Waite, W.M.: Modularity and reusability in attribute grammars. Acta Informatica 31, 601–627 (1994)
Kats, L.C.L., Sloane, A.M., Visser, E.: Decorated Attribute Grammars: Attribute Evaluation Meets Strategic Programming. In: de Moor, O., Schwartzbach, M.I. (eds.) CC 2009. LNCS, vol. 5501, pp. 142–157. Springer, Heidelberg (2009)
Magnusson, E., Hedin, G.: Circular reference attributed grammars–their evaluation and applications. Science of Computer Programming 68(1), 21–37 (2007)
Mauro, J., Gregg, B., Mynhier, C.: DTrace: Dynamic Tracing in Oracle Solaris, Mac OS X and FreeBSD. Prentice Hall Professional (2011)
Nguyen, P., Falkner, K., Detmold, H., Munro, D.S.: A domain specific language for execution profiling & regulation. In: Proceedings of the Australasian Conference on Computer Science, pp. 123–132. Australian Computer Society, Inc. (2009)
Paakki, J.: Attribute grammar paradigms—a high-level methodology in language implementation. Computing Surveys 27(2), 196–255 (1995)
Rajagopalan, M., Debray, S.K., Hiltunen, M.A., Schlichting, R.D.: Profile-directed optimization of event-based programs. In: Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language Design and Implementation, PLDI 2002, pp. 106–116. ACM, New York (2002)
Sansom, P.M., Peyton Jones, S.L.: Formally based profiling for higher-order functional languages. ACM Trans. Program. Lang. Syst. 19(2), 334–385 (1997)
Saraiva, J.: Purely Functional Implementation of Attribute Grammars. PhD thesis, Department of Computer Science, Utrecht University, The Netherlands (December 1999)
Sloane, A.M.: Debugging Eli-Generated Compilers with Noosa. In: Jähnichen, S. (ed.) CC 1999. LNCS, vol. 1575, pp. 17–31. Springer, Heidelberg (1999)
Sloane, A.M.: Lightweight Language Processing in Kiama. In: Fernandes, J.M., Lämmel, R., Visser, J., Saraiva, J. (eds.) GTTSE 2009. LNCS, vol. 6491, pp. 408–425. Springer, Heidelberg (2011)
Sloane, A.M., Kats, L.C.L., Visser, E.: A pure embedding of attribute grammars. Science of Computer Programming (in press, 2012)
Söderberg, E., Hedin, G.: Automated Selective Caching for Reference Attribute Grammars. In: Malloy, B., Staab, S., van den Brand, M. (eds.) SLE 2010. LNCS, vol. 6563, pp. 2–21. Springer, Heidelberg (2011)
Van Wyk, E., Bodin, D., Gao, J., Krishnan, L.: Silver: An extensible attribute grammar system. Science of Computer Programming 75(1+2), 39–54 (2010)
Vogt, H.H., Swierstra, S.D., Kuiper, M.F.: Higher order attribute grammars. In: PLDI 1989: Proceedings of the ACM SIGPLAN 1989 Conference on Programming Language Design and Implementation, pp. 131–145. ACM Press (1989)
Wirth, N.: Compiler Construction. Addison-Wesley (1996) (revised November 2005)
Yaghmour, K., Dagenais, M.: The Linux trace toolkit. Linux Journal (May 2000)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2013 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Sloane, A.M. (2013). Profile-Based Abstraction and Analysis of Attribute Grammar Evaluation. In: Czarnecki, K., Hedin, G. (eds) Software Language Engineering. SLE 2012. Lecture Notes in Computer Science, vol 7745. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-36089-3_3
Download citation
DOI: https://doi.org/10.1007/978-3-642-36089-3_3
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-36088-6
Online ISBN: 978-3-642-36089-3
eBook Packages: Computer ScienceComputer Science (R0)