SHARE
TWEET

Jbc-Grammar v2

a guest Feb 20th, 2019 194 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.   SPACE='regexp:\s+'
  17.   COMMENT='regexp://.*'
  18.   NUMBER ='regexp:(-)?\d+'
  19.   STRING="regexp:('([^'\\]|\\.)*'|\"([^\"\\]|\\.)*\")"
  20.  //JAVA="regexp:(([A-Za-z])*\.)+([A-Za-z])*(\{(.)*\})?"
  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|LoadString|NEW|CHECKCAST"
  22.  
  23.  PUT_GET_INSTR="regexp:(put|get) .* :"
  24.  LOAD_INSTR="regexp:Load([A-Za-z]+)[(]\"?.*\"?[)]"
  25.  StuffInAngles="regexp:«(\w+)»"
  26.  
  27.  // TYPES
  28.  JAVATYPE="regexp:(([A-Za-z_])*\.)+[A-Z-a-z_]*"
  29.  PRIMITIVETYPE="regexp:void|boolean|byte|char|short|int|long|float|double"
  30.  MODIFIER="regexp:static|final|abstract|default"
  31.  PREMODIFIER="regexp:public|private|protected|default"
  32.  EOF = "\n"
  33.  STRINGVAR = "regexp:[A-Za-z0-9]+"
  34.  ]
  35.  
  36.  psiImplUtilClass="JavaByteCodeLanguage.psi.impl.JavaByteCodePsiImplUtil"
  37.  
  38. //  mixin("JAVATYPE")="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  39. //        implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  40. //        methods=[getKey getValue getName setName getNameIdentifier getReferences]
  41. }
  42. jbcFile ::= item_*
  43.  
  44. private item_ ::= (MethodDeclaration)
  45. Type ::= (JType | PRIMITIVETYPE)('[]')*
  46.  
  47. JType ::= JAVATYPE {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  48.                    implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  49.                    methods=[getJavaType getName setName getNameIdentifier getReferences]}
  50.  
  51. MethodDeclaration ::= MethodHead InstructionHead InstructionBody* LocVarTableDeleration?
  52. MethodHead ::= Modifier? Type MethodName StuffInAngles* // JAVA
  53. Modifier ::= PREMODIFIER? MODIFIER*
  54. //MethodName ::= ('<init>'|'<clinit>'|STRINGVAR)('('(Type ','?)*')')?
  55. //    | STRINGVAR {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  56. //                implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement" methods=[getKey getValue getName setName getNameIdentifier]}
  57. MethodName ::=  ('<init>'|'<clinit>'|DefMethodName) params
  58.  
  59. DefMethodName ::= STRINGVAR {mixin="JavaByteCodeLanguage.psi.impl.JavaByteCodeNamedElementImpl"
  60.                             implements="JavaByteCodeLanguage.psi.JavaByteCodeNamedElement"
  61.                             methods=[getStringVar getName setName getNameIdentifier getReferences]}
  62. params ::= ('('(Type ','?)*')')?
  63.  
  64. private InstructionHead ::= PC Line Instruction
  65. private InstructionBody::= NUMBER NUMBER Instr
  66. Instr ::= (INST ("("((JavaOP|NUMBER|STRING)','?)*")"|JavaOP)?) | (PUT_GET_INSTR Type) | (LOAD_INSTR)// TODO {recoverWhile=recoverTillNextInstr}
  67. JavaOP ::= ((Type|STRINGVAR)('{'Type MethodName'}')?)+| 'lvIndex=' NUMBER
  68.  
  69.    private recoverTillNextInstr ::= !NUMBER
  70.  
  71. LocVarTableDeleration ::= LocVarTableHead LocVarTableBody*
  72. private LocVarTableHead ::= LocalVariableTable
  73. 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