hekailiang / squirrel

squirrel-foundation is a State Machine library, which provided a lightweight, easy use, type safe and programmable state machine implementation for Java.
http://hekailiang.github.io/squirrel/
Other
2.19k stars 540 forks source link

Why can not convert o Mvel expression? #79

Open eakarsu opened 7 years ago

eakarsu commented 7 years ago

I am trying to convert the following long transition expression to this Mvel-based one. But I am getting error. I appreciate any help

2017-10-13 18:48:40,254 ERROR [main] (MvelConditionImpl.java:47) - Evaluate "(context.nextChar!=null && context.nextChar.equals(SLASH))" failed with [Error: could not access: nextChar; in class: java.util.HashMap] [Near : {... (context.nextChar!=null && cont ....}]

builder.externalTransition().from(ParserState.COMMENT).to(ParserState.RULE).on(STAR).whenMvel("Cond2:::(context.nextChar!=null && context.nextChar.equals(STAR))");

builder.externalTransition().from(ParserState.COMMENT).to(ParserState.RULE).on(STAR).when( new Condition() { @Override public boolean isSatisfied(ParserContext context) { return context.nextChar!=null && context.nextChar.equals(SLASH); }

                @Override
                public String name() {
                    return "Cond2";
                }
            });