Search in sources :

Example 1 with BooleanExprToken

use of org.develnext.jphp.core.tokenizer.token.expr.value.BooleanExprToken in project jphp by jphp-compiler.

the class TokenizerTest method testSplitNot.

@Test
public void testSplitNot() throws IOException {
    Tokenizer tokenizer = new Tokenizer(new Context("!true"));
    assertTrue(tokenizer.nextToken() instanceof BooleanNotExprToken);
    assertTrue(tokenizer.nextToken() instanceof BooleanExprToken);
}
Also used : Context(php.runtime.env.Context) BooleanNotExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanNotExprToken) Tokenizer(org.develnext.jphp.core.tokenizer.Tokenizer) BooleanExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.BooleanExprToken) Test(org.junit.Test)

Example 2 with BooleanExprToken

use of org.develnext.jphp.core.tokenizer.token.expr.value.BooleanExprToken in project jphp by jphp-compiler.

the class TokenizerTest method testScalarTokens.

@Test
public void testScalarTokens() throws IOException {
    Token token;
    Tokenizer tokenizer = new Tokenizer(new Context("10 3.3 'foo' '' \"xyz\" 0xCC 0b0011 true false"));
    token = tokenizer.nextToken();
    assertTrue(token instanceof IntegerExprToken);
    assertEquals(10L, ((IntegerExprToken) token).getValue());
    token = tokenizer.nextToken();
    assertTrue(token instanceof DoubleExprToken);
    assertEquals(3.3, ((DoubleExprToken) token).getValue(), 0.01);
    token = tokenizer.nextToken();
    assertTrue(token instanceof StringExprToken);
    assertEquals(StringExprToken.Quote.SINGLE, ((StringExprToken) token).getQuote());
    assertEquals("foo", ((StringExprToken) token).getValue());
    token = tokenizer.nextToken();
    assertTrue(token instanceof StringExprToken);
    assertEquals(StringExprToken.Quote.SINGLE, ((StringExprToken) token).getQuote());
    assertEquals("", ((StringExprToken) token).getValue());
    token = tokenizer.nextToken();
    assertTrue(token instanceof StringExprToken);
    assertEquals(DOUBLE, ((StringExprToken) token).getQuote());
    assertEquals("xyz", ((StringExprToken) token).getValue());
    token = tokenizer.nextToken();
    assertTrue(token instanceof IntegerExprToken);
    assertEquals(new BigInteger("CC", 16).longValue(), ((IntegerExprToken) token).getValue());
    token = tokenizer.nextToken();
    assertTrue(token instanceof IntegerExprToken);
    assertEquals(new BigInteger("0011", 2).longValue(), ((IntegerExprToken) token).getValue());
    token = tokenizer.nextToken();
    assertTrue(token instanceof BooleanExprToken);
    assertEquals(true, ((BooleanExprToken) token).getValue());
    token = tokenizer.nextToken();
    assertTrue(token instanceof BooleanExprToken);
    assertEquals(false, ((BooleanExprToken) token).getValue());
    token = tokenizer.nextToken();
    assertNull(token);
}
Also used : Context(php.runtime.env.Context) DoubleExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.DoubleExprToken) IntegerExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.IntegerExprToken) BigInteger(java.math.BigInteger) StaticAccessExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.StaticAccessExprToken) GlobalStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.GlobalStmtToken) DefaultStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.DefaultStmtToken) CommentToken(org.develnext.jphp.core.tokenizer.token.CommentToken) DirMacroToken(org.develnext.jphp.core.tokenizer.token.expr.value.macro.DirMacroToken) NamespaceStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.NamespaceStmtToken) PowExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.PowExprToken) IdenticalExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.IdenticalExprToken) ModExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.ModExprToken) MulExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.MulExprToken) DoStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.DoStmtToken) FunctionMacroToken(org.develnext.jphp.core.tokenizer.token.expr.value.macro.FunctionMacroToken) EqualExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.EqualExprToken) EndswitchStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.EndswitchStmtToken) ReturnStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ReturnStmtToken) PlusExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.PlusExprToken) ForStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ForStmtToken) BraceExprToken(org.develnext.jphp.core.tokenizer.token.expr.BraceExprToken) ProtectedStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ProtectedStmtToken) EndwhileStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.EndwhileStmtToken) StaticExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.StaticExprToken) DollarExprToken(org.develnext.jphp.core.tokenizer.token.expr.DollarExprToken) ForeachStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ForeachStmtToken) VariableExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.VariableExprToken) TraitMacroToken(org.develnext.jphp.core.tokenizer.token.expr.value.macro.TraitMacroToken) AbstractStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.AbstractStmtToken) FinallyStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.FinallyStmtToken) CommaToken(org.develnext.jphp.core.tokenizer.token.expr.CommaToken) SemicolonToken(org.develnext.jphp.core.tokenizer.token.SemicolonToken) CatchStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.CatchStmtToken) EndifStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.EndifStmtToken) ClassMacroToken(org.develnext.jphp.core.tokenizer.token.expr.value.macro.ClassMacroToken) ConcatExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.ConcatExprToken) BooleanExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.BooleanExprToken) TryStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.TryStmtToken) DynamicAccessExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.DynamicAccessExprToken) BooleanAndExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanAndExprToken) FunctionStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.FunctionStmtToken) BooleanNotExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanNotExprToken) NotIdenticalExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.NotIdenticalExprToken) FinalStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.FinalStmtToken) DoubleExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.DoubleExprToken) ElseIfStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ElseIfStmtToken) MinusExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.MinusExprToken) BooleanXorExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanXorExprToken) ImplementsStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ImplementsStmtToken) Token(org.develnext.jphp.core.tokenizer.token.Token) IfStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.IfStmtToken) NamespaceMacroToken(org.develnext.jphp.core.tokenizer.token.expr.value.macro.NamespaceMacroToken) AssignExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.AssignExprToken) PublicStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.PublicStmtToken) BooleanNotEqualExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanNotEqualExprToken) EndforStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.EndforStmtToken) SmallerOrEqualToken(org.develnext.jphp.core.tokenizer.token.expr.operator.SmallerOrEqualToken) SwitchStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.SwitchStmtToken) BooleanAnd2ExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanAnd2ExprToken) MethodMacroToken(org.develnext.jphp.core.tokenizer.token.expr.value.macro.MethodMacroToken) ElseStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ElseStmtToken) BooleanOrExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanOrExprToken) IntegerExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.IntegerExprToken) DeclareStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.DeclareStmtToken) LineMacroToken(org.develnext.jphp.core.tokenizer.token.expr.value.macro.LineMacroToken) ClassStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ClassStmtToken) FileMacroToken(org.develnext.jphp.core.tokenizer.token.expr.value.macro.FileMacroToken) BooleanOr2ExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanOr2ExprToken) WhileStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.WhileStmtToken) ExtendsStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ExtendsStmtToken) GreaterOrEqualExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.GreaterOrEqualExprToken) PrivateStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.PrivateStmtToken) EndforeachStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.EndforeachStmtToken) NamespaceUseStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.NamespaceUseStmtToken) StringExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.StringExprToken) DivExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.DivExprToken) NameToken(org.develnext.jphp.core.tokenizer.token.expr.value.NameToken) NewExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.NewExprToken) CaseStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.CaseStmtToken) Tokenizer(org.develnext.jphp.core.tokenizer.Tokenizer) StringExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.StringExprToken) BooleanExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.BooleanExprToken) Test(org.junit.Test)

Aggregations

Tokenizer (org.develnext.jphp.core.tokenizer.Tokenizer)2 BooleanNotExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanNotExprToken)2 BooleanExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.BooleanExprToken)2 Test (org.junit.Test)2 Context (php.runtime.env.Context)2 BigInteger (java.math.BigInteger)1 CommentToken (org.develnext.jphp.core.tokenizer.token.CommentToken)1 SemicolonToken (org.develnext.jphp.core.tokenizer.token.SemicolonToken)1 Token (org.develnext.jphp.core.tokenizer.token.Token)1 BraceExprToken (org.develnext.jphp.core.tokenizer.token.expr.BraceExprToken)1 CommaToken (org.develnext.jphp.core.tokenizer.token.expr.CommaToken)1 DollarExprToken (org.develnext.jphp.core.tokenizer.token.expr.DollarExprToken)1 AssignExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.AssignExprToken)1 BooleanAnd2ExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanAnd2ExprToken)1 BooleanAndExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanAndExprToken)1 BooleanNotEqualExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanNotEqualExprToken)1 BooleanOr2ExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanOr2ExprToken)1 BooleanOrExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanOrExprToken)1 BooleanXorExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.BooleanXorExprToken)1 ConcatExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.ConcatExprToken)1