]> git.xonotic.org Git - xonotic/gmqcc.git/blob - doc/specification.tex
e41a14a64e06634165e118ced8e89044f9f985a7
[xonotic/gmqcc.git] / doc / specification.tex
1 \documentclass{article}
2
3 %%% PACKAGES
4 \usepackage{geometry}
5 \usepackage[utf8]{inputenc}
6 \usepackage[parfill]{parskip}
7 \usepackage{subfig}
8 \usepackage{listings}
9 \usepackage{color}
10 \usepackage{sectsty}
11
12 %%% GEOMETRY FOR DOCUMENT
13 \geometry{a4paper}
14
15 %%% HEADERS/FOOTERS APPEARANCE
16 \usepackage{fancyhdr} % This should be set AFTER setting up the page geometry
17 \pagestyle{fancy} % options: empty , plain , fancy
18 \renewcommand{\headrulewidth}{0pt} % customise the layout...
19 \lhead{}\chead{}\rhead{}
20 \lfoot{}\cfoot{\thepage}\rfoot{}
21
22 %%% SECTION TITLE APPEARANCE
23 \allsectionsfont{\sffamily\mdseries\upshape} % (See the fntguide.pdf for font help)
24
25 %%% ToC APPEARANCE
26 \usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC
27 \usepackage[titles,subfigure]{tocloft} % Alter the style of the Table of Contents
28 \renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
29 \renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape} % No bold!
30
31 %%% listing language definitions
32 %%% BNF for now, QuakeC will be later
33 \definecolor{keyword1}{RGB}{0,102,153}
34 \definecolor{keyword2}{RGB}{0,153,102}
35 \definecolor{keyword3}{RGB}{0,153,255}
36 \definecolor{comment}{RGB}{204,0,0}
37 \definecolor{function}{RGB}{153,102,255}
38 \definecolor{digit}{RGB}{255,0,0}
39 \definecolor{string}{RGB}{255,0,204}
40 \definecolor{rule}{RGB}{192,192,192}
41 \definecolor{back}{RGB}{250,250,250}
42
43 \lstdefinelanguage{bnf}{
44   keywordstyle={\color{keyword2}\bfseries},
45   keywords={},
46   otherkeywords={::=,|},
47   morecomment=[s][\color{comment}]{(*}{*)},
48   stringstyle=\color{string},
49   showstringspaces=false,
50   frame=none,
51   rulecolor=\color{rule},
52   backgroundcolor=\color{back}
53 }
54
55 %% Title Information %%
56 \title{The GMQCC QuakeC Programming Language}
57 \author{Dale Weiler}
58 \date{\today}
59
60 \begin{document}
61
62 %% Title Page %%
63 \maketitle
64 \thispagestyle{empty}
65 \raggedright
66 \abstract
67 This document specifies the form and establishes the interpretation of programs written in
68 the GMQCC QuakeC programming language variant (refereed simply as QuakeC throughout this
69 document). It specifies:
70 \begin{itemize}
71         \item the representation of QuakeC programs;
72         \item the syntax and constraints of the QuakeC language;
73         \item the semantic rules for interpreting QuakeC programs;
74         \item the representation of input data to be processed by QuakeC programs;
75         \item the representation of output data produced by QuakeC programs;
76         \item the restrictions and limits imposed by a conforming implementation of QuakeC.
77 \end{itemize}
78 This document does not specify
79 \begin{itemize}
80         \item the mechanism by which QuakeC programs are transformed for use by a data-
81               processing system;
82         \item the mechanism by which QuakeC programs are invoked for use by a data-processing
83               system;
84         \item the mechanism by which input data are transformed for use by a QuakeC program;
85         \item the size or complexity of a program and its data that will exceed the capacity
86               of any specific data-processing system or the capacity of a particular
87               execution environment;
88         \item all minimal requirements of a data-processing system that is capable of
89               supporting a conforming implementation.
90 \end{itemize}
91
92 %% Table Of Contents %%
93 \newpage
94 \thispagestyle{empty}
95 \tableofcontents
96 \newpage
97
98 %% Begin Contents %%
99 \raggedright % No weird TEX spacing on lines to fill page
100
101 %% -> Terms, definitions, and symbols %%
102 \section{Terms, definitions, and symbols}
103 \subsection*{argument}
104 Expression in the comma-separated list bounded by the parentheses in a function call
105 expression, or a sequence of preprocessing tokens in the comma-separated list bounded
106 by the parentheses in a function-like macro invocation.
107
108 \subsection*{behavior}
109 External appearance or action
110
111 \subsection*{implementation-defined behavior}
112 Unspecified behavior where each implementation documents how the choice is made.
113
114 \subsection*{undefined behavior}
115 Behavior, upon use of a non-portable or erroneous program construct or of erroneous data,
116 for which this document imposes no actual requirements.
117
118 \subsection*{unspecified behavior}
119 Use of an unspecified value, or other behavior where this document provides two or more
120 possibilities and imposes no further requirements on which is chosen in any instance.
121
122 \subsection*{constraint}
123 Restriction, either syntactic or semantic, by which the exposition of language elements
124 is to be interpreted.
125
126 \subsection*{diagnostic message}
127 Message belonging to an implementation-defined subset of the implementation's message
128 output.
129
130 \subsection*{object}
131 Region of data storage in the execution environment, the contents of which can represent
132 values.
133
134 \subsection*{parameter}
135 Object declare as part of a function declaration or definition that acquires a value on
136 entry to the function, or an identifier from the comma-separated list bounded by the
137 parentheses immediately following the macro name in a function-like macro definition.
138
139 \subsection*{recommended practice}
140 Specification that is strongly recommended as being in keeping with the intent of this
141 document, but that may be impractical for some implementations.
142
143 \subsection*{value}
144 Precise meaning of the contents of an object when interpreted as having a specific type.
145
146 \subsection*{implementation}
147 Particular set of software, running in a particular translation environment under
148 particular control options, that performs translation of programs for, and supports
149 execution of functions in, a particular execution environment.
150
151 \subsection*{implementation-defined value}
152 Unspecified value where each implementation documents how the choice is made.
153
154 \subsection*{unspecified value}
155 Valid value of the relevant type where this document imposes no requirements on which
156 value is chosen in any instance.
157
158 %% -> Conformance %%
159 \section{Conformance}
160 In this document, "shall" is to be interpreted as a requirement on an implementation
161 or on a program; conversely, "shall not" is to be interpreted as a prohibition. \\
162 If a "shall" or "shall not" requirement that appears outside of a constraint is violated,
163 the behavior is undefined.  Undefined behavior is otherwise indicated in this document by
164 the words "undefined behavior" or by the omission of any explicit definition of behavior.
165 There is no difference in emphasis among these three; they all describe "behavior that is
166 undefined".
167
168 %% -> Enviroment %%
169 \section{Environment}
170 An implementation that translates QuakeC source files and executes QuakeC programs in two
171 data processing-system environments, which will be called the translation environment and
172 the execution environment in this document. Their characteristics define and constrain the
173 results of executing QuakeC programs constructed according to the syntactic and semantic
174 rules for conforming implementations.
175 \subsection{Conceptual models}
176 \subsubsection{Translation environment}
177 \paragraph*{Translation steps}
178 The precedence among the syntax rules of translation is specified by the following steps
179 \begin{enumerate}
180         \item Physical source file characters are mapped, in an implementation-defined manner,
181               to the source character set (introducing new-line characters for end-of-line
182               indicators) if necessary.  Trigraph and digraph sequences are replaced by their
183               corresponding single-character internal representations.
184         \item The source file is decomposed into preprocessing tokens and sequences of white-
185               space characters (including comments). A source file shall not end in a partial
186               preprocessing token or in a partial comment. Each comment is replaced by one
187               space character. New-line characters are retained. Whether each nonempty
188               sequences of white-space characters other than new-line is retained or replaced
189               by one space character is implementation-defined.
190         \item Preprocessing directives are executed, macro invocations are expanded 
191               recursively. A \#include preprocessing directive causes the named header or
192               source file to be processes from step one through step three, recursively. All
193               preprocessing directives are then deleted.
194         \item Each source character set member and escape sequence in character constants and
195               string literals is converted to the corresponding member of the execution
196               character set; if there is no corresponding member, it is converted to an
197               implementation-defined member other than the null character.
198         \item Adjacent string literal tokens are concatenated.
199         \item White-space characters seperating tokens are no longer significant. Each
200               preprocessing token is converted into a token. The resulting tokens are then
201               syntactically and semantically analyzed and translated.                         
202 \end{enumerate}
203 \subparagraph*{Footnotes}
204 Implementations shall behave as if these separate steps occur, even though many are likely
205 to be folded together in practice. Source files need not be stored as file, nor need there
206 be any one-to-one correspondence between these items and any external representation. The
207 description is conceptual only, and does not specify any particular implementation.
208
209 \paragraph*{Diagnostics}
210 A conforming implementation shall produce at least on diagnostic message(identified in an
211 implementation-defined manner) if a source file contains a violation of any syntax rule or
212 constraint, even if the behavior is also explicitly specified as undefined or
213 implementation-defined. Diagnostic messages need not be produced in other circumstances.
214
215 %% ->-> Execution environments %%
216 \subsubsection{Execution environment}
217 A conforming execution environment shall provide at minimal the following 15 definitions
218 for built in functions, with an accompanying header or source file that defines them.
219 \begin{enumerate}
220         \item entity ()                                spawn
221         \item void   (entity)                          remove
222         
223         \item string (float)                           ftos
224         \item string (vector)                          vtos
225         \item string (entity)                          etos
226         \item float  (string)                          stof
227         
228         \item void   (string, ...)                     dprint
229         \item void   (entity)                          eprint
230         
231         \item float  (float)                           rint
232         \item float  (float)                           floor
233         \item float  (float)                           ceil
234         \item float  (float)                           fabs
235         \item float  (float)                           sin
236         \item float  (float)                           cos
237         \item float  (float)                           sqrt
238 \end{enumerate}
239 The numbers of which these built-ins are assigned is implementation-defined;
240 an implementation is allowed to use these built-ins however it sees fit.
241
242 \pagebreak
243 %% -> Language %%
244 \section{Language}
245 \subsection{Notation}
246 The syntax notation used in this document is that of a BNF specification.  A set of
247 derivation rules, often written as:
248 \begin{lstlisting}[language=bnf]
249         symbol ::= expression
250 \end{lstlisting}
251 Where symbol is a nonterminal, and the expression consists of one or more sequences of
252 symbols; more sequences are separated by a vertical bar \textbar, indicating a choice,
253 the whole being a possible substitution for the symbol on the left.  Symbols that never
254 appear on the left side are terminals.
255 \linebreak
256
257 This document defines language syntax throughout it's way at defining language
258 constructs If you're interested in a summary of the language syntax, one is given in 
259 annex A.
260
261 %% -> Concepts %%
262 \subsection{Concepts}
263 %% ->-> Scopes of identifiers %%
264 \subsubsection{Scopes of identifiers}
265 An identifier can denote an object; a function, or enumeration; a label name; a macro
266 name; or a macro parameter. The same identifier can denote difference items at different
267 point in the program. A member of an enumeration is called an enumeration constant.
268 Macro names and macro parameters are not considered further here, because prior to the
269 semantic phase of program translation any occurrences of macro names in the source file
270 are replaced by the preprocessing token sequences that constitute their macro definitions.
271 \linebreak
272
273 For each different item that an identifier designates, the identifier is visible (i.e, 
274 can be used) only within a region of program text called its scope.  Different items 
275 designated by the same identifier either have different scopes, or are in different name
276 spaces. There are four kinds of scopes: function, file, block and function prototype.
277 (A function prototype is a declaration of a function that declares the types of its
278 parameters.)
279 \linebreak
280
281 A label name is the only kind of identifier that has function scope.  It can be used (in 
282 a goto statement) anywhere in the function in which it appears, and is declared
283 implicitly by its syntactic appearance (prefixed by a : and a statement).
284 \linebreak
285
286 Every other identifier has scope determined by the placement of its declaration (in a 
287 declarator or type specifier).  If the declarator or types specifier that declares the 
288 identifier appears outside any block or list of parameters, the identifier has file 
289 scope,  which terminates at the end of the file.  If the declartor or type specifier that
290 declares the identifier appears inside a block or within the list of parameter
291 declarations in a  function definition, the identifier has block scope, which terminates
292 at the end of the  associated block.  If the declarator or type specifier that declares 
293 the identifier appears  within the list of parameter declarations in a function prototype
294 (not part of a function definition), the identifier has function prototype scope, which 
295 terminates at the end of the function declarator.  If an identifier designates two 
296 different items in the same  name space, the scopes might overlap.  If so, the scope of 
297 one item (the inner scope) will be a strict subset of the scope of the other item (the 
298 outer scope). Within the inner scope, the identifier designates the item declared in the
299 inner scope; the item declared in the  outer scope is hidden (and not visible) within 
300 the inner scope.
301 \linebreak
302
303 Unless explicitly stated otherwise, where this document uses the term "identifier" to 
304 refer to some item (as opposed to the syntactic construct), it refers to the item in the 
305 relevant name space whose declaration is visible at the point the identifier occurs.
306 \linebreak
307
308 Two identifiers have the same scope it and only if their scopes terminate at the same 
309 point.
310 \linebreak
311
312 Each enumeration constant has scope that begins just after the appearance of its defining
313 enumerator in an enumerator list. Any other identifier has scope that begins just after 
314 the completion of its declarator.
315
316 %% ->-> Name spaces of identifiers %%
317 \subsubsection{Name spaces of identifiers}
318 If more than one declaration of a particular identifier is visible at any point in a 
319 source file, the syntactic context disambiguates uses that refer to different items. 
320 Thus, there  are separate name spaces for various categories of identifiers, as follows:
321 \linebreak
322 \begin{itemize}
323         \item Label names (disambiguated by the syntax of the label declaration and use);
324         \item Enumerations (disambiguated by following the keyword enum);
325         \item All other identifiers, called ordinary identifiers (declared in ordinary
326               declarators or as enumeration constants).
327 \end{itemize}
328
329 %% ->-> Types %%
330 \subsubsection{Types}
331 The meaning of a value stored in an object returned by a function is determined by the 
332 type  of the expression used to access it. (An identifier declared to be an object is the simplest
333 such expression; the type is specified in the declaration of the identifier.)  Types are 
334 partitioned into object types (types that fully describe objects), function types(types 
335 that  describe functions), and incomplete types(types that describe objects but lack 
336 information).
337 \linebreak
338
339 An object declared type bool is large enough to store the values 0 and 1.
340 \linebreak
341
342 An object declared type float is a real type; An object declared type vector is a 
343 comprised set of three floats that respectively represent the \underline{x,y,z} 
344 components of a three-dimensional vector.
345 \linebreak
346
347 An enumeration comprises a set of named integer constant values.  Each distinct 
348 enumeration constitutes a different enumerated type.
349 \linebreak
350
351 Enumeration types and float are collectively called arithmetic types. Each arithmetic 
352 type belongs to one type domain.
353 \linebreak
354
355 The void type comprises an empty set of values; it is an incomplete type that cannot be
356 completed.
357 \linebreak
358
359 A number of derived types can be constructed from the object, function and incomplete 
360 types, as follows:
361 \linebreak
362
363 \begin{itemize}
364         \item An array type describes a contiguously allocated nonempty set of objects with a 
365               particular object types, called the element type. Array types are characterized 
366               by their element type and by the number of elements in the array.  An array type
367               is said to be derived     from its element type, and if its element is type T, the 
368               array type is sometimes called "array of T".  The construction of an array type
369                   from an element type is called "array type derivation".
370         \item A function type described a function with a specified return type. A function
371                   type is characterized by its return type and the number and types of its
372                   parameters. A function type is said to be derived from its return type, and if 
373                   its return type is T, the function type is sometimes called "function returning
374                    T". The construction of a function type from a return type is called "function
375                    type derivation".
376 \end{itemize}
377
378 Arithmetic types are collectively called scalar types. Arrays and vectors are 
379 collectively called aggregate types.
380 \linebreak
381
382 An array of unknown size is an incomplete type.  It is completed, for an identifier of 
383 that byte, by specifying the size in a later declaration.  Arrays are required to have 
384 known constant size.
385 \linebreak
386
387 A type is characterized by its type category, which is either the outermost derivation 
388 of a derived type (as noted above in the construction of derived types), or the type 
389 itself if the type consists of no derived types.
390 \linebreak
391
392 Any type so far mentioned is an unqualified type.  Each unqualified type has several 
393 qualified version of its type, corresponding to the combinations of one, two, or all 
394 two of const and volatile qualifiers.  The qualified or unqualified versions of a type 
395 are distinct types that belong to the same type category and have the same representation.
396 A derived type is not qualified by the qualifiers (if any) of the type from which it 
397 is derived.
398 \linebreak
399
400 %% ->-> Compatible types and composite type %%
401 \subsubsection{Compatible types and composite type}
402 Two types have compatible type if their types are the same.
403 \linebreak
404
405 All declarations that refer to the same object or function shall have compatible type; 
406 otherwise the behavior is undefined.
407 \linebreak
408
409 A composite type can be constructed from two types that are compatible; it is a type that 
410 is compatible with both of the two types and satisfies the following conditions:
411 \begin{itemize}
412         \item If one type is an array, the composite type is an array of that size.
413         \item If only one type is a function type with a parameter type list(a function 
414               prototype), the composite type is a function prototype with the parameter type 
415               list.
416         \item If both types are function types with parameter type lists, the type of each 
417               parameter in the composite parameter type list is the composite type of the 
418               corresponding parameters.
419 \end{itemize}
420 These rules apply recursively to types from which the twp types are derived.
421 \linebreak
422
423 %% ->Conversions %%
424 \subsection{Conversions}
425 Several operators convert operand values from one type to another automatically. This 
426 sub-clause specified the result required from such an implicit conversion.
427 \linebreak
428
429 Conversion from an operand value to a compatible type causes no change to the value or
430 the representation.
431 \linebreak
432
433 %% ->->Aritmetic operands %%
434 \subsubsection{Arithmetic operands}
435 \paragraph*{Boolean type}
436 When any scalar value is converted to bool, the result is 0 if the value compares equal 
437 to 0; otherwise the result is 1.
438
439 %% ->->Other operands %%
440 \subsubsection{Other operands}
441 \paragraph{Lvalues, arrays and function designators}
442 An lvalue is an expression with an object type or an incomplete type other than void; 
443 if an lvalue does not designate an object when it is evaluated, the behavior is undefined.
444 When an object is said to have a particular type, the type is specified by the lvalue 
445 used to designate the object.  A modifiable lvalue is an lvalue that does not have an 
446 array type, does not have an incomplete type, does not have a const-qualified type.
447 \linebreak
448
449 Except when it is the operand of the unary \& operator, the ++ operator, the -- operator,
450 or the left operand of the . operator or an assignment operator, an lvalue that does not 
451 have array type is converted to the value stored in the designated object (and is no 
452 longer an lvalue).  If the lvalue has qualified type, the value has the unqualified 
453 version of the type of the lvalue; otherwise, the value has the type of the lvalue. If 
454 the lvalue has an incomplete type and does not have array type, the behavior is undefined.
455 \linebreak
456
457 A function designator is an expression that has function type.
458 \linebreak
459
460 \paragraph*{void}
461 The (nonexistent) value of a void expression (an expression that has type void) shall not 
462 be used in any way, and implicit conversions (except to void) shall not be applied to 
463 such an expression.  If an expression of any other type is evaluated as a void expression
464 , its value or designator is discarded. (A void expression is only evaluated for its 
465 side effects.)
466 \pagebreak
467
468 \subsection{Lexical elements}
469 \paragraph*{Syntax}
470 \begin{lstlisting}[language=bnf]
471 token ::= keyword    
472         | identifier
473         | constant   
474         | string-literal
475         | punctuator
476 preprocessing-token ::= header-name 
477                       | identifier
478                       | pp-number   
479                       | string-literal
480                       | punctuator
481 \end{lstlisting}
482 \paragraph*{Constraints}
483 Each preprocessing token that is converted to a token shall have the lexical form of a 
484 keyword, an identifier, a constant, a string literal, or a punctuator.
485
486 \paragraph*{Semantics}
487 A token is the minimal lexical element of the language in translation steps six and seven.
488 The categories of tokens are: keywords, identifiers, constants, string literals, and
489 punctuators. A preprocessing token is the minimal lexical element of the language in
490 translation steps three through five. The categories of preprocessing tokens are: header
491 names, identifiers, preprocessing numbers, string literals, punctuators and other single
492 non-white-space characters that do not lexically match the other preprocessing token
493 categories. If a \' or a \" character matches the last category, the behavior is undefined.
494 Preprocessing tokens can be separated by white space; this consists of comments (described
495 later), or white-space characters (space, horizontal tab, new-line, vertical tab, and form
496 -feed), or both. In certain circumstances during translation step four, white space (or
497 the absence thereof) serves as more than preprocessing token separation. Whit space may 
498 appear within a preprocessing token only as part of a header name or between the quotation
499 characters in a string literal.
500 \linebreak
501
502 If the input stream has been parsed into preprocessing tokens up to a given character, the
503 next preprocessing token is the longest sequence of characters that could constitute a
504 preprocessing token. There is one exception to this rule: header name preprocessing tokens
505 are recognized only within \#include preprocessing directives and in implementation-defined
506 locations within \#pragma directives. In such contexts, a sequence of characters that
507 could be either a header name or string literal is recognized as the former.
508
509 %% ->-> Keywords %%
510 \subsubsection{Keywords}
511 \paragraph*{Syntax}
512 \begin{lstlisting}[language=bnf]
513 keyword ::= enum     | break
514           | return   | void
515           | case     | float
516           | volatile | for
517           | while    | const
518           | goto     | bool
519           | continue | if
520           | static   | default
521           | inline   | do
522           | switch   | else
523           | vector   | entity
524 \end{lstlisting}
525 \paragraph*{Semantics}
526 The above tokens (case sensitive) are reserved (in translation step seven and eight) for 
527 use as keywords, and shall not be used otherwise.
528
529 %% ->->Identifiers %%
530 \subsubsection{Identifiers}
531 \paragraph*{Syntax}
532 \begin{lstlisting}[language=bnf]
533 identifier ::= nondigit
534              | identifier nondigit
535              | identifier digit
536              
537 nondigit  ::= _ | a | b | c | d | e | f | g | h | i 
538             | j | k | l | m | n | o | p | q | r | s
539             | t | u | v | w | x | y | z | A | B | C
540             | D | E | F | G | H | I | J | K | L | M
541             | N | P | Q | R | S | T | U | V | W | X
542             | Y | Z
543
544 digit     ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
545 \end{lstlisting}
546
547 %% ->->Constants %%
548 \subsubsection{Constants}
549 \begin{lstlisting}[language=bnf]
550 constant             ::= integer-constant
551                        | floating-constant
552                        | enumeration-constant
553                        | character-constant
554                        | vector-constant
555            
556 integer-constant     ::= decimal-constant
557                        | octal-constant
558                        | hexadecimal-constant
559                    
560 decimal-constant     ::= nonzero-digit
561                        | decimal-constant digit
562                    
563 octal-constant       ::= 0
564                        | octal-constant octal-digit
565                    
566 hexadecimal-constant ::= hexdecimal-prefix
567                          hexadecimal-digit
568                        | hexadecimal-digit
569                          hexadecimal-constant
570
571 hexadecimal-prefix:  ::= 0x | 0X
572
573 nonzero-digit        ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
574                        | 9
575                        
576 octal-digit          ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
577
578 hexadecimal-digit    ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
579                        | 8 | 9 | a | b | c | d | e | f
580                        | A | B | C | D | E | F
581 \end{lstlisting}
582
583 %% ->-> String literals %%
584 \subsubsection{String literals}
585 \begin{lstlisting}[language=bnf]
586 string-literal  := " s-char-sequence "
587
588 s-char-sequence := s-char
589                  | s-char-sequence s-char
590                  
591 s-char          := ` | ! | @ | # | $ | % | ^ | & | *
592                  | ( | ) | _ | - | + | = | { | } | [
593                  | ] | | | : | ; | ' | < | , | > | .
594                  | ? | / | 1 | 2 | 3 | 4 | 5 | 6 | 7
595                  | 8 | 9 | 0 | q | w | e | r | t | y
596                  | u | i | o | p | a | s | d | f | g
597                  | h | j | k | l | z | x | c | v | b 
598                  | n | m | Q | W | E | R | T | Y | U
599                  | I | O | P | A | S | D | F | G | |
600                  | H | J | K | L | Z | X | C | V | B
601                  | N | M
602 \end{lstlisting}
603 \paragraph*{Description}
604 A character string literal is a sequence of zero or more characters enclosed in 
605 double-quotes, as in "xyz".
606 \linebreak
607
608 The same considerations apply to each element of the sequence in a character string
609 literal as if it where an integer character constant, except that the single-quote 
610 ' is representable either by itself or by the escape sequence \textbackslash', but 
611 the double-quote " shall be represented by the escape sequence \textbackslash".
612
613 \paragraph*{Semantics}
614 In translation stage six, the character sequences specified by any sequence of adjacent 
615 character string literal tokens are concatenated into a single character sequence.
616
617 %% ->-> Punctuators %%
618 \subsubsection{Punctuators}
619 TODO: BNF
620
621 A punctuator is a symbol that has independent syntactic and semantic significance. 
622 Depending on context, it may specify an operation to be performed (which in turn 
623 may yield a value or a function designator, produce a side effect, or some combination 
624 thereof) in which case it is known as an operator (other forms of operator also exist 
625 in some contexts). An operand is an item on which an operator acts.
626 \linebreak
627
628 TODO: Trigraphs \& Digraphs
629
630 \subsubsection{Header names}
631 TODO
632 \subsubsection{Preprocessing numbers}
633 TODO
634 \subsubsection{Comments}
635 Except within a character constant, a string literal, or a comment, the characters /* 
636 introduce a comment.  The contents of such a comment are examined only to identify 
637 characters and to find the characters /* that terminate it.
638 \linebreak
639
640 Except within a character constant, a string literal, or a comment, the characters // 
641 introduce a comment that includes all characters up to, but not including, the next 
642 new-line character.  The contents of such a comment are examined only to identify 
643 characters and to find the terminating new-line characters.
644 \linebreak
645
646 %% -> Expressions %%
647 \subsection{Expressions}
648 An expression is a sequence of operators and operands that specifies computation of a 
649 value, or that designates an object or function, or that generates side effects, or that 
650 performs a combination thereof.
651 \linebreak
652
653 Between the previous and next sequence point an object shall have its stored value 
654 modified at most once by the evaluation of an expression. Furthermore, the prior value 
655 shall be read only to determine the value to be stored.
656 \linebreak
657
658 The grouping of operators and operands is indicated by the syntax. Except as specified 
659 later (for the function call (), \&\&, \textbar\textbar ?:, and comma operators), the 
660 order of evaluation of sub-expressions and the order in which side effects take place 
661 are both unspecified.
662 \linebreak
663
664 Some operators (the unary \textasciitilde operator, and the binary operators \textless
665 \textless, \textgreater\textgreater, \&, \^, and \textbar, collectively describe bitwise 
666 operators) are required to have operands that are either integer, or floating point with
667 zero points of decimal precision.
668 \linebreak
669
670 If an exceptional condition occurs during the evaluation of an expression (that is, if 
671 the result is not mathematically defined or not in the range or representable values for 
672 its type), the behavior is undefined.
673
674 %% ->-> Primary expressions %%
675 \subsubsection{Primary expressions}
676 \paragraph*{Syntax}
677 \begin{lstlisting}[language=bnf]
678 primary-expression := identifier
679                     | constant
680                     | string-literal
681                     ( expression )
682 \end{lstlisting}
683 \paragraph*{Semantics}
684 An identifier is a primary expression, provided it has been declared as designating an 
685 object(in which case it is an lvalue) or a function(in which case it is a function 
686 designator).
687 \linebreak
688
689 A constant is a primary expression. Its type depends on its form and value.
690 \linebreak
691
692 A string literal is a primary expression.  It is an lvalue.
693 \linebreak
694
695 A parenthesized expression is a primary expression.  Its type and value identical to 
696 those of the unparenthesized expression.  It is an lvalue, a function designator, or a 
697 void expression if the unparenthesized expression is, respectively, an lvalue, a 
698 function designator, or a void expression.
699
700 \bibliographystyle{abbrv}
701 \bibliography{main}
702
703 \end{document}