ANTLR 4. Programming Assignment #3
|
|
- Stephany Lucas
- 6 years ago
- Views:
Transcription
1 ANTLR 4 Programming Assignment #3
2 C++ auto keyword C++03: variable s type must be specified explicitly Since C++11: definition of variable with an explicit initialization can use the auto keyword Type inference C++11 auto some_int = 5; C++03 int some_int = 5; 2
3 C++ auto keyword (cont d) Syntax auto variable initializer auto function (since C++11) (since C++14) Example auto.cpp #include <iostream> using namespace std; auto add(int a, int b) { return a + b; $ g++ std=c++14 o auto auto.cpp $./auto int main( ) { auto a = ; auto b = add(2, 3); cout<<a<<endl; cout<<b<<endl; return 0; 3
4 C++ auto keyword (cont d) Syntax auto variable initializer auto function (since C++11) (since C++14) Example auto.cpp #include <iostream> using namespace std; auto add(int a, int b) { return a + b; int main( ) { auto a = ; auto b = add(2, 3); cout<<a<<endl; cout<<b<<endl; return 0; $ g++ std=c++14 o auto auto.cpp $./auto
5 C auto keyword Storage class specifier auto, extern, static, register keyword auto are rarely used variable inside a function is automatic by default Not datatype int main( ) { auto int a; int main( ) { int a; 5
6 Compiler auto datatype Use gcc/g++ version 4.9 or higher auto.c #include <stdio.h> auto add(int a, int b) { return a + b; int main( ) { auto a = ; auto b = add(2, 3); printf( %f \n, a); printf( %d \n, b); return 0; $ gcc std=c11 auto.c auto.c: error or warning $ g++ std=c++14 auto.c $./a.out
7 PA#3 AutoC2CApp implement auto datatype C source-to-ansi C source compiler output is source code which uses ANSI C datatype (covers int, float, void, char) Based on the PA#2 (C2CApp) Use ANTLR Visitor (not Listener) 7
8 PA#3 (cont d) Make variable & function symbol table Implement type checking (type inference) Use static scoping int i; auto a; auto b; a = ; type checking var/func datatype i int a auto float b auto 8
9 PA#3 Listener (cont d) program function #include <stdio.h> void main( ) { auto g; auto A(int a) { g = 3 + a; g = 1; A(3); // g = 6 declaration function assignstmt callstmt DFS g = 1? assignstmt wrong type checking can cause enterprogram enterfunction enterdeclaration auto g; exitdeclaration auto g; enterfunction enterassignstmt g = 3 + a; exitassignstmt g = 3 + a; exitfunction enterassignstmt g = 1; exitassignstmt g = 1; entercallstmt exitcallstmt exitfunction exitprogram 9
10 PA#3 Visitor (cont d) program visitx( ) function #include <stdio.h> declaration function assignstmt callstmt void main( ) { auto g; auto A(int a) { g = 3 + a; g = 1; A(3); // g = 6 assignstmt can visit any node g = 6 visitprogram visitfunction visitdeclaration auto g; visitassignstmt g = 1; visitcallstmt visitfunction visitassignstmt g = 3 + a; 10
11 PA#3 (cont d) Input & Output auto.c #include <stdio.h> void main( ) { auto g; auto A(int a) { g = 3 + a; g = 1; A(3); gcc compile X output_auto.c #include <stdio.h> void main( ) { int g; void A(int a) { g = 3 + a; g = 1; A(3); gcc compile O 11
12 PA#3 AutoC grammar 12 grammar AutoC; (cont d) program : inclist? decllist? funclist? ; stmt : assignstmt callstmt retstmt whilestmt forstmt ifstmt switchstmt compoundstmt ; expr : Unop expr expr Unop expr expr Addiop expr expr Multop expr expr Relaop expr expr Eqltop expr call Intnum Floatnum Id Id '[' expr ']' '(' expr ')' StringLiteral ; Type : int float void char auto ; compoundstmt : { decllist? funclist? stmtlist ;...
13 PA#3 (cont d) Skeleton code AutoC2CApp.java class C2CVisitor extends CBaseVisitor<Integer> { Stack<StringBuilder> out = new Stack<StringBuilder>(); public Integer visitdirectivedefinition(@notnull CParser.DirectiveDefinitionContext ctx) { if(ctx.getparent() instanceof CParser.IncListContext) for (int i=0; i< ctx.getchildcount(); i++) out.peek().append(ctx.getchild(i).gettext()+"\n"); return public Integer visitfunction(@notnull CParser.FunctionContext ctx) { for (int i=0; i < ctx.getchildcount(); i++) if (ctx.getchild(i) instanceof TerminalNode) out.peek().append(ctx.getchild(i).gettext()+" "); return public Integer visitterminal(terminalnode node) { if(node.getparent().getparent().getparent() instanceof CParser.ProgramContext==false) out.peek().append(node.gettext()+'\n'); return null; public class AutoC2CApp { public static void main(string[] args) throws IOException { // Input file if (args.length!= 1){ System.err.println("Input C file"); System.exit(1); String filename = args[0]; System.setIn(new FileInputStream(filename)); InputStream input = System.in; // Get lexer CLexer lexer = new CLexer(new ANTLRInputStream(input)); // Get a list of matched tokens CommonTokenStream tokens = new CommonTokenStream(lexer); // Pass tokens to parser CParser parser = new CParser(tokens); // ParseTree ParseTree tree = parser.program(); // our visitor C2CVisitor visitor = new C2CVisitor(); // visit Cparser visitor.visit(tree); // Output file FileOutputStream output = new FileOutputStream(new File("output_"+args[0])); System.out.println("Output file name: output_"+args[0]); output.write(visitor.out.peek().tostring().getbytes()); output.flush(); output.close(); 13
14 Summary PA#3 auto datatype C source-to-ansi C source compiler use Visitor only implement your own type checking methods with static scoping output source code must be compiled by gcc due by 6 June All 3 PAs can be resubmitted until final exam(16 June) maximum 5 points resubmission via (sspark@arcs.skku.edu) 14
Tree visitors. Context classes. CS664 Compiler Theory and Design LIU 1 of 11. Christopher League* 24 February 2016
CS664 Compiler Theory and Design LIU 1 of 11 Tree visitors Christopher League* 24 February 2016 Context classes ANTLR automatically generates heterogeneous representations of the parse trees for your grammar.
More informationInstall and Configure ANTLR 4 on Eclipse and Ubuntu
Install and Configure ANTLR 4 on Eclipse and Ubuntu Ronald Mak Department of Computer Engineering Department of Computer Science January 20, 2019 Introduction ANTLR 4 ( Another Tool for Language Recognition
More informationTHE PROGRAMMING LANGUAGE NINC PARSER PROJECT. In this project, you will write a parser for the NINC programming language. 1.
THE PROGRAMMING LANGUAGE NINC PARSER PROJECT DR. GODFREY C. MUGANDA NORTH CENTRAL COLLEGE In this project, you will write a parser for the NINC programming language. 1. NINC Overview NINC contains three
More informationProject 2 Interpreter for Snail. 2 The Snail Programming Language
CSCI 2400 Models of Computation Project 2 Interpreter for Snail 1 Overview In this assignment you will use the parser generator yacc to construct an interpreter for a language called Snail containing the
More informationSyntax Analysis/Parsing. Context-free grammars (CFG s) Context-free grammars vs. Regular Expressions. BNF description of PL/0 syntax
Susan Eggers 1 CSE 401 Syntax Analysis/Parsing Context-free grammars (CFG s) Purpose: determine if tokens have the right form for the language (right syntactic structure) stream of tokens abstract syntax
More informationExercise ANTLRv4. Patryk Kiepas. March 25, 2017
Exercise ANTLRv4 Patryk Kiepas March 25, 2017 Our task is to learn ANTLR a parser generator. This tool generates parser and lexer for any language described using a context-free grammar. With this parser
More informationContext-free grammars (CFG s)
Syntax Analysis/Parsing Purpose: determine if tokens have the right form for the language (right syntactic structure) stream of tokens abstract syntax tree (AST) AST: captures hierarchical structure of
More informationSyntax Errors; Static Semantics
Dealing with Syntax Errors Syntax Errors; Static Semantics Lecture 14 (from notes by R. Bodik) One purpose of the parser is to filter out errors that show up in parsing Later stages should not have to
More informationSML-SYNTAX-LANGUAGE INTERPRETER IN JAVA. Jiahao Yuan Supervisor: Dr. Vijay Gehlot
SML-SYNTAX-LANGUAGE INTERPRETER IN JAVA Jiahao Yuan Supervisor: Dr. Vijay Gehlot Target Design SML-Like-Syntax Build Parser in ANTLR Abstract Syntax Tree Representation ANLTER Integration In Interpreter
More informationffl assign The assign has the form: identifier = expression; For example, this is a valid assign : var1 = 20-3*2; In the assign the identifier gets th
CSCI 2400 Models of Computation Project 2 Yacc Return Day: Friday, November 30. Teams: You must form teams of 2 or 3 persons. 1 Overview In this assignment you will use the parser generator yacc to construct
More informationCS664 Compiler Theory and Design LIU 1 of 16 ANTLR. Christopher League* 17 February Figure 1: ANTLR plugin installer
CS664 Compiler Theory and Design LIU 1 of 16 ANTLR Christopher League* 17 February 2016 ANTLR is a parser generator. There are other similar tools, such as yacc, flex, bison, etc. We ll be using ANTLR
More informationThe Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer.
The Compiler So Far CSC 4181 Compiler Construction Scanner - Lexical analysis Detects inputs with illegal tokens e.g.: main 5 (); Parser - Syntactic analysis Detects inputs with ill-formed parse trees
More informationVariables Data types Variable I/O. C introduction. Variables. Variables 1 / 14
C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition
More informationSyntax. A. Bellaachia Page: 1
Syntax 1. Objectives & Definitions... 2 2. Definitions... 3 3. Lexical Rules... 4 4. BNF: Formal Syntactic rules... 6 5. Syntax Diagrams... 9 6. EBNF: Extended BNF... 10 7. Example:... 11 8. BNF Statement
More informationFundamentals of Programming Session 12
Fundamentals of Programming Session 12 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2014 These slides have been created using Deitel s slides Sharif University of Technology Outlines
More informationComputational Expression
Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name
More informationLexical and Syntax Analysis
Lexical and Syntax Analysis (of Programming Languages) Bison, a Parser Generator Lexical and Syntax Analysis (of Programming Languages) Bison, a Parser Generator Bison: a parser generator Bison Specification
More informationAutomated Tools. The Compilation Task. Automated? Automated? Easier ways to create parsers. The final stages of compilation are language dependant
Automated Tools Easier ways to create parsers The Compilation Task Input character stream Lexer Token stream Parser Abstract Syntax Tree Analyser Annotated AST Code Generator Code CC&P 2003 1 CC&P 2003
More informationCOMP3131/9102: Programming Languages and Compilers
COMP3131/9102: Programming Languages and Compilers Jingling Xue School of Computer Science and Engineering The University of New South Wales Sydney, NSW 2052, Australia http://www.cse.unsw.edu.au/~cs3131
More information/22. Clang Tutorial. Moonzoo Kim School of Computing KAIST. The original slides were written by Yongbae Park,
/22 Clang Tutorial Moonzoo Kim School of Computing KAIST The original slides were written by Yongbae Park, yongbae2@gmail.com 1 /22 Content Motivation of learning code analysis technique Overview of Clang
More informationCS 314 Principles of Programming Languages. Lecture 9
CS 314 Principles of Programming Languages Lecture 9 Zheng Zhang Department of Computer Science Rutgers University Wednesday 5 th October, 2016 Zheng Zhang 1 CS@Rutgers University Class Information Homework
More informationCS /534 Compiler Construction University of Massachusetts Lowell. NOTHING: A Language for Practice Implementation
CS 91.406/534 Compiler Construction University of Massachusetts Lowell Professor Li Xu Fall 2004 NOTHING: A Language for Practice Implementation 1 Introduction NOTHING is a programming language designed
More informationCreating, Compiling and Executing
Shell Commands & Vi Compiling C programs Creating, Compiling and Executing Creating program #i n c l u d e i n t main ( ) { p r i n t f ( AA\n ) ; p r i n t f ( A A\n ) ; p r i n t f ( A
More informationCSCE 314 Programming Languages. Type System
CSCE 314 Programming Languages Type System Dr. Hyunyoung Lee 1 Names Names refer to different kinds of entities in programs, such as variables, functions, classes, templates, modules,.... Names can be
More informationBuilding Compilers with Phoenix
Building Compilers with Phoenix Parser Generators: ANTLR History of ANTLR ANother Tool for Language Recognition Terence Parr's dissertation: Obtaining Practical Variants of LL(k) and LR(k) for k > 1 PCCTS:
More informationAMCAT Automata Coding Sample Questions And Answers
1) Find the syntax error in the below code without modifying the logic. #include int main() float x = 1.1; switch (x) case 1: printf( Choice is 1 ); default: printf( Invalid choice ); return
More informationCSE 333 Midterm Exam 7/25/16. Name UW ID#
Name UW ID# There are 7 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,
More informationAnnouncements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy
CSCI 334: Principles of Programming Languages Lecture 18: C/C++ Homework help session will be tomorrow from 7-9pm in Schow 030A instead of on Thursday. Instructor: Dan Barowy HW6 and HW7 solutions We only
More informationffl assign : The assign has the form: identifier = expression ; For example, this is a valid assign : var1 = 20-3*2 ; In the assign the identifier get
CSCI 2400 Models of Computation, Section 3 Programming Assignment 2 Yacc Return Day: Monday, December 4. Teams: You are encouraged to form teams of 2 persons. 1 Overview In this assignment you will use
More informationWhy VC++ instead of Dev C++?
Why VC++ instead of Dev C++? I love UNIX! I am proficient in UNIX! I like public domain open source software. I love GPL. I was more confident in GCC than in Microsoft C. But! The software business has
More informationArray. Prepared By - Rifat Shahriyar
Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types
More informationClass, Variable, Constructor, Object, Method Questions
Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx
More informationAN OVERVIEW OF C++ 1
AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function
More informationAn Introduction to LEX and YACC. SYSC Programming Languages
An Introduction to LEX and YACC SYSC-3101 1 Programming Languages CONTENTS CONTENTS Contents 1 General Structure 3 2 Lex - A lexical analyzer 4 3 Yacc - Yet another compiler compiler 10 4 Main Program
More information4. C++ functions. 1. Library Function 2. User-defined Function
4. C++ functions In programming, function refers to a segment that group s code to perform a specific task. Depending on whether a function is predefined or created by programmer; there are two types of
More informationCS453 CLASSES, VARIABLES, ASSIGNMENTS
CS453 CLASSES, VARIABLES, ASSIGNMENTS CS453 Lecture Code Generation for Classes 1 PA6 new in MeggyJava member / instance variables local variables assignments let s go check out the new MeggyJava grammar
More information(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution
Ch 5 Arrays Multiple Choice 01. An array is a (A) (B) (C) (D) data structure with one, or more, elements of the same type. data structure with LIFO access. data structure, which allows transfer between
More informationI pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.
Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationThe component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science
The component base of C language Nguyễn Dũng Faculty of IT Hue College of Science Content A brief history of C Standard of C Characteristics of C The C compilation model Character set and keyword Data
More informationEDA180: Compiler Construc6on. Top- down parsing. Görel Hedin Revised: a
EDA180: Compiler Construc6on Top- down parsing Görel Hedin Revised: 2013-01- 30a Compiler phases and program representa6ons source code Lexical analysis (scanning) Intermediate code genera6on tokens intermediate
More informationParser and syntax analyzer. Context-Free Grammar Definition. Scanning and parsing. How bottom-up parsing works: Shift/Reduce tecnique.
POLITECNICO I TORINO Parser and syntax analyzer (01JEUHT) Formal Languages and Compilers Laboratory N 2 Stefano Scanzio mail: Web: http://www.skenz.it/compilers Given a non-ambiguous grammar and a sequence
More informationClass Information ANNOUCEMENTS
Class Information ANNOUCEMENTS Third homework due Friday, October 13, 11:59pm. First project will be posted soon. Midterm exam: Friday, October 27, in class. Don t forget to work on your C and Linux skills
More informationKay Schlühr.
Kay Schlühr kay@fiber-space.de EE Everything begun...... with a tiny arrow operator as a visual clue >>> -> A0 A4 00 00 3F 00 EE But where do we find arrows? easy to parse as console input easy to parse
More informationpublic LLParser( String sourcefile, boolean verbose ) source file location verbose mode switch
--------------------------------------------------------------------- [ITP404/Compiler Theory] Project II - manual.pdf Author: Charmgil, Hong / 20200636 CSEE ---------------------------------------------------------------------
More informationFast Introduction to Object Oriented Programming and C++
Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming
More informationBTE2313. Chapter 2: Introduction to C++ Programming
For updated version, please click on http://ocw.ump.edu.my BTE2313 Chapter 2: Introduction to C++ Programming by Sulastri Abdul Manap Faculty of Engineering Technology sulastri@ump.edu.my Objectives In
More informationSemantic actions for declarations and expressions
Semantic actions for declarations and expressions Semantic actions Semantic actions are routines called as productions (or parts of productions) are recognized Actions work together to build up intermediate
More informationCharacter Stream : It provides a convenient means for handling input and output of characters.
Be Perfect, Do Perfect, Live Perfect 1 1. What is the meaning of public static void main(string args[])? public keyword is an access modifier which represents visibility, it means it is visible to all.
More informationExamination in Compilers, EDAN65
Examination in Compilers, EDAN65 Department of Computer Science, Lund University 2016 10 28, 08.00-13.00 Note! Your exam will be marked only if you have completed all six programming lab assignments in
More informationKU Compilerbau - Programming Assignment
716.077 KU Compilerbau - Programming Assignment Univ.-Prof. Dr. Franz Wotawa, Birgit Hofer Institute for Software Technology, Graz University of Technology April 20, 2011 Introduction During this semester
More informationSoftware Tools ANTLR
2009 Software Tools ANTLR Part II - Lecture 8 1 The University of Auckland New Zealand COMPSCI 732 Today s Outline 2009 Introduction to ANTLR Parsing Actions Generators 2 The University of Auckland New
More informationEECS483 D1: Project 1 Overview
EECS483 D1: Project 1 Overview Chun-Hung Hsiao Jan 11, 2013 Special thanks to Ashutosh 1 Course Websites http://www.eecs.umich.edu/courses/eecs483/ Schedule, lecture slides https://piazza.com/class#winter2013/
More informationCOMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table
COMPILER CONSTRUCTION Lab 2 Symbol table LABS Lab 3 LR parsing and abstract syntax tree construction using ''bison' Lab 4 Semantic analysis (type checking) PHASES OF A COMPILER Source Program Lab 2 Symtab
More informationCSE P 501 Compilers. Parsing & Context-Free Grammars Hal Perkins Winter /15/ Hal Perkins & UW CSE C-1
CSE P 501 Compilers Parsing & Context-Free Grammars Hal Perkins Winter 2008 1/15/2008 2002-08 Hal Perkins & UW CSE C-1 Agenda for Today Parsing overview Context free grammars Ambiguous grammars Reading:
More informationProgramming in C UVic SEng 265
Programming in C UVic SEng 265 Daniel M. German Department of Computer Science University of Victoria 1 SEng 265 dmgerman@uvic.ca C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier,
More informationProgramming in C. What is C?... What is C?
C Programming in C UVic SEng 265 Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version
More informationDOMjudge team manual. Summary. Reading and writing. Submitting solutions. Viewing scores, submissions, etc.
judge DOMjudge team manual Summary /\ DOM DOM judge Here follows a short summary of the system interface. This is meant as a quick introduction, to be able to start using the system. It is, however, strongly
More informationDecaf Language Reference
Decaf Language Reference Mike Lam, James Madison University Fall 2016 1 Introduction Decaf is an imperative language similar to Java or C, but is greatly simplified compared to those languages. It will
More informationLecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8
Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How
More informationSri Vidya College of Engineering & Technology Question Bank
1. What is exception? UNIT III EXCEPTION HANDLING AND I/O Part A Question Bank An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program s instructions.
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationLab Exam 1 D [1 mark] Give an example of a sample input which would make the function
CMPT 127 Spring 2019 Grade: / 20 First name: Last name: Student Number: Lab Exam 1 D400 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return -1? Answer:
More informationProgramming in C. What is C?... What is C?
Programming in C UVic SEng 265 C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version
More informationCOMP322 - Introduction to C++
COMP322 - Introduction to C++ Winter 2011 Lecture 2 - Language Basics Milena Scaccia School of Computer Science McGill University January 11, 2011 Course Web Tools Announcements, Lecture Notes, Assignments
More informationA Bison Manual. You build a text file of the production (format in the next section); traditionally this file ends in.y, although bison doesn t care.
A Bison Manual 1 Overview Bison (and its predecessor yacc) is a tool that take a file of the productions for a context-free grammar and converts them into the tables for an LALR(1) parser. Bison produces
More informationCSE302: Compiler Design
CSE302: Compiler Design Instructor: Dr. Liang Cheng Department of Computer Science and Engineering P.C. Rossin College of Engineering & Applied Science Lehigh University March 27, 2007 Outline Recap General/Canonical
More information( &% class MyClass { }
Recall! $! "" # ' ' )' %&! ( &% class MyClass { $ Individual things that differentiate one object from another Determine the appearance, state or qualities of objects Represents any variables needed for
More information(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution
Ch 5 Arrays Multiple Choice Test 01. An array is a ** (A) data structure with one, or more, elements of the same type. (B) data structure with LIFO access. (C) data structure, which allows transfer between
More informationToday. Assignments. Lecture Notes CPSC 326 (Spring 2019) Quiz 5. Exam 1 overview. Type checking basics. HW4 due. HW5 out, due in 2 Tuesdays
Today Quiz 5 Exam 1 overview Type checking basics Assignments HW4 due HW5 out, due in 2 Tuesdays S. Bowers 1 of 11 Exam Overview Basics closed notes, book, etc. 4 multi-part questions worth 15% of final
More informationCIS133J. Working with Numbers in Java
CIS133J Working with Numbers in Java Contents: Using variables with integral numbers Using variables with floating point numbers How to declare integral variables How to declare floating point variables
More informationDOMjudge team manual. Summary. Reading and writing. Submitting solutions. Viewing scores, submissions, etc.
judge DOMjudge team manual Summary /\ DOM DOM judge Here follows a short summary of the system interface. This is meant as a quick introduction, to be able to start using the system. It is, however, strongly
More informationCS2141 Software Development using C/C++ C++ Basics
CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationBaby Steps: Some Simple Programs in C, C++, and Java
Baby Steps: Some Simple Programs in C, C++, and Java Two Goals: To introduce the rudiments of OO vocabulary by showing the easily established conceptual parallels between C, C++, and Java programs. To
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationDOMjudge team manual. Summary. Reading and writing. Submitting solutions. Viewing scores, submissions, etc.
judge DOMjudge team manual Summary /\ DOM DOM judge Here follows a short summary of the system interface. This is meant as a quick introduction, to be able to start using the system. It is, however, strongly
More informationAn ANTLR Grammar for Esterel
An ANTLR Grammar for Esterel COMS W4115 Prof. Stephen A. Edwards Fall 2005 Columbia University Department of Computer Science ANTLR Esterel.g class EsterelParser extends Parser; file : expr EOF!; class
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationParser Generation. Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team. Mainly with applications to! language processing
Parser Generation Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team Mainly with applications to! language processing Program generation Specification Program generator Program Parser
More informationLearning the Java Language. 2.1 Object-Oriented Programming
Learning the Java Language 2.1 Object-Oriented Programming What is an Object? Real world is composed by different kind of objects: buildings, men, women, dogs, cars, etc. Each object has its own states
More informationSyntax and Variables
Syntax and Variables What the Compiler needs to understand your program, and managing data 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line
More informationCompiler Construction
Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-17/cc/ Recap: LR(1) Parsing LR(1) Items and Sets Observation:
More informationA Short Summary of Javali
A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler
More informationTirgul 1. Course Guidelines. Packages. Special requests. Inner classes. Inner classes - Example & Syntax
Tirgul 1 Today s topics: Course s details and guidelines. Java reminders and additions: Packages Inner classes Command Line rguments Primitive and Reference Data Types Guidelines and overview of exercise
More information[0569] p 0318 garbage
A Pointer is a variable which contains the address of another variable. Declaration syntax: Pointer_type *pointer_name; This declaration will create a pointer of the pointer_name which will point to the
More informationDOMjudge team manual. Summary. Reading and writing. Submitting solutions. Viewing scores, submissions, etc.
judge DOMjudge team manual Summary /\ DOM DOM judge This page gives a short summary of the system interface. The summary is meant as a quick introduction, to be able to start using the system. It is however
More informationCOMP322 - Introduction to C++ Lecture 02 - Basics of C++
COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.
More informationUnit 7. Functions. Need of User Defined Functions
Unit 7 Functions Functions are the building blocks where every program activity occurs. They are self contained program segments that carry out some specific, well defined task. Every C program must have
More informationAbout this exam review
Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review
More informationIntermediate Programming, Spring 2017*
600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general
More informationLab 2 Tutorial (An Informative Guide)
Lab 2 Tutorial (An Informative Guide) Jon Eyolfson University of Waterloo October 18 - October 22, 2010 Outline Introduction Good News Lexer and Parser Infrastructure Your Task Example Conclusion Jon Eyolfson
More informationCompiler Construction
Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-17/cc/ Recap: LR(1) Parsing Outline of Lecture 11 Recap: LR(1)
More informationCSE 333 Midterm Exam 7/25/16 Sample Solution. Question 1. (10 points) Preprocessor. Suppose we have the following two files:
Question 1. (10 points) Preprocessor. Suppose we have the following two files: defs.h: #define DIV(a,b) a / b #define INCDIV(c,d) DIV(c + 1, d + 1) main.c: #include #include "defs.h" int main()
More informationIntroduction to Compiler Design
Introduction to Compiler Design Lecture 1 Chapters 1 and 2 Robb T. Koether Hampden-Sydney College Wed, Jan 14, 2015 Robb T. Koether (Hampden-Sydney College) Introduction to Compiler Design Wed, Jan 14,
More informationIntroduction to C An overview of the programming language C, syntax, data types and input/output
Introduction to C An overview of the programming language C, syntax, data types and input/output Teil I. a first C program TU Bergakademie Freiberg INMO M. Brändel 2018-10-23 1 PROGRAMMING LANGUAGE C is
More informationB.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University
Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are
More informationWeek 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O
Week 12 Streams and File I/O Overview of Streams and File I/O Text File I/O 1 I/O Overview I/O = Input/Output In this context it is input to and output from programs Input can be from keyboard or a file
More informationNAMESPACES IN C++ You can refer the Programming with ANSI C++ by Bhushan Trivedi for Understanding Namespaces Better(Chapter 14)
NAMESPACES IN C++ You can refer the Programming with ANSI C++ by Bhushan Trivedi for Understanding Namespaces Better(Chapter 14) Some Material for your reference: Consider following C++ program. // A program
More information