Home About Rice Downloads Documents Others Cooker CookerGX
Documents  >  Reference  >  token
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.

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

method

endmethod

setter

endsetter

getter

endgetter

fitter

endfitter

try

catch

endtry

if

elseif

else

endif

while

endwhile

each

endeach

fromto

endfromto

return

break

continue

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.

Symbol

The following is list of symbols.


=

;

{

}

(

)

,

.

+

-

!

*

/

%

>

<

>=

<=

==

!=

$$

!$

&

|

//

/*

*/


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


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 */.


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.


Next
Previous
Copyright © Rice All rights reserved.