zoukankan      html  css  js  c++  java
  • Atitit.java expression fsm 表达式词法分析引擎 v2 qaa.docx

    Atitit.java expression fsm 表达式词法分析引擎 v2 qaa.docx

    C:workspaceAtiPlatf_cmssrccomattilaxfsmJavaExpFsm.java

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

    .trim();

     

     

    Ver2 新特性

    字符串单引号括起来的支持

    字符串可以不要双引号括起来..方便的使用path..

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

    [

    "new",

    "(",

    "com.attilax.user.AgentService",

    ")",

    ".",

    "login",

    "(",

    "admin",

    "admin",

    ")"

    ]

    作者::  ★(attilax)>>>   绰号:老哇的爪子  全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊  汉字名:艾龙,  EMAIL:1466519819@qq.com

    转载请注明来源: http://blog.csdn.net/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;

    }

    }

    Atiend

  • 相关阅读:
    DOORS的引用类型
    C# 中多态和重载的区别
    VS中C#连接SQLite数据库处理器架构“x86”不匹配的问题
    C# 4种方法计算斐波那契数列 Fibonacci
    (C#版本)提升SQlite数据库效率——开启事务,极速插入数据,3秒100万,32秒1000万条数据
    数据结构简单学习
    intellij idea载入java工程报程序包提示不存在,springboot已经导入了依赖依然提示不存在
    springboot整合mybatis提示错误Error:java: 程序包org.apache.ibatis.annotations不存在、找不到符号:类 Mapper
    springboot Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project springboot-mybatis: There are test failures.
    C# Stream 和 byte[] 之间的转换
  • 原文地址:https://www.cnblogs.com/attilax/p/5963205.html
Copyright © 2011-2022 走看看