Unformatted text preview:

Petros A Multi purpose Text File Manipulation Language Language Reference Manual Joseph Sherrick js2778 columbia edu June 20 2008 Table of Contents 1 2 3 4 5 6 7 Introduction Lexical Structure 2 1 Language Elements 2 2 White Space 2 3 Comments 2 4 Identifiers 2 5 Keywords 2 6 Separators 2 7 Operators 2 7 1 Assignment Operator 2 7 2 Concatenation Operator 2 7 3 End of Set Operator 2 7 4 Arithmetic Operators 2 7 5 Equality and Relational Operators 2 7 6 Logical Operators 2 7 7 Precedence Underlying Functions 3 1 Location Specification 3 2 delimit 3 3 print 3 4 write 3 5 read 3 6 file 3 7 insert 3 8 remove 3 9 done Data Types Statements 5 1 The if and elseif Statement 5 2 The if else Statement 5 3 The while Statement 5 4 The do Statement 5 5 The for Statement Expressions 6 1 Arithmetic Expressions 6 2 Conditional Expressions 6 3 Logical Expressions Example Program 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 6 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 11 1 Introduction Petros is a multi purpose text processing programming language Petros utilizes a pattern matching scheme to extract relevant information from a text file It is designed to provide a flexible framework from which a user can manipulate data by specifying a set of expressions and statements consisting of rules conditions and operations Relevant information pertaining to a specified relationship or location is educed from a text file to provide information or knowledge about the file s content 2 Lexical Structure Programs are written using the Unicode character set The Unicode characters resulting from the lexical translations are reduced to a sequence of elements Section 2 1 consisting of white space Section 2 2 comments Section 2 3 and tokens Tokens are comprised of identifiers Section 2 4 keywords Section 2 5 literals Section 4 and operators Section 2 7 of the syntactic grammar 2 1 Language Elements Language elements are the various pieces of a Petros program These elements provide the building blocks of text file manipulation by combining elements in a meaningful sequence Elements consist of tokens comments and white space Tokens are comprised of identifiers keywords literals separators and operators White space and comments serve to separate tokens provide structural organization and improve syntactic readability For example the keywords else and if can form the conditional statement token elseif only if there is no intervening white space or comment 2 2 White Space White space represents any non printable character such as the spacebar tab new line and form feed White space is not used to dictate the scope of variables or program flow It instead provides a means to separate tokens and is otherwise ignored by the compiler 2 3 Comments The Petros programming language provides two kinds of comments text text all the text between and is ignored all the text from to the end of the line is ignored 3 Both comment types employ the following properties comments do not nest both and have no special meaning in comments that begin with sequential characters have no special meaning within comments that begin and end with As a result the following example is a single complete comment this comment ends at the end of this sentence 2 4 Identifiers Identifiers refer to user defined variable names which are essential for symbolic processing An identifier is a sequence of letters and digits the first character is required to be a letter An identifier cannot have the same spelling as a keyword or literal Letters and digits may be draw from the entire character set This includes all uppercase and lowercase ASCII letters A through Z and a through z as well as ASCII digits 0 through 9 Two identifiers are considered equivalent if they contain the same character for each letter or digit All identifiers are case sensitive 2 5 Keywords Keywords represent a specific meaning to the Petros language and cannot be used as identifiers The comprehensive list of keywords includes if elseif read file 2 6 else for do insert remove while and or contains done delimit Separators The following characters are used as separators 2 7 2 7 1 encapsulates the arguments of a statement defines the body of a Petros statement specifies the structural location of data signifies the end of a statement separates the arguments of a statement Operators Assignment Operator used to initialize a particular identifier 4 print write 2 7 2 Concatenation Operator used to connect multiple series of characters together A series of numbers is assumed to be a string 2 7 3 End of Set Operator used to signify the final value of either rows or columns in the location specification Section 3 1 2 7 4 2 7 5 Arithmetic Operators additive operator subtraction operator multiplication operator division operator Equality and Relational Operators Equality and relational operators evaluate a particular relation between two entities These operators return true or false depending on whether the conditional relationship between the two operands holds or not The equality and relational operators include 2 7 6 equal to not equal to greater than greater than or equal to less than less than or equal to Logical Operators The condition is evaluated true or false as a Boolean expression On the basis of the evaluation the expression invokes some particular action The conditional operators include and evaluates to true if all conditions return true false otherwise or evaluates to true if at least one condition returns true false otherwise contains evaluates to true if all or some portion of an entity contains the specified element false otherwise 5 2 7 7 Precedence Expressions are evaluated as left associative Parentheses may be used to force precedence Table 1 depicts the precedence of operators in the Petros language from highest to lowest Precedence 1 2 3 4 5 Operator Description and or contains Parentheses Multiplication and Division Addition and Subtraction Relational and Equality Operators Logical And Or Contains Table 1 Precedence of Petros operators Shown from highest to lowest 3 3 1 Underlying Functions Location Specification x y j k An arbitrary location within a text file is specified in terms of a row and column The location can be a single row a range of rows and columns or a specific column within a row The range of rows and columns are separated by a colon Rows and columns are separated by a comma with the first parameter being a row and the second a column Both row and column numbers begin at the


View Full Document

Columbia COMS W4115 - Petros - A Multi-purpose Text File Manipulation Language

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

JTemplate

JTemplate

238 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Loading Unlocking...
Login

Join to view Petros - A Multi-purpose Text File Manipulation 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 Petros - A Multi-purpose Text File Manipulation 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?