程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> JAVA綜合教程 >> Atitit.java expression fsm 表達式分詞fsm引擎,atitit.javafsm

Atitit.java expression fsm 表達式分詞fsm引擎,atitit.javafsm

編輯:JAVA綜合教程

Atitit.java expression fsm 表達式分詞fsm引擎,atitit.javafsm


 

 

Atitit.java expression fsm 表達式分詞fsm引擎

 

C:\0workspace\AtiPlatf_cms\src\com\attilax\fsm\JavaExpFsm.java

 

 

String code = "new(com.attilax.util.connReduceDync).set_resfile(uc_js.txt).joinNout() "

.trim();

 

 

$code=new(com.attilax.user.AgentService).login(admin,admin)

 

[

"new",

"(",

"com.attilax.user.AgentService",

")",

".",

"login",

"(",

"admin",

"admin",

")"

]

 

 

作者::  ★(attilax)>>>   綽號:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿爾 拉帕努伊 ) 漢字名:艾龍,  EMAIL:[email protected]

轉載請注明來源: http://www.cnblogs.com/attilax/

 

 

 

package com.attilax.fsm;

 

import java.util.List;

 

import com.google.common.collect.Lists;

 

public class JavaExpFsm {

List<String> tokens = Lists.newLinkedList();

String curToken = "";

//String splitors = "(),\"";

String curStat = "ini";

private String code;

public char[] code_char_arr;

 

public JavaExpFsm(String code) {

this.code = code;

}

 

/**

 * http://localhost/new(com.attilax.util.connReduceDync).set_resfile(uc_js.txt).joinNout()

 * http://localhost/wrmiServlet?code=new(com.attilax.util.connReduceDync).set_resfile(uc_js.txt).joinNout()

 * @param args

 */

public static void main(String[] args) {

String code = "new(com.attilax.util.connReduceDync).set_resfile(uc_js.txt).joinNout() "

.trim();

code= " new(com.attilax.agent.AgentRechargeService).getSubMemTotalsRecycleByAgentId(\"promoter:$pid$,fld2:v2\")";

List li = new JavaExpFsm(code).getTokens();

for (Object object : li) {

System.out.println(object);

}

System.out.println(li);

 

}

 

public List getTokens() {

code_char_arr = code.toCharArray();

for (char c : code_char_arr) {

// get next char,,then change stat

// jude cur char and cur stat...then if or not chage stat

if (c == '(' && !this.curStat.equals("strStart")) {    //&&  cur stta=ini

this.curStat = "brkStart";

tokens.add(this.curToken);

tokens.add("(");

this.curToken = "";

continue;

}

 

//if (c == '.' && this.curStat.equals("brkStart")) {

//

//curToken = curToken + String.valueOf(c);

//continue;

//

//// this.curStat.equals("brkEnd"))

//

//}

//

if (c == ')'  && !this.curStat.equals("strStart") ) {    //&& cur stat =brk start

this.curStat = "brkEnd";

if(this.curToken.length()>0)

tokens.add(this.curToken);

tokens.add(")");

this.curToken = "";

continue;

}

if (c == '.' && this.curStat.equals("brkEnd")) {

tokens.add(".");

curToken = "";

continue;

}

if(c=='\"' && this.curStat.equals("brkStart"))

{

this.curStat = "strStart";

//tokens.add(c);

this.curToken = "";

continue;

}

if(c=='\"' && this.curStat.equals("strStart"))

{

this.curStat = "strEnd";

tokens.add(this.curToken);

this.curToken = "";

continue;

}

if(c==',' && this.curStat.equals("brkStart"))

{

//this.curStat = "strEnd";

tokens.add(this.curToken);

this.curToken = "";

continue;

}

//if (this.curStat.equals("ini"))

curToken = curToken + String.valueOf(c);

}

return tokens;

}

 

}

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved