Search in sources :

Example 1 with Parser

use of net.kodehawa.mantarobot.commands.custom.v3.Parser in project MantaroBot by Mantaro.

the class CustomCommandHandler method handle.

public void handle(boolean preview) {
    if (!processResponse())
        return;
    if (specialHandling())
        return;
    if (response.startsWith("v3:")) {
        CCv3.process(prefixUsed, ctx, new Parser(response.substring(3)).parse(), preview);
        return;
    }
    MessageBuilder builder = new MessageBuilder().setContent(filtered.matcher(response).replaceAll("-filtered regex-"));
    builder.setActionRows(ActionRow.of(Button.primary("yes", ctx.getLanguageContext().get("commands.custom.custom_notice")).asDisabled()));
    if (preview) {
        builder.append("\n\n").append(EmoteReference.WARNING).append("**This is a preview of how a CC with this content would look like, ALL MENTIONS ARE DISABLED ON THIS MODE.**\n").append("`Command preview requested by: ").append(ctx.getAuthor().getAsTag()).append("`");
        builder.denyMentions(Message.MentionType.ROLE, Message.MentionType.USER, Message.MentionType.EVERYONE, Message.MentionType.HERE);
    } else {
        builder.denyMentions(Message.MentionType.ROLE, Message.MentionType.EVERYONE, Message.MentionType.HERE);
    }
    ctx.send(builder.build());
}
Also used : MessageBuilder(net.dv8tion.jda.api.MessageBuilder) Parser(net.kodehawa.mantarobot.commands.custom.v3.Parser)

Example 2 with Parser

use of net.kodehawa.mantarobot.commands.custom.v3.Parser in project jackrabbit by apache.

the class ParserTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    NamePathResolver resolver = new DefaultNamePathResolver(new DummyNamespaceResolver());
    QueryObjectModelFactoryImpl factory = new QOMF(resolver);
    ValueFactory vf = new ValueFactoryQImpl(QValueFactoryImpl.getInstance(), resolver);
    parser = new Parser(factory, vf);
}
Also used : QueryObjectModelFactoryImpl(org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelFactoryImpl) NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) DummyNamespaceResolver(org.apache.jackrabbit.spi.commons.conversion.DummyNamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) ValueFactory(javax.jcr.ValueFactory) ValueFactoryQImpl(org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl) Parser(org.apache.jackrabbit.commons.query.sql2.Parser)

Example 3 with Parser

use of net.kodehawa.mantarobot.commands.custom.v3.Parser in project sulong by graalvm.

the class BasicNodeFactory method createInlineAssemblerExpression.

@Override
public LLVMExpressionNode createInlineAssemblerExpression(LLVMParserRuntime runtime, String asmExpression, String asmFlags, LLVMExpressionNode[] args, Type[] argTypes, Type retType, LLVMSourceLocation sourceSection) {
    Type[] retTypes = null;
    int[] retOffsets = null;
    if (retType instanceof StructureType) {
        // multiple out values
        assert args[1] instanceof LLVMAllocaConstInstruction;
        LLVMAllocaConstInstruction alloca = (LLVMAllocaConstInstruction) args[1];
        retTypes = alloca.getTypes();
        retOffsets = alloca.getOffsets();
    }
    Parser asmParser = new Parser(runtime.getLanguage(), sourceSection, asmExpression, asmFlags, argTypes, retType, retTypes, retOffsets);
    LLVMInlineAssemblyRootNode assemblyRoot = asmParser.Parse();
    LLVMFunctionDescriptor asm = LLVMFunctionDescriptor.createDescriptor(runtime.getContext(), runtime.getLibrary(), "<asm>", new FunctionType(MetaType.UNKNOWN, new Type[0], false), -1);
    asm.declareInSulong(Truffle.getRuntime().createCallTarget(assemblyRoot), false);
    LLVMFunctionLiteralNode asmFunction = LLVMFunctionLiteralNodeGen.create(asm);
    return new LLVMCallNode(new FunctionType(MetaType.UNKNOWN, argTypes, false), asmFunction, args, sourceSection);
}
Also used : LLVMInlineAssemblyRootNode(com.oracle.truffle.llvm.nodes.func.LLVMInlineAssemblyRootNode) LLVMSourcePointerType(com.oracle.truffle.llvm.runtime.debug.LLVMSourcePointerType) VariableBitWidthType(com.oracle.truffle.llvm.runtime.types.VariableBitWidthType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) LLVMConversionType(com.oracle.truffle.llvm.parser.instructions.LLVMConversionType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) LLVMInteropType(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType) LLVMArithmeticInstructionType(com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType) Type(com.oracle.truffle.llvm.runtime.types.Type) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceType) LLVMCallNode(com.oracle.truffle.llvm.nodes.func.LLVMCallNode) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) LLVMFunctionDescriptor(com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor) LLVMFunctionLiteralNode(com.oracle.truffle.llvm.nodes.literals.LLVMFunctionLiteralNode) LLVMAllocaConstInstruction(com.oracle.truffle.llvm.nodes.memory.LLVMAllocInstruction.LLVMAllocaConstInstruction) Parser(com.oracle.truffle.llvm.asm.amd64.Parser)

Aggregations

Parser (com.oracle.truffle.llvm.asm.amd64.Parser)1 LLVMCallNode (com.oracle.truffle.llvm.nodes.func.LLVMCallNode)1 LLVMInlineAssemblyRootNode (com.oracle.truffle.llvm.nodes.func.LLVMInlineAssemblyRootNode)1 LLVMFunctionLiteralNode (com.oracle.truffle.llvm.nodes.literals.LLVMFunctionLiteralNode)1 LLVMAllocaConstInstruction (com.oracle.truffle.llvm.nodes.memory.LLVMAllocInstruction.LLVMAllocaConstInstruction)1 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)1 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)1 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)1 LLVMSourcePointerType (com.oracle.truffle.llvm.runtime.debug.LLVMSourcePointerType)1 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)1 LLVMInteropType (com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType)1 AggregateType (com.oracle.truffle.llvm.runtime.types.AggregateType)1 ArrayType (com.oracle.truffle.llvm.runtime.types.ArrayType)1 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)1 MetaType (com.oracle.truffle.llvm.runtime.types.MetaType)1 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)1 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)1 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)1 Type (com.oracle.truffle.llvm.runtime.types.Type)1 VariableBitWidthType (com.oracle.truffle.llvm.runtime.types.VariableBitWidthType)1