Fall 2025 Programming Languages Homework 1 Solutions Due Sunday September 28 2025 11 59 PM Eastern Standard Time The homework must be submitted entirely through NYU Brightspace do not send by email Make I do not sure you complete the entire submission process in Brightspace before leaving the page recommend waiting until the last minute to submit in case you encounter difficulties Late submissions will not be accepted No exceptions I highly recommend that you submit well in advance of the deadline to ensure that your submission is successfully transmitted This assignment consists of programming tasks in Flex Bison and also pencil and paper questions Submit programs according to the instructions in question 4 Submit all other written responses in a single PDF document It is okay if you scan in a handwritten document for some questions as long as everything is together in a single PDF document The Flex and Bison part of this assignment requires some minor coding in either C or C in order to capture tokens and also specify the semantic actions whenever a rewrite rule is invoked It is highly recommended that you get started right away on writing the scanner and grammar This will require some time to complete properly Your Flex and Bison assignments must be tested to execute properly on the CIMS computers using Flex 2 6 and Bison 3 7 Use the commands module load bison 3 7 and module load flex 2 6 on the CIMS computers to use these versions You can use any system you want to perform the development work but in the end it must run on the CIMS machines All students registered in this course who do not already have accounts on CIMS should have received an email with instructions on how to request an account While you are working on this assignment you may consult the lecture material class notes text book discussion forums and or recitation materials for general information concerning Flex Bison grammars or any topics related to the assignment You may under no circumstance collaborate with other students or use materials from an outside source i e people books Internet etc in answering specific homework questions However you may collaborate and utilize reference material for understanding the general topics covered by the homework For example discussing the topic of regular expressions or the C C programming languages with a classmate is permitted as long as the discussion does not involve homework questions or solutions 1 1 15 points Language Standards A programming language s standard serves as an authoritative source of information concerning that language Someone who claims expertise in a particular programming language should be thoroughly familiar with the language standard governing that language In the exercises below you will look into the language standards of several well known languages includ ing C C Java and C to find the answers to some basic questions You should use the standards documents on the course web page which contain recent publicly available documents1 In your answers to every question below you must cite the specific sections and passages in the relevant standard s serving as the basis for your answer No prior knowledge of either language is assumed nor expected but you cannot simply provide the answer with no evidential support from the standard or you will lose credit Do not cite to web pages books textbooks Stack Overflow or any other source other than the language standard 1 In C a class can be inherited from a base class using the protected access specifier What is the meaning of this See section 11 8 3 If a class is declared to be a base class for another class using the protected access specifier the public and protected members of the base class are accessible as protected members of the derived class 2 In C the user can create their own literals using four underlying C types What are the types What are the semantics of a user defined literal what happens when it is used Section 5 13 8 The types are integer floating point string and character The use of a user defined literal is treated as a call to a literal operator or literal operator template 3 In Java can data members of a class be initialized with default values if no other value is specified If so where can the default values be found Yes This is covered in 4 12 5 Initial Values of Variables 4 What are the two kinds of types in Java Section 4 1 covers this There are two kinds of types primitive and reference types 5 In Java what is an annotation How many are there and what are they Do they have any effect on the runtime behavior of the program Section 9 2 covers this An annotation is a marker which associates information with a program construct There are three kinds normal marker and single element It has no effect at runtime 6 In Java most people know or can at least guess what an assignment is But what about a definite assignment In your own words what does it mean to be definitely assigned and what does definite assignment ensure Section 16 covers this A variable must have a value before it is accessed except when a value is being assigned to the variable Definite assignment ensures that all execution paths will result in an assignment by the time the variable is accessed Definite assignment is a stronger concept than assignment It means that under all circumstances the variable will definitely have a value by the time it is accessed as opposed to it perhaps having a value 7 What are the three kinds of linkages defined in the context of identifiers in the C programming language Explain how each kind of linkage affects the visibility and scope of identifiers within a program Section 6 2 2 Page 29 The three kinds of linkage in C are external internal and none External linkage ensures that each declaration of an identifier across translation units denotes the same object or function while internal linkage limits this scope to within a single translation unit 1For example the C 23 standard is a copyrighted document that must be purchased at a high cost but the earlier 2020 working draft is free We therefore use the 2020 working draft for the purposes of this assignment and course Page 2 8 What is a delegate type in C What s the distinction between this and a C function pointer See section 9 2 8 As stated there a delegate is a data structure that refers to one or more methods For instance methods it also refers to their corresponding object instances Note The closest equivalent of a delegate in C
View Full Document
Unlocking...