Columbia COMS W4115 - PCGSL - Playing Card Game Simulation Language (83 pages)

Previewing pages 1, 2, 3, 4, 5, 6, 38, 39, 40, 41, 42, 78, 79, 80, 81, 82, 83 of 83 page document View the full content.
View Full Document

PCGSL - Playing Card Game Simulation Language



Previewing pages 1, 2, 3, 4, 5, 6, 38, 39, 40, 41, 42, 78, 79, 80, 81, 82, 83 of actual document.

View the full content.
View Full Document
View Full Document

PCGSL - Playing Card Game Simulation Language

138 views


Pages:
83
School:
Columbia University
Course:
Coms W4115 - Programming Languages and Translators
Programming Languages and Translators Documents
Unformatted text preview:

PCGSL Playing Card Game Simulation Language Enrique Henestroza eh2348 columbia edu Yuriy Kagan yk2159 columbia edu Andrew Shu ans2120 columbia edu Peter Tsonev pvt2101 columbia edu COMS W4115 Programming Languages and Translators December 19 2008 Contents 1 Introduction 1 1 Simple 3 3 2 Language Tutorial 4 3 Language Manual 3 1 Lexical Conventions 3 1 1 Comments 3 1 2 Identifiers 3 1 3 Keywords 3 1 4 Constants 3 1 5 Operators 3 1 6 Meaning of Identifiers 3 1 7 Scope Namespace and Storage Duration 3 2 Declarations 3 2 1 Variables 3 2 2 Functions 3 2 3 Special Blocks 3 3 Expressions and Operators 3 3 1 Precedence and Association Rules in PCGSL 3 3 2 Expressions 3 3 3 Function Calls 3 3 4 Assignment 3 4 Statements 3 4 1 Expression Statements 1 5 5 5 5 6 6 6 6 7 8 8 9 9 9 9 11 11 11 12 12 3 4 2 3 4 3 3 4 4 Selection Statements Iteration Statements Jump Statements 4 Project Plan 4 1 Planning Specification 4 2 Development Testing 4 3 Programming Style Guide 4 4 Project timeline 4 5 Roles and Responsibilities 4 6 Software Development Environment 4 7 Project Log 5 Architectural Design 12 12 13 14 14 15 15 17 17 18 18 19 2 Chapter 1 Introduction The Playing Card Game Simulation Language PCGSL is designed to be a simple programming language for programming card games Our language allows a programmer to work within a standard set of conventions and procedures for playing card games without having to write a large amount of code as one would have to in a general purpose language This allows the programmer to focus on creating randomized simulations of popular games or hands as well as quick mock ups of new games based around standard 52 card decks 1 1 Simple PCGSL is simple to learn Using well known C style imperative syntax conventions our language 3 Chapter 2 Language Tutorial 4 Chapter 3 Language Manual 3 1 Lexical Conventions This section covers the lexical conventions including comments and tokens A token is a series of contiguous characters that the compiler treats as a unit Blanks tabs newlines and comments are collectively known as white space White space is ignored except as it serves to separate tokens Some white space is required to separate otherwise adjacent identifiers keywords and constants If the input stream has been parsed into tokens up to a given character the next token is taken to include the longest string of characters that could possibly constitute a token 3 1 1 Comments The characters introduce a comment a newline terminates a comment The characters do not indicate a comment when occurring within a string literal Comments do not nest Once the introducing a comment are seen all other characters are ignored until the ending newline is encountered 3 1 2 Identifiers An identifier is a sequence of letters digits and underscores The first character cannot be a digit Uppercase and lowercase letters are distinct Identifier length is unlimited 5 3 1 3 Keywords The identifiers listed below are reserved for use as keywords and cannot be used for any other purpose Among these are a group of reserved identifiers corresponds to card names for a standard 52 card deck break Play CardEntities return else Start false true Globals while If WinCondition Include var null H2 H3 H4 H5 H6 H7 H8 H9 H10 HJ HQ HK HA D2 D3 D4 D5 D6 D7 D8 D9 D10 DJ DQ DK DA C2 C3 C4 C5 C6 C7 C8 C9 C10 CJ CQ CK CA S2 S3 S4 S5 S6 S7 S8 S9 S10 SJ SQ SK SA 3 1 4 Constants The two types of constants are integer and character string Integer Constants An integer constant consists of a sequence of one or more digits and is always considered decimal String Constants A string constant is a sequence of characters surrounded by double quotation marks such as Hello World We consider characters to be ASCII printable characters 3 1 5 Operators An operator specifies an operation to be performed The operators are shown below 3 1 6 Meaning of Identifiers Identifiers are disambiguated by their type scope and namespace No identifier will have linkage and storage duration will be determined by the scope e g identifiers within the 6 same scope will have the same storage duration Type Our language has four fundamental object types int string boolean and Card In addition there are two derived types list and CardEntity There is no notion of a floating point number since it is not really needed in card games There is also no need for a char type since it can be simulated by a string consisting of a single ASCII symbol int the int type can represent an arbitrary integer since it will be mapped to the OCaml integer internally bool the bool type represents a boolean either of the value true or false It is mapped to OCaml boolean internally string the string type will be able to hold arbitrary strings since it will also be mapped to OCaml strings internally Card the Card type is a basic type that represents one of the 52 cards in a standard playing card deck list the list type is a derived type since it is a collection of fundamental objects They have an attribute called length that stores the length of the list CardEntity The CardEntity type represents a certain participant in the card game who can be active e g a player or passive e g a deck or a flop Each CardEntity has a list of Card objects that belongs to it and special operators for transferring Card objects among CardEntity objects 3 1 7 Scope Namespace and Storage Duration Unlike C identifiers PCGSL identifiers have no linkage e g the scopes are disjoint Scope The scope specifies the region where certain identifiers are visible PCGSL employs static scope There are two kinds of scope and they do not intersect 7 Global scope variables defined within the Globals block have global scope Global variables cannot be defined in functions or any other block Global variables are accessed via the symbol Therefore there are no intersections with the local scope Function Block scope variables declared within a function or block will be visible within that function or block Nested functions or blocks are disallowed in the language Namespace Functions and blocks share a namespace Variables have their own namespace as do CardEntities None of these three namespaces overlap Storage Duration Local variables have automatic storage duration Their lifetime expires after the function in which they are defined returns Global variables have static storage duration and live from their declaration to the end of program execution 3 2 Declarations A declaration specifies the interpretation given to a set of


View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view PCGSL - Playing Card Game Simulation Language and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view PCGSL - Playing Card Game Simulation Language and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?