SHARE
TWEET

Untitled

a guest Feb 28th, 2019 156 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.  
  94. Type ::= (LambdaType | JType | PRIMITIVETYPE)('[]')*
  95. JType ::= (STRINGVAR'.')*STRINGVAR  {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  96.                    implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  97.                    methods=[getJavaType getName setName getNameIdentifier getReferences]}
  98.  
  99. LambdaType ::= (STRINGVAR'.')*STRINGVAR lambdaParams STRINGVAR ":" NUMBER STRINGVAR
  100. lambdaParams ::= ('('(STRINGVAR ':'?)*')')
  101.  
  102.  
  103.  
  104. private MethodHead ::= ModifierV Type MethodName ("«" (STRINGVAR ","?)* "»")? // JAVA
  105.  
  106. ModifierV ::= (PREMODIFIER)?(MODIFIER)*
  107.  
  108. MethodName ::=  ('<init>'|'<clinit>'|DefMethodName) params
  109. DefMethodName ::= STRINGVAR {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  110.                             implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  111.                             methods=[getStringVar getName setName getNameIdentifier getReferences]}
  112. params ::= ('('(Type ','?)*')')?
  113.  
  114. // TODO: add some pin/recover rule ... need sth to mark end of line ? And where? InstrBody or Instr?
  115. private InstructionHead ::= PC Line Instruction
  116. private InstructionBody::= NUMBER NUMBER Instr
  117. Instr ::= (PUT_GET_INSTR Type) | ((LOAD_INSTR|MNEMONIC) ("("((JavaOP|NUMBER|STRING|Type)','?)*")"|JavaOP)?)
  118.  
  119. // e.g. java.io.PrintStream{ void println(java.lang.String) }
  120. JavaOP ::= (Type('{'Type MethodName'}')?)+ | 'lvIndex=' NUMBER
  121.  
  122. private ObjType ::= "ObjectType" LBRACKET Type RBRACKET
  123.  
  124.  
  125. LocVarTableDeclaration ::= LocVarTableHead LocVarTableBody* {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  126.                                                                               implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  127.                                                                               methods=[getName setName getNameIdentifier getPresentation]}
  128.  
  129. LocVarTableHead ::= LocalVariableTable
  130. 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