The minimum elements that make up the source code of the Rice.

Token

Token means the minimum components that has a meaning as the source code of Rice. The following are kinds of token.


Identifier

Reserved word

Symbol

Literal

Comment

Space


Identifier

The identifier means a name that defined in source code. The following is a regular expression that is used for the identifier.


[_a-zA-Z][_a-zA-Z0-9]*


In other words, the identifier is a string that satisfy the following conditions.


The first character is underscore or alphabet.

Then, the underscore, alphabet, or number repeat 0 or more times.


Reserved words satisfy the above conditions, but cannot use as identifier. Uppercase and lowercase letters are distinguished. Limit on the number of characters in the identifier is not.

Ver 1.1.0.0 : The syntax rules for reserved words and identifiers is changed.

The above restriction has been relaxed. The reserved words that appear immediately after the dot operator are exceptionally recognized as identifiers.

Reserved word

The token which is not an identifier while satisfying a rule as an identifier is a reserved word. The reserved words of Rice consists of keywords and class names.

The following is list of keywords.


import

class

endclass

ec

method

endmethod

em

setter

endsetter

es

getter

endgetter

eg

fitter

endfitter

ef

try

catch

endtry

et

if

elseif

else

endif

ei

while

endwhile

ew

each

endeach

ee

fromto

endfromto

eft

keepon

endkeepon

eko

return

break

continue

throw

true

false

open

closed

new

this


Keyword is always reserved word. Namely, keyword will never be the identifier in every context of the Rice.

Unlike the keywords, class name can use as an identifier by the context. A basic class name is always the reserved word. Whether you can use the embedded class name as an identifier, depends on the context. A user-defined class name can always use as an identifier.

The embedded class name that has been executed embedding will be a reserved word from the reading of the next source files.

The following three class names are reserved word.


void

error

dummy


These are classes used in implementation of Rice. Users cannot use them.

Please refer to the appropriate documentation for information about the kinds of class.

Ver 1.1.0.0: The syntax rules for reserved words and identifiers is changed.

The above restriction has been relaxed. The reserved words that appear immediately after the dot operator are exceptionally recognized as identifiers.

Ver 1.2.0.0: It added reserved words.

It added abbreviations for endxx type keywords and reserved words related to keepon statements.

Symbol

The following is list of symbols.


=

;

{

}

(

)

,

.

+

++

-

--

!

*

/

%

>

<

>=

<=

==

!=

$$

!$

&

|

//

/*

*/

Ver 1.2.0.0: It added ++ and --.

Literal

Literal is value that is directly described on the code.

There are the following literals.


int literal

long literal

real literal

string literal

bool literal


int literal

The following is a regular expression that is used for the int literal.


[0]

[1-9][0-9]*

[1-9][0-9]*I


In other words, the int literal is a string that satisfy the following conditions.


0

The first character is a non-zero digit, and followed by the digit that repeat zero or more times.

The first character is a non-zero digit, and followed by the digit that repeat zero or more times, and the last character is I.


Range of int literal is the same as the int type. For more information, refer to the manual of int type.

long literal

The following is a regular expression that is used for the long literal.


[1-9][0-9]*L


In other words, the long literal is a string that satisfy the following conditions.


The first character is a non-zero digit, and followed by the digit that repeat zero or more times, and the last character is L.


Range of long literal is the same as the long type. For more information, refer to the manual of long type.

real literal

The following is a regular expression that is used for the real literal.


[1-9][0-9]*\.[0-9]+

0\.[0-9]+

.[0-9]+


In other words, the real literal is a string that satisfy the following conditions.


The first character is a non-zero digit, and followed by digit that repeat zero or more times, and followed by the dot, and followed by digit that repeat one or more times.

The first character is the zero, and followed by the dot, and followed by digit that repeat one or more times.

The first character is the dot, and followed by digit that repeat one or more times.


Range of real literal is the same as the real type. For more information, refer to the manual of real type.

string literal

The following is a regular expression that is used for the string literal.


\"(.*?)\"


In other words, the string literal is a string that satisfy the following conditions.


A string that repeat a character other than double quotes enclosed by the double quotes.


Although you can use all of the characters at the string literal, there is no way to describe directly the newline character, tab, double quotes etc in a string literal. Namely, the escape sequence does not exist in the Rice.

When the escape sequence is required, you can use the escape sequence instead of the replacement or concatenation of the string. For more information, refer to the escape sequence of the manual.

bool literal

Bool literals are true and false.

Comment

The comment is the inserted annotation in source code. At the time of execution it is ignored.

There are the following comments.


Single-line comment

Multi-line comment

Named comment


Ver 1.2.0.0: It added the named comment.

Single-line comment

The following is a regular expression that is used for the single-line comment.


//.*


In other words, the single-line comment is a string that satisfy the following conditions


A string up to the end of the line that begin with //.


Multi-line comment

The following is a regular expression that is used for the multi-line comment.


/\*([\s\S]*?)\*/


In other words, the multi-line comment is a string that satisfy the following conditions


A string that surrounded by /* And */.


Named comment

Named comment is multi-line comment that has a special format for referencing its content from the program.

See Named comment for more information.


Space

It is a sequence of blank characters. At the time of execution it is ignored.

The following is a regular expression that is used for the space.


\s+


In other words, the space is a string that satisfy the following conditions


Repetition of one or more blank characters.


Copyright © Rice All rights reserved.