Interpreting a basic turtle graphics programming language: hand-coded vs JavaCC based implementations

Florin Birleanu

Abstract


Interpretation of custom programming languages is a challenging task for many software programmers. This paper presents an easy to follow approach to this problem by using as input language a small programming language for generating turtle graphics. First, we present a step by step almost automatic manual implementation in JavaScript of an interpreter for this input language. Then, we automate the implementation even more, by using the JavaCC code generator. In this second implementation, instead of directly interpreting the abstract syntax tree in order to generate a drawing in a Canvas element, we translate it to an SVG graphics file. Besides their usefulness as case studies, the resulting applications can be used as tools for teaching basic programming concepts.


Full Text:

PDF

References


T. Æ. Mogensen, Introduction to Compiler Design, 2nd ed., Springer International Publishing, 2017.

D. Grune and C. J.H. Jacobs, Parsing Techniques. A Practical Guide, 3rd ed., Springer-Verlag New York, 2008.

C. J. Solomon and S. Papert, “A case study of a young child doing turtle graphics in LOGO,” in Proceedings of the AFIPS ‘76 national computer conference and exposition, New York, June 7-10, 1976, pp. 1049–1056.

M. E. Caspersen and H. B. Christensen, “Here, there and everywhere - on the recurring use of turtle graphics in CS1,” in Proceedings of the ACSE ‘00 Australasian conference on Computing education, Melbourne, 2000, pp. 34–40.

R. Goldman, S. Schaefer, and T. Ju, “Turtle geometry in computer graphics and computer-aided design,” Elsevier Computer-Aided Design, vol. 36, pp. 1471–1482, December 2004.

W. Feurzeig and G. Lukas, “LOGO – A Programming Language for Teaching Mathematics,” Educational Technology, vol. 12, no. 3, pp. 39–46, March 1972.

V. Kodaganallur, “Incorporating language processing into Java applications: a JavaCC tutorial,” IEEE Software, vol. 21, pp. 70–77, July-Aug. 2004.


Refbacks

  • There are currently no refbacks.


Copyright (c) 2019 Journal of Electrical Engineering, Electronics, Control and Computer Science

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.