首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

思前想后,还是决定开工做EScript

2012-12-22 
前思后想,还是决定开工做EScript虽然有些忙,但觉得 CommentScriipt想法还是很不错的,决定开工做了 支持的

前思后想,还是决定开工做EScript
虽然有些忙,但觉得 CommentScriipt想法还是很不错的,决定开工做了

支持的语法现在考虑如下:

/*CS.replace(log.dir=@@kkkkkk@@)*/
//CS:util.smartReeplace(@@kkkkkk@@)
//CS:util.deleteNextLine

//CS:util.delete


//CS:util.end-delete


//CS:com.yourcorp.mergejs(<script src="utp-all.js>)

如有帮手一起来完成,更好啊。可以联系我 1 楼 javamonkey 2010-11-27   用antlr做,些技术含量。

用antlr定义语言容易,但现在还不能确定是否能用上antlr来定义普通文件,研究中 2 楼 javamonkey 2010-11-28   grammar T2;
txt:(line|others)*;
line:   string NEWLINE others{System.out.println("get Content "+$others.text+"by command "+$string.text);};
string
: '#'  ID
;
others
:ID NEWLINE;
WS  :   (' '|'\t')+ {skip();} ;
ID:('a'..'z')*;
NEWLINE: ('\r'? '\n')+;

补充一个原型

对如下文本解析
dfdfdfdfdfdfd
#hello
dfdfdfd
#cccccddfdf
fdfdfdf
3 楼 javamonkey 2010-12-05   再次完善了脚本语法,但离目标还很远,主要是还不熟习antlr,只能看他参考文档慢慢做了。
语法能解析如下输入文本

#CS: delnext
dfdfdfd
#CS: replace a {
dfdfdf
hello c
#CS:}


///////////////////////////////////////////////////////////

grammar T2;
options {backtrack=true;}
txt:(commandLine|contentLine|comment)*;
commandLine
scope {
boolean  isSingleLine;
}
@init{
$commandLine::isSingleLine = true;
}
:  commentChar 'CS:' key (csbegin {$commandLine::isSingleLine=false;System.out.println("mutipleLine found");})? NEWLINE  parasLine  (csend )?  ;
csbegin
:'{';
csend
:commentChar 'CS:}' NEWLINE;
parasLine
:{$commandLine::isSingleLine}?=>singleLine{System.out.println("single line");}
|mutilLine{System.out.println("mutilple line");}
;
singleLine
:contentLine;
mutilLine
:contentLine+;

key
: replace
| 'delnext'
;
replace
:'replace a'
|'replace b'
;
contentLine
:STRING NEWLINE;
comment
:commentChar contentLine
;
commentChar
:'#'
|'//'
|'/*'
;
WS  :   (' '|'\t')+ {skip();} ;

STRING
:('a'..'z')*
;
NEWLINE: ('\r'? '\n')+;


热点排行