Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- parserClass="JavaByteCodeLanguage.parser.JavaByteCodeParser"
- parserUtilClass="JavaByteCodeLanguage.parser.JavaByteCodeParserUtil"
- extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
- psiClassPrefix="JavaByteCode"
- psiImplClassSuffix="Impl"
- psiPackage="JavaByteCodeLanguage.psi"
- psiImplPackage="JavaByteCodeLanguage.psi.impl"
- elementTypeHolderClass="JavaByteCodeLanguage.psi.JavaByteCodeTypes"
- elementTypeClass="JavaByteCodeLanguage.psi.JavaByteCodeElementType"
- tokenTypeClass="JavaByteCodeLanguage.psi.JavaByteCodeTokenType"
- //implements("") = "org.intellij.lang."
- tokens=[
- COMMENT='regexp://.*'
- BLOCK_COMMENT="regexp:/\*[^\*/]*\*/"
- NUMBER ='regexp:(-)?\d+(\.\d*)?'
- STRING="regexp:('([^'\\]|\\.)*'|\"([^\"\\]|\\.)*\")"
- // INST="regexp:A(A)?(CONST_NULL|LOAD|STORE)(_\d)?|(I)(CONST|LOAD|STORE)(_M?\d)?|(I|L|F|D|A)?RETURN|INVOKE(SPECIAL|STATIC|VIRTUAL)|DUP|NOP|IF(EQ|NE|LT|GE|GT|LE|_ICMP(EQ|NE|LT|GE|GT|LE)|_ACMP(EQ|NE))|IINC|ARRAYLENGTH|GOTO|NEW|CHECKCAST"
- // CONST
- //EOF = "regexp:\n"
- SPACE='regexp:\s+'
- COMMA=","
- DOT="."
- LBRACKET="regexp:\(|\{|\[|«"
- RBRACKET="regexp:\)|\}|\]|»"
- CONSTMETHODNAMES = "regexp:<(cl)?init>"
- // @see https://en.wikipedia.org/wiki/Java_bytecode_instruction_listings
- // important: order matters !!! e.g. ILOAD_0 must come before ILOAD,
- // or ILOAD will incorrectly match first for ILOAD_0
- // not included: getfield, getstatic, putfield, putstatic
- MNEMONIC="regexp:AALOAD|AASTORE|ACONST_NULL|ALOAD_0|ALOAD_1|ALOAD_2|ALOAD_3|ALOAD|\
- |ANEWARRAY|ARETURN|ARRAYLENGTH|ASTORE_0|ASTORE_1|ASTORE_2|ASTORE_3|ASTORE|\
- |ATHROW|BALOAD|BASTORE|BIPUSH|BREAKPOINT|CALOAD|CASTORE|CHECKCAST|\
- |D2F|D2I|DADD|DALOAD|DASTORE|DCMPG|DCMPL|DCONST_0|DCONST_1|DDIV|\
- |DLOAD_0|DLOAD_1|DLOAD_2|DLOAD_3|DLOAD|DMUL|DNEG|DREM|DRETURN|\
- |DSTORE_0|DSTORE_1|DSTORE_2|DSTORE_3|DSTORE|DSUB|DUP|DUP_X1|DUP_X2|\
- |DUP2|DUP2_X1|DUP2_X2|F2D|F2I|F2L|FADD|FALOAD|FASTORE|FCMPG|FCMPL|\
- |FCONST_0|FCONST_1|FCONST_2|FDIV|FLOAD_0|FLOAD_1|FLOAD_2|FLOAD_3|FLOAD|\
- |FMUL|FNEG|FREM|FRETURN|FSTORE_0|FSTORE_1|FSTORE_2|FSTORE_3|FSTORE|FSUB|\
- |GOTO|GOTO_W|I2B|I2C|I2D|I2F|I2L|I2S|IADD|IALOAD|IAND|IASTORE|ICONST_M1|\
- |ICONST_0|ICONST_1|ICONST_2|ICONST_3|ICONST_4|ICONST_5|IDIV|IF_ACMPEQ|\
- |IF_ACMPNE|IF_ICMPEQ|IF_ICMPGE|IF_ICMPGT|IF_ICMPLE|IF_ICMPLT|IF_ICMPNE|\
- |IFEQ|IFGE|IFGT|IFLE|IFLT|IFNE|IFNONNULL|IFNULL|IINC|\
- |ILOAD_0|ILOAD_1|ILOAD_2|ILOAD_3|ILOAD|IMPDEP1|IMPDEP2|IMUL|INEG|INSTANCEOF|\
- |INVOKEDYNAMIC|INVOKEINTERFACE|INVOKESPECIAL|INVOKESTATIC|INVOKEVIRTUAL|\
- |IOR|IREM|IRETURN|ISHL|ISHR|ISTORE_0|ISTORE_1|ISTORE_2|ISTORE_3|ISTORE|\
- |ISUB|IUSHR|IXOR|JSR|JSR_W|L2D|L2F|L2I|LADD|LALOAD|LAND|LASTORE|LCMP|\
- |LCONST_0|LCONST_1|LDC|LDC_W|LDC2_W|LDIV|\
- |LLOAD_0|LLOAD_1|LLOAD_2|LLOAD_3|LLOAD|LMUL|LNEG|LOOKUPSWITCH|LOR|LREM|\
- |LRETURN|LSHL|LSTORE_0|LSTORE_1|LSTORE_2|LSTORE_3|LSTORE|LSUB|LUSHR|LXOR|\
- |MONITORENTER|MONITOREXIT|MULTIANEWARRAY|NEW|NEWARRAY|NOP|POP|POP2|\
- |RETURN|RET|SALOAD|SASTORE|SIPUSH|SWAP|TABLESWITCH|WIDE"
- PUT_GET_INSTR="regexp:(put|get) .* :"
- LOAD_INSTR="regexp:Load([A-Za-z]+)"
- //JAVACONST
- CLASS='class'
- EXTENDS='extends'
- IMPLEMENTS='implements'
- // TYPES
- PRIMITIVETYPE="regexp:void|boolean|byte|char|short|int|long|float|double"
- MODIFIER="regexp:static|final|abstract|default"
- PREMODIFIER="regexp:public|private|protected"
- STRINGVAR = "regexp:[a-zA-Z$_][a-zA-Z0-9$_]*"
- INST="regexp:[A-Z_0-9]+" // TODO: remove this
- ]
- psiImplUtilClass="JavaByteCodeLanguage.psi.impl.JavaByteCodePsiImplUtil"
- // mixin("JAVATYPE")="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
- // implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
- // methods=[getKey getValue getName setName getNameIdentifier getReferences]
- }
- jbcFile ::= ClassHead item_*
- ClassHead ::= ModifierV? ("@"?)(class|enum|interface) JType (extends JType)? (implements (JType(",")?)+)?
- private item_ ::= MethodDeclaration
- MethodDeclaration ::= MethodHead InstructionHead InstructionBody* LocVarTableDeclaration? {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
- implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
- methods=[getName setName getNameIdentifier getPresentation]}
- Private MethodHead ::= ModifierV? Type MethodName ("«" (STRINGVAR ","?)* "»")? // JAVA
- ModifierV ::= (PREMODIFIER)?(MODIFIER)*
- // TODO: add some pin/recover rule ... need sth to mark end of line ? And where? InstrBody or Instr?
- private InstructionHead ::= PC Line Instruction
- private InstructionBody::= NUMBER NUMBER Instr
- Instr ::= (PUT_GET_INSTR Type) | ((LOAD_INSTR|MNEMONIC) ("("((JavaOP|NUMBER|STRING|Type)','?)*")"|JavaOP)?)
- Type ::= (LambdaType | JType | PRIMITIVETYPE)('[]')*
- JType ::= (STRINGVAR'.')*STRINGVAR {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
- implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
- methods=[getJavaType getName setName getNameIdentifier getReferences]}
- LambdaType ::= (STRINGVAR'.')*STRINGVAR lambdaParams STRINGVAR ":" NUMBER STRINGVAR
- lambdaParams ::= ('('(STRINGVAR ':'?)*')')
- MethodName ::= ('<init>'|'<clinit>'|DefMethodName) params
- DefMethodName ::= STRINGVAR {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
- implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
- methods=[getStringVar getName setName getNameIdentifier getReferences]}
- params ::= ('('(Type ','?)*')')?
- // e.g. java.io.PrintStream{ void println(java.lang.String) }
- JavaOP ::= (Type('{'Type MethodName'}')?)+ | 'lvIndex=' NUMBER
- private ObjType ::= "ObjectType" LBRACKET Type RBRACKET
- LocVarTableDeclaration ::= LocVarTableHead LocVarTableBody* {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
- implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
- methods=[getName setName getNameIdentifier getPresentation]}
- LocVarTableHead ::= LocalVariableTable
- private LocVarTableBody ::= "["NUMBER ">" NUMBER ")" "=>" Type (this | STRINGVAR) // NOT RIGHT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement