锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
鍋囪鎴戜滑杈撳叆int a=100;榪欐牱涓涓瓧絎︿覆浣滀負浠g爜錛岄偅涔堟垜浠皢濡備綍鍒嗘瀽鍛紵
棣栧厛璇誨叆i錛?#8220;i”絎﹀悎Identifier鐨勮鍒欙紝浣嗘槸緇х畫璇諱笅鍘昏繕鏈変釜n錛屼竴鍏辨槸“in”錛?#8220;in”涔熺鍚圛dentifier鐨勮鍒欙紝鍐嶈錛屽彉鎴?#8220;int”錛?#8220;int”絎﹀悎Type鐨勮鍒欙紝緇х畫璇誨叆鍚庨潰鐨勭┖鏍鹼紝鍙樻垚“int ”錛岃繖涓彲涓嶇鍚堜換浣曡鍒欎簡錛屽洜姝ゆ垜浠笉鑳芥壙璁よ繖涓姝ワ紝鍙ソ鍙栦笂涓姝ョ殑鍙帴鍙楃殑緇撴灉Type錛?#8220;int”銆傝繖鏍鋒垜浠氨鐢熸垚浜嗙涓涓猅oken錛屼粬鐨勭被鍨嬫槸Type錛屽兼槸“int”銆備互姝ょ被鎺紝鎴戜滑鍙互璇誨畬鏁翠釜紼嬪簭錛屽茍瀹屾垚鏁翠釜璇嶆硶鍒嗘瀽鐨勮繃紼嬨?br>
浣嗘槸姣忎竴嬈¢兘鍘誨垽鏂暣涓凡璇誨叆鐨勫瓧絎︿覆鏄惁鍖歸厤鏌愪釜瑙勫垯錛屾晥鐜囬潪甯鎬綆錛屾垜浠渶瑕佷竴縐嶇嚎鎬ц鍏ュ瓧絎︿覆錛屽茍瀹炴椂鎺屾彙鐩墠瀛楃涓插尮閰嶇姸鍐電殑鍔炴硶銆傜‘瀹氭ф湁絀瘋嚜鍔ㄦ満錛圖FA錛夊氨鏄繖鏍蜂竴縐嶇姸鎬佹満銆?br>
涓嬮潰鏄垜涓篊NScript鐢誨嚭鐨勭姸鎬佸浘錛?br>
渚嬪鍒氭墠璇葷殑int a=100錛?br>鎴戜滑涓寮濮嬫槸鍦ㄧ紪鍙蜂負0鐨勭姸鎬侊紝鐜板湪杈撳叆i錛屽洜涓篿灞炰簬a-zA-Z鐨勮寖鍥達紝鎵浠ラ氳繃鏈鍚庝竴騫呭浘鎴戜滑鐪嬪埌錛屾垜浠皢榪堝悜緙栧彿涓?4鐨勭姸鎬併傚啀杈撳叆n錛屽洜涓簄灞炰簬a-zA-Z0-9_鐨勮寖鍥達紝鎵浠ユ垜浠戶緇蛋鍦ㄧ紪鍙?4鐨勭姸鎬侊紝t涔熷姝わ紝浣嗘槸杈撳叆絀烘牸鏃訛紝鎴戜滑鍙戠幇44鍙風姸鎬佹病鏈夋帴鍙楃┖鏍煎瓧絎︾殑鍑哄彛錛屼篃灝辨槸鏃犳硶緇х畫璧頒笅鍘諱簡錛岃屼笖44鍙風姸鎬佹槸涓涓彲鎺ュ彈鐘舵侊紝鎵浠ユ垜浠帴鍙楀凡緇忚緭鍏ヤ簡鐨?#8220;int”銆?br>鍦ㄨ繖閲屾垜浠殑44鍙風姸鎬侊紝鎺ュ彈鎰忎箟鏄竴涓猲ame錛屽彲浠ユ槸Identifier錛屼篃鍙互鏄疜eyword錛屼篃鍙互鏄疶ype錛屽綋鎴戜滑鍙栧緱name錛?#8220;int”鏃訛紝鎴戜滑鍐嶅垽鏂彂鐜拌繖鏄竴涓猅ype錛屾墍浠ユ垜浠緱鍑篢oken錛歍ype錛?#8220;int”銆傜劧鍚庣姸鎬佸洖鍒?鍙鳳紝緇х畫杈撳叆鍒氭墠鐨勭┖鏍箋備互姝ょ被鎺ㄣ?br>
鎵浠ユ垜浠彧瑕佹寜榪欎釜鐘舵佸浘鍘婚亶鍘嗗瓧絎︿覆錛屾垜浠氨浼氫笉鏂殑鍦ㄥ悇涓姸鎬佷腑杈楄漿鍙嶅錛屽茍涓嶆柇鐨勫緱鍑篢okens銆傝繖灝辨槸鎴戜滑璇嶆硶鍒嗘瀽鐨勫熀鏈師鐞嗐?br>涓嬩竴綃囨垜浼氬啓鍑鴻繖涓狣FA鐨勪唬鐮佸拰鍏蜂綋浣跨敤鏂規銆?/p>
Functionality:
Procedure Oriented, No Custom Data Structures, No Closures, Strong Typed, Array Supported.
Keywords:
int,double,char,string,bool,void,if,else,for,do,while,return
Statements:
Single Expression:
expression;
Chunk:
{
Statement1
Statement2
}
Array Declaration:
type name[size];
Variable Declaration:
type name [= expression];
Function definition:
type FunctionName(type paramName1, type paramName2)
Chunk
IF-ELSE:
if(expression)
Statement1
else
Statement2
FOR-LOOP:
for(statement1 expression2;expression3)
Statement
WHILE-LOOP:
while(expression)
Statement
DO-WHILE-LOOP:
do
Statement
while(expression);
Expressions:
Values:
true
false
number
string
char
Variable Name
Array Name[index]
Assign:
name = expression
Function Call:
name(expression1,expression2)
Compares:
expression1 == expression2
expression1 != expression2
expression1 < expression2
expression1 > expression2
expression1 <= expression2
expression1 >= expression2
Boolean Operations:
!expression
expression1 && expression2
expression1 || expression2
Calculating:
expression++
expression鈥?/font>
++expression
--expression
expression1 + expression2
expression1 – expression2
expression1 * expression2
expression1 / expression2
expression1 % expression2
expression1 ^ expression2
(expression)
Lexical Tokens:
Spaces:
Space: (space_bar+)|(\n+) (\r+)|(\t+)
TypeNames:
Type: (int)|(double)|(char)|(string)|(bool)|(void)
Keywords:
Keyword_if: if
Keyword_else: else
Keyword_for: for
Keyword_do: do
Keyword_while: while
Keyword_return: return
Brackets:
BigLeftBracket: {
BigRightBracket: }
MidLeftBracket: [
MidRightBracket: ]
SmallLeftBracket: \(
SmallRightBracket: \)
Identifier:
Identifier: (_+[a-zA-Z0-9_]+)|([a-zA-Z][a-zA-Z0-9_]*)
Number Value:
Integer: 0|[1-9][0-9]*
Double: (0|[1-9][0-9]*)\.[0-9]+
Bool Value:
BoolValue: true|false
Char:
CharValue: ‘(\\[^\r\n\t])|([^’\r\n\t])’
String:
StringValue: “((\\”)|[^\r\n])*”
Operators:
Operator: =|\+|-|\*|/|%|^|(++)|(--)|(&&)|(\|\|)|(!)|<|>|(<=)|(>=)|(==)|(!=)
Seprators:
Seprator: ;
Variable Declaration:
type name [= expression];
鎵嶈兘寤虹珛璧瘋娉曟爲鏉ャ?br>Lexical Tokens涓槸姣忕Token瀵瑰簲鐨勬鍒欒〃杈懼紡銆?/p>