SHARE
TWEET

Untitled

a guest Feb 28th, 2019 149 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2.   parserClass="JavaByteCodeLanguage.parser.JavaByteCodeParser"
  3.   parserUtilClass="JavaByteCodeLanguage.parser.JavaByteCodeParserUtil"
  4.   extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
  5.  
  6.   psiClassPrefix="JavaByteCode"
  7.   psiImplClassSuffix="Impl"
  8.   psiPackage="JavaByteCodeLanguage.psi"
  9.   psiImplPackage="JavaByteCodeLanguage.psi.impl"
  10.  
  11.   elementTypeHolderClass="JavaByteCodeLanguage.psi.JavaByteCodeTypes"
  12.   elementTypeClass="JavaByteCodeLanguage.psi.JavaByteCodeElementType"
  13.   tokenTypeClass="JavaByteCodeLanguage.psi.JavaByteCodeTokenType"
  14.   //implements("") = "org.intellij.lang."
  15.   tokens=[
  16.   COMMENT='regexp://.*'
  17.   BLOCK_COMMENT="regexp:/\*[^\*/]*\*/"
  18.   NUMBER ='regexp:(-)?\d+(\.\d*)?'
  19.   STRING="regexp:('([^'\\]|\\.)*'|\"([^\"\\]|\\.)*\")"
  20.  
  21. //  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"
  22.  
  23.  // CONST
  24.  //EOF = "regexp:\n"
  25.  SPACE='regexp:\s+'
  26.  
  27.  COMMA=","
  28.  DOT="."
  29.  LBRACKET="regexp:\(|\{|\[|«"
  30.  RBRACKET="regexp:\)|\}|\]|»"
  31.  CONSTMETHODNAMES = "regexp:<(cl)?init>"
  32.  
  33.    // @see https://en.wikipedia.org/wiki/Java_bytecode_instruction_listings
  34.    // important: order matters !!! e.g. ILOAD_0 must come before ILOAD,
  35.    //      or ILOAD will incorrectly match first for ILOAD_0
  36.    // not included: getfield, getstatic, putfield, putstatic
  37.    MNEMONIC="regexp:AALOAD|AASTORE|ACONST_NULL|ALOAD_0|ALOAD_1|ALOAD_2|ALOAD_3|ALOAD|\
  38.                      |ANEWARRAY|ARETURN|ARRAYLENGTH|ASTORE_0|ASTORE_1|ASTORE_2|ASTORE_3|ASTORE|\
  39.                      |ATHROW|BALOAD|BASTORE|BIPUSH|BREAKPOINT|CALOAD|CASTORE|CHECKCAST|\
  40.                      |D2F|D2I|DADD|DALOAD|DASTORE|DCMPG|DCMPL|DCONST_0|DCONST_1|DDIV|\
  41.                      |DLOAD_0|DLOAD_1|DLOAD_2|DLOAD_3|DLOAD|DMUL|DNEG|DREM|DRETURN|\
  42.                      |DSTORE_0|DSTORE_1|DSTORE_2|DSTORE_3|DSTORE|DSUB|DUP|DUP_X1|DUP_X2|\
  43.                      |DUP2|DUP2_X1|DUP2_X2|F2D|F2I|F2L|FADD|FALOAD|FASTORE|FCMPG|FCMPL|\
  44.                      |FCONST_0|FCONST_1|FCONST_2|FDIV|FLOAD_0|FLOAD_1|FLOAD_2|FLOAD_3|FLOAD|\
  45.                      |FMUL|FNEG|FREM|FRETURN|FSTORE_0|FSTORE_1|FSTORE_2|FSTORE_3|FSTORE|FSUB|\
  46.                      |GOTO|GOTO_W|I2B|I2C|I2D|I2F|I2L|I2S|IADD|IALOAD|IAND|IASTORE|ICONST_M1|\
  47.                      |ICONST_0|ICONST_1|ICONST_2|ICONST_3|ICONST_4|ICONST_5|IDIV|IF_ACMPEQ|\
  48.                      |IF_ACMPNE|IF_ICMPEQ|IF_ICMPGE|IF_ICMPGT|IF_ICMPLE|IF_ICMPLT|IF_ICMPNE|\
  49.                      |IFEQ|IFGE|IFGT|IFLE|IFLT|IFNE|IFNONNULL|IFNULL|IINC|\
  50.                      |ILOAD_0|ILOAD_1|ILOAD_2|ILOAD_3|ILOAD|IMPDEP1|IMPDEP2|IMUL|INEG|INSTANCEOF|\
  51.                      |INVOKEDYNAMIC|INVOKEINTERFACE|INVOKESPECIAL|INVOKESTATIC|INVOKEVIRTUAL|\
  52.                      |IOR|IREM|IRETURN|ISHL|ISHR|ISTORE_0|ISTORE_1|ISTORE_2|ISTORE_3|ISTORE|\
  53.                      |ISUB|IUSHR|IXOR|JSR|JSR_W|L2D|L2F|L2I|LADD|LALOAD|LAND|LASTORE|LCMP|\
  54.                      |LCONST_0|LCONST_1|LDC|LDC_W|LDC2_W|LDIV|\
  55.                      |LLOAD_0|LLOAD_1|LLOAD_2|LLOAD_3|LLOAD|LMUL|LNEG|LOOKUPSWITCH|LOR|LREM|\
  56.                      |LRETURN|LSHL|LSTORE_0|LSTORE_1|LSTORE_2|LSTORE_3|LSTORE|LSUB|LUSHR|LXOR|\
  57.                      |MONITORENTER|MONITOREXIT|MULTIANEWARRAY|NEW|NEWARRAY|NOP|POP|POP2|\
  58.                      |RETURN|RET|SALOAD|SASTORE|SIPUSH|SWAP|TABLESWITCH|WIDE"
  59.  
  60.  PUT_GET_INSTR="regexp:(put|get) .* :"
  61.  LOAD_INSTR="regexp:Load([A-Za-z]+)"
  62.  
  63.  
  64.  //JAVACONST
  65.  CLASS='class'
  66.  EXTENDS='extends'
  67.  IMPLEMENTS='implements'
  68.  // TYPES
  69.  PRIMITIVETYPE="regexp:void|boolean|byte|char|short|int|long|float|double"
  70.  MODIFIER="regexp:static|final|abstract|default"
  71.  PREMODIFIER="regexp:public|private|protected"
  72.  
  73.  STRINGVAR = "regexp:[a-zA-Z$_][a-zA-Z0-9$_]*"
  74.  
  75.  INST="regexp:[A-Z_0-9]+"    // TODO: remove this
  76.  ]
  77.  
  78.  psiImplUtilClass="JavaByteCodeLanguage.psi.impl.JavaByteCodePsiImplUtil"
  79.  
  80. //  mixin("JAVATYPE")="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  81. //        implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  82. //        methods=[getKey getValue getName setName getNameIdentifier getReferences]
  83. }
  84. jbcFile ::= ClassHead item_*
  85.  
  86. ClassHead ::= ModifierV? ("@"?)(class|enum|interface) JType (extends JType)? (implements (JType(",")?)+)?
  87.  
  88. private item_ ::= MethodDeclaration
  89.  
  90. MethodDeclaration ::= MethodHead InstructionHead InstructionBody* LocVarTableDeclaration? {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  91.                                                                                            implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  92.                                                                                            methods=[getName setName getNameIdentifier getPresentation]}
  93. Private MethodHead ::= ModifierV? Type MethodName ("«" (STRINGVAR ","?)* "»")? // JAVA
  94.  
  95. ModifierV ::= (PREMODIFIER)?(MODIFIER)*
  96.  
  97. // TODO: add some pin/recover rule ... need sth to mark end of line ? And where? InstrBody or Instr?
  98. private InstructionHead ::= PC Line Instruction
  99. private InstructionBody::= NUMBER NUMBER Instr
  100. Instr ::= (PUT_GET_INSTR Type) | ((LOAD_INSTR|MNEMONIC) ("("((JavaOP|NUMBER|STRING|Type)','?)*")"|JavaOP)?)
  101.  
  102.  
  103. Type ::= (LambdaType | JType | PRIMITIVETYPE)('[]')*
  104. JType ::= (STRINGVAR'.')*STRINGVAR  {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  105.                    implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  106.                    methods=[getJavaType getName setName getNameIdentifier getReferences]}
  107.  
  108. LambdaType ::= (STRINGVAR'.')*STRINGVAR lambdaParams STRINGVAR ":" NUMBER STRINGVAR
  109. lambdaParams ::= ('('(STRINGVAR ':'?)*')')
  110.  
  111. MethodName ::=  ('<init>'|'<clinit>'|DefMethodName) params
  112.  
  113. DefMethodName ::= STRINGVAR {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  114.                             implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  115.                             methods=[getStringVar getName setName getNameIdentifier getReferences]}
  116.                            
  117. params ::= ('('(Type ','?)*')')?
  118.  
  119.  
  120. // e.g. java.io.PrintStream{ void println(java.lang.String) }
  121. JavaOP ::= (Type('{'Type MethodName'}')?)+ | 'lvIndex=' NUMBER
  122.  
  123. private ObjType ::= "ObjectType" LBRACKET Type RBRACKET
  124.  
  125.  
  126. LocVarTableDeclaration ::= LocVarTableHead LocVarTableBody* {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  127.                                                                               implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  128.                                                                               methods=[getName setName getNameIdentifier getPresentation]}
  129.  
  130. LocVarTableHead ::= LocalVariableTable
  131. private LocVarTableBody ::= "["NUMBER ">" NUMBER ")" "=>" Type (this | STRINGVAR) // NOT RIGHT
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top