DOC PREVIEW
UVA CS 415 - INTERCAL

This preview shows page 1-2-21-22 out of 22 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

INTERCALA note about the sourcesHistoryPolitenessConstantsVariablesArraysOperatorsBinary operatorsUnary operatorsPrecedenceStatementsSlide 13Slide 14Slide 15Slide 16COME FROMCommentsHello World ExampleAnother ExampleThat last program in comparisonBeyond INTERCALINTERCALAaron BloomfieldCS 415Fall 20052A note about the sourcesThe main sources for this lecture set are:The INTERCAL page in Wikipediahttp://en.wikipedia.org/wiki/IntercalThe INTERCAL Programming Language Revised Reference ManualOn the INTERCAL resources page: http://www.catb.org/~esr/intercal/Both sources are available under “free” licensesWikipedia under the GNU Free Documentation LicenseThe Reference Manual under the GPLIn accordance with these licenses, this work is also released under those same licenses3HistoryOriginally designed in 1972Main goal: “to have a compiler language which has nothing at all in common with any other major language”Only similarities are “basic” things such as:Variables, arrays, I/O, assignmentNothing else!Including all the arithmetic operators you are familiar with…INTERCAL stands for “Programming language without a pronounceable acronym”4PolitenessINTERCAL makes sure the programmer is politeStatements may be prefixed by PLEASEIf not enough PLEASEes are there, the compiler complains:PROGRAMMER IS INSUFFICIENTLY POLITEIF too many are there, the compiler also complains:PROGRAMMER IS OVERLY POLITEBetween ¼ and 1/3 of the statements must have PLEASE5ConstantsConstants are prefixed by a mesh (#)Can not be negative, and range from 0 to 65535Examples on next line#0 #32 #655356VariablesTwo types of variables:16-bit integerRepresented by the spot (.) followed by a number between 0 and 65535Examples on next line.1 .32 .6553532-bit integerRepresented by the two-spot (:)Examples on next line:0 :32 :4294967295Note that you can’t have negative numbersYou have to keep track of the sign separatelyFurther notes.123 and :123 are distinct variablesBut .1 and .0001 are identicalBut .001 is not 1E-37ArraysArray (of numbers) are represented by a tail (,) or a hybrid (;) for 16-bit and 32-bit values, respectivelyArray elements are suffixed by the word SUB, followed by the subscriptsIn summary:.123 :123 ,123 ;123 and #123 are all distinct8OperatorsINTERCAL recognized 5 operators: 2 binary, 3 unary“Please be kind to our operators: they may not be very intelligent, but they’re all we’ve got”The design intent was to be different than any other operators that existedBinary operatorsInterleave (aka mingle): represented by a change (¢)In an ASCII environment, you can use big money ($) insteadTakes two 16-bit values and interleaves their bits, producing a 32-bit valueSo #65535$#0 has 32-bit form 101010…10 (or 2863311530 decimal)Select: represented by a sqiggle [sic] (~)9Binary operatorsInterleave (aka mingle): represented by a change (¢)In an ASCII environment, you can use big money ($) insteadTakes two 16-bit values and interleaves their bits, producing a 32-bit valueSo #65535$#0 has 32-bit form 101010…10 (or 2863311530 decimal)Select: represented by a sqiggle [sic] (~)Finds which bits are 1 in the second operandSelects those bits from the first operandConsider #179~#201 (binary 10110011~11001001)From the second operand, selects bits 1, 2, 5, and 8Those bits in the first operand are 1, 0, 0, and 1, resepectivelyThus, the result is value #9Consider #201~#179 (binary 11001001~10110011)From the second operand, selects bits 1, 3, 4, 7, 8Those bits in the first operand are 1, 0, 0, 0, 1Thus, the result is #1710Unary operatorsThree types:Logical AND (&)Logical OR (V)Logical XOR ()In ASCII, written as a what (?)These characters are inserted between the spot, two-spot, mesh, etc., and the number:Examples on the next line.&123 #?123Cannot use multiple unary operatorsThese operators perform their respective operations on pairs of adjacent bits, with the result going into the position of where the first bit (of the pair) was in the original numberThe result of the first and last bits goes into the first bit of the resultExamples (77 is binary 1001101):#&77 is 0000000000000100 = 4#V77 is 1000000001101111 = 32879#?77 is 1000000001101011 = 3287511PrecedenceAs INTERCAL was intended “to have no precedents”, the compiler does not define what the operator precedence is“The precedence (or lack thereof) may be overruled by grouping expressions between pairs of sparks (‘) or rabbit-ears (“)”.Thus, ‘#165$#203’~#358 (binary value ‘10100101$11001011’~101100110) has value 1512StatementsLine labels are enclosed in wax-wane pairs (())Labels are (unique) integers from 1 to 65535Labels between 1000 and 1999 are used by the INTERCAL System Library functionsAfter the line label (if present), one of the following must occur:DOPLEASEPLEASE DOFollowing that, “either, neither, or both” of the following occur:NOT or N’T, which causes INTERCAL to abstain from that lineA number from 0 to 100, preceded by a double-oh-seven (%)This causes the statement to have that percentage of being executedFollowing all of this are one of the 14 valid operations13Statements1. CalculateThe assignment: instead of =, INTERCAL uses a angle (<) followed by a worm (-)32-bit values can get 16-bit values, and vise-versa if the value is less than 655352. NEXTOf the form:DO (label) NEXTPLEASE DO (label) NEXTUsed for subroutine calls and unconditional transfersTransfers control to that label AND stores it in a stack3. FORGETFollowed by an expressionCauses that many entries to be removed from the stack14Statements4. RESUMELike a FORGETBut jumps to the line label that is the last to be poppedUsed with NEXT (and FORGET) to do “subroutines”5. STASHStores variables and arrays so that subroutines can use the same variable namesVariables and arrays to stash are separated by intersections (+)6. RETRIEVERestores the previously STASHed values of the variables and arrays15Statements7. IGNOREFollowed by a variable (or array)Causes the variable to be unable to


View Full Document

UVA CS 415 - INTERCAL

Download INTERCAL
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view INTERCAL 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 INTERCAL 2 2 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?