Example: quiz answers

The C-- Language Reference Manual

TheC-- Language Reference ManualSimon Peyton JonesThomas NordinDino OlivaPablo Nogueira IglesiasApril 23, 1998 Contents1 Introduction32 Syntax General .. Comments .. Names .. Name scope .. Theimportandexportdeclarations .. Constants .. Integer and floating point numbers .. Characters and strings .. 73 Fundamental concepts Memory .. Data segment .. Code segment .. Types .. Local variables (or registers) .. Addresses .. Names.

The C--Language Reference Manual Simon Peyton Jones Thomas Nordin Dino Oliva Pablo Nogueira Iglesias April 23, 1998 Contents 1 Introduction 3 2 Syntax definition 3

Tags:

  Manual, Language, Reference, The c language reference manual

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of The C-- Language Reference Manual

1 TheC-- Language Reference ManualSimon Peyton JonesThomas NordinDino OlivaPablo Nogueira IglesiasApril 23, 1998 Contents1 Introduction32 Syntax General .. Comments .. Names .. Name scope .. Theimportandexportdeclarations .. Constants .. Integer and floating point numbers .. Characters and strings .. 73 Fundamental concepts Memory .. Data segment .. Code segment .. Types .. Local variables (or registers) .. Addresses .. Names.

2 Foreign Language interface .. 94 Data layout Labels .. Initialisation .. Alignment .. 1215 Procedure definition .. Statements .. ;.. Declaration .. Assignment .. Memory write .. relational operations .. Local control labels andgoto.. Procedure call .. Foreign Language interface .. 196 Introduction .. Memory read .. Operators, precedence, and evaluation order .. Primitives .. Exception handling .. Casting.

3 And primitives .. +and-.. *.. ,|, and .. <<and>>.. and primitives .. +f,-f, and*f.. 327 Further Work331 IntroductionC--is a portable assembly Language designed to be a good backendfor high level languages (par-ticularly for those that make use of garbage-collection) and to run fast on a number of todays majorcomputer architectures. It is also designed to have as few dependencies as possible on the under-lying hardware, but speed and ease of use has sometimes takenprecedence over orthogonality be rich enough to be a viable backend for most mainstream and paper should be sufficiently self-supporting so that anyone who knows an imperative languageand is acquainted with computers should be able to write her/his ownC--programs after reading Syntax definitionThe syntax ofC--is given in Figures 1 and GeneralAC--program file is written in eight bit ASCII characters.

4 It consists in a sequence ofdatalayoutdirectives (Section 4), and/or procedure definitions (Section 5), and/orimportdeclarations, and/orexportdeclarations (Section ), interleaved in any unitis aC--program file that can be successfully compiled and that is suitablefor not support input/output. Nevertheless, it can be accomplished using a foreign languagecall (Section ).3 Programprogram!pal[program]Palpal!dataj[ conv]Name(arg1,:::argn)[data]blockn 0jimportName1,:::Namen;n 1jexportName1,:::Namen;n 1 Datadata!

5 Data {datum1:::datumn}n 1 Datumdatum!Name:jtype[[sconst]][{expr1,: ::exprn}];n 1jtype[]{expr1,:::exprn} ;n 1jword1[]AsciiString;Abbreviationjword2[ ]UnicodeString;Abbreviationjalignn;Align mentdirectiveSimpleConstantssconst!NumIn tegerconstantj char Asciichar:constantjunicode( char )Unicodechar:constantConstantsconst!scon stSimpleconstantsjFNumFloatnumberconstan tjNameSymbolicconstantjAsciiStringString constantjUnicodeStringUnicodestringconst antStringsAsciiString!"char1:::charn"n 0 UnicodeString!unicode("char1:::charn")n 0 Conventionconv!

6 ForeignconvkindConventiondeclarationConv entionsconvkind!CCallingConventionsjPasc alj:::FormalArgumentsarg!typeNameTypetyp e!wordnjfloatmn2f1;2;4;8g;m2f4;8gBlockbl ock!{stm1:::stmn}n 0 Figure 1:C--syntax4 Statementsstm!skip;NullstatementjtypeNam e1,:::Namen;Var:decl:;n 1jName=expr;Assignmentjtype[{alignn}][ex pr] =expr;Memorywrite;align:njifexprrelexprb lock[elseblock]jswitch[[ ]]expr{swt1:::swtn}n 1jblockScopingjName:Localcontrollabeljgo toName;Gotolocallabeljjumpexpr(expr1,::: exprn) ;n 0;Jumptoexprj[conv][Name1,:::Namem=]expr (expr1,:::exprn) ;n;m 0j[conv]return(expr1,:::exprn);n 0 Expressionsexpr!

7 ConstjNameVariableorlabeljtype[{alignn}] [expr]Memoryread;align:nj(expr)jexpropex prjprim(expr1,:::,exprn)n 1 Operatorsop!+flagj-flagj*flagj/flagj%fla gArithmeticj&j|j j<<j>>flagj BitwisePrimitivesprim!negflagjabsflagjsi gnflagjexponentflagjfractionflagjscalefl agjsuccflagjpredflagjulpflagjtruncflagjr oundflagjintpartflagjfractpartflagjtypef lagTypeCastsFlagsflag!NoFlagjoUnOrderedj ujtjutUnsignedandTrappingjfjfzjfnjfpFloa tingandRoundingjftjftzjftnjftpFloatingan dTrappingRelationsrel!==flagj!=flagj>fla gj<flagj>=flagj<=flagSwitchbranchswt!

8 Sconst1,:::sconstn:blockn 1jdefault :blockFigure 2: Statements CommentsComments start with/*and end with*/. They cannot be NamesNames are made up of letters, digits, underscore and dots. A name cannot begin with a numbercharacter or with a dot followed by a number character. Upperand lower case are distinct. Importednames should also follow these are identifiers for registers or memory addresses (Section ).The following are examples of legalC-- are two illegalC--names:. Name scopeProcedure and label names are always global inside aC--compilation unit (or program).

9 Local vari-able names and local control labels are only in scope of the procedure body where they are is no nested scoping of names inside a procedure. Procedure and label names may be usedbefore they are TheimportandexportdeclarationsNames that are to be used outside of theC--program must be exported with , names that theC--program uses and does not declare must be imported with theimportdeclaration. Only procedure and (pointer) label names may be names should follow the syntatic restriction mentioned in Section example where a few C external names are imported and a fewC--names are exported:import printf, sqrt; /* C procedures used in this C-- program*/export foo, bar; /* To be used outside this C-- program */Names that are explicitly exported and imported are guaranteed to be unchanged by the compiler.

10 Allother names might be anexportdeclaration may appear anywhere in the program where adatalayoutdirective or a procedure definition ConstantsConstants can be (signed) integers, (signed) floating pointnumbers, characters, strings and C s syntax for denoting integer, floating point, character, and string Integer and floating point numbersInteger constants have of typeword. Floating point constants have typefloat. Their size Characters and stringsCharacter and string constants are treated as integers and as pointer labels respectively.


Related search queries