⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perl5compiler.java

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	if((__modifierFlags[0] & __CASE_INSENSITIVE) != 0 &&	   Character.isUpperCase(ender))	  ender = Character.toLowerCase(ender);	if(pOffset < maxOffset && __isComplexRepetitionOp(__input._array, pOffset)) {	  if(length > 0)	    pOffset = lastOffset;	  else {	    ++length;	    __emitCode(ender);	  }	  break;	}	__emitCode(ender);      } // end for loop      __input._setOffset(pOffset - 1);      __getNextChar();      if(length < 0)	throw new MalformedPatternException(         "Unexpected compilation failure.  Please report this bug!");      if(length > 0)	retFlags[0] |= __NONNULL;      if(length == 1)	retFlags[0] |= __SIMPLE;      if(__program!= null)	__program[OpCode._getOperand(offset)] = (char)length;      //__emitCode('\0'); // debug      __emitCode(CharStringPointer._END_OF_STRING);    }    return offset;  }  // Set the bits in a character class.  Only recognizes ascii.  private void __setCharacterClassBits(char[] bits, int offset, char deflt,				       char ch)  {    if(__program== null || ch >= 256)      return;    ch &= 0xffff;    if(deflt == 0) {      bits[offset + (ch >> 4)] |= (1 << (ch & 0xf));    } else {      bits[offset + (ch >> 4)] &= ~(1 << (ch & 0xf));    }  }  private int __parseCharacterClass() throws MalformedPatternException {    boolean range = false, skipTest;    char clss, deflt, lastclss = Character.MAX_VALUE;    int offset, bits, numLength[] = { 0 };    offset = __emitNode(OpCode._ANYOF);    if(__input._getValue() == '^') {      ++__cost;      __input._increment();      deflt = 0;    } else {      deflt = 0xffff;    }    bits = __programSize;    for(clss = 0; clss < 16; clss++)      __emitCode(deflt);    clss = __input._getValue();    if(clss == ']' || clss == '-')      skipTest = true;    else      skipTest = false;    while((!__input._isAtEnd() && (clss = __input._getValue()) != ']')	  || skipTest) {      // It sucks, but we have to make this assignment every time      skipTest = false;      __input._increment();      if(clss == '\\') {	clss = __input._postIncrement();	switch(clss){	case 'w':	  for(clss = 0; clss < 256; clss++)	    if(OpCode._isWordCharacter(clss))	      __setCharacterClassBits(__program, bits, deflt, clss);	  lastclss = Character.MAX_VALUE;	  continue;	case 'W':	  for(clss = 0; clss < 256; clss++)	    if(!OpCode._isWordCharacter(clss))	      __setCharacterClassBits(__program, bits, deflt, clss);	  lastclss = Character.MAX_VALUE;	  continue;	case 's':	  for(clss = 0; clss < 256; clss++)	    if(Character.isWhitespace(clss))	      __setCharacterClassBits(__program, bits, deflt, clss);	  lastclss = Character.MAX_VALUE;	  continue;	case 'S':	  for(clss = 0; clss < 256; clss++)	    if(!Character.isWhitespace(clss))	      __setCharacterClassBits(__program, bits, deflt, clss);	  lastclss = Character.MAX_VALUE;	  continue;	case 'd':	  for(clss = '0'; clss <= '9'; clss++)	    __setCharacterClassBits(__program, bits, deflt, clss);	  lastclss = Character.MAX_VALUE;	  continue;	case 'D':	  for(clss = 0; clss < '0'; clss++)	    __setCharacterClassBits(__program, bits, deflt, clss);	  for(clss = (char)('9' + 1); clss < 256; clss++)	    __setCharacterClassBits(__program, bits, deflt, clss);	  lastclss = Character.MAX_VALUE;	  continue;	case 'n':	  clss = '\n';	  break;	case 'r':	  clss = '\r';	  break;	case 't':	  clss = '\t';	  break;	case 'f':	  clss = '\f';	  break;	case 'b':	  clss = '\b';	  break;	case 'e':	  clss = '\033';	  break;	case 'a':	  clss = '\007';	  break;	case 'x':	  clss = (char)__parseHex(__input._array, __input._getOffset(), 2,				  numLength);	  __input._increment(numLength[0]);	  break;	case 'c':	  clss = __input._postIncrement();	  if(Character.isLowerCase(clss))	    clss = Character.toUpperCase(clss);	  clss ^= 64;	  break;	case '0': case '1': case '2': case '3': case '4':	case '5': case '6': case '7': case '8': case '9':	  clss = (char)__parseOctal(__input._array, __input._getOffset() - 1,				    3, numLength);	  __input._increment(numLength[0] - 1);	  break;	}      }      if(range) {	if(lastclss > clss)	  throw new MalformedPatternException(			 "Invalid [] range in expression.");	range = false;      } else {	lastclss = clss;	if(__input._getValue() == '-' &&	   __input._getOffset() + 1 < __input._getLength() &&	   __input._getValueRelative(1) != ']') {	  __input._increment();	  range = true;	  continue;	}      }      while(lastclss <= clss) {	__setCharacterClassBits(__program, bits, deflt, lastclss);	if((__modifierFlags[0] & __CASE_INSENSITIVE) != 0 &&	   Character.isUpperCase(lastclss))	  __setCharacterClassBits(__program, bits, deflt,				 Character.toLowerCase(lastclss));	++lastclss;      }      lastclss = clss;    }    if(__input._getValue() != ']')      throw new MalformedPatternException("Unmatched [] in expression.");    __getNextChar();    return offset;  }  private int __parseBranch(int[] retFlags) throws MalformedPatternException {    boolean nestCheck = false, handleRepetition = false;    int offset, next, min, max, flags[] = { 0 };    char operator, value;    min = 0;    max = Character.MAX_VALUE;    offset = __parseAtom(flags);    if(offset == OpCode._NULL_OFFSET) {      if((flags[0] & __TRYAGAIN) != 0)	retFlags[0] |= __TRYAGAIN;      return OpCode._NULL_OFFSET;    }    operator = __input._getValue();    if(operator == '(' && __input._getValueRelative(1) == '?' &&       __input._getValueRelative(2) == '#') {      while(operator != CharStringPointer._END_OF_STRING && operator != ')')	operator = __input._increment();      if(operator != CharStringPointer._END_OF_STRING) {	__getNextChar();	operator = __input._getValue();      }    }    if(operator == '{' &&       __parseRepetition(__input._array, __input._getOffset())) {      int maxOffset, pos;      next = __input._getOffset() + 1;      pos = maxOffset = __input._getLength();      value = __input._getValue(next);      while(Character.isDigit(value) || value == ',') {	if(value == ',') {	  if(pos != maxOffset)	    break;	  else	    pos = next;	}	++next;	value = __input._getValue(next);      }      if(value == '}') {	int num;	StringBuffer buffer = new StringBuffer(10);	if(pos == maxOffset)	  pos = next;	__input._increment();	num = __input._getOffset();	value = __input._getValue(num);	while(Character.isDigit(value)) {	  buffer.append(value);	  ++num;	  value = __input._getValue(num);	}	try {	  min = Integer.parseInt(buffer.toString());	} catch(NumberFormatException e) {	  throw new MalformedPatternException(	 "Unexpected number format exception.  Please report this bug." +	   "NumberFormatException message: " + e.getMessage());	}	value = __input._getValue(pos);	if(value == ',')	  ++pos;	else	  pos = __input._getOffset();	num = pos;	buffer = new StringBuffer(10);	value = __input._getValue(num);	while(Character.isDigit(value)){	  buffer.append(value);	  ++num;	  value = __input._getValue(num);	}	try {	  if(num != pos)	    max = Integer.parseInt(buffer.toString());	} catch(NumberFormatException e) {	  throw new MalformedPatternException(	 "Unexpected number format exception.  Please report this bug." +	   "NumberFormatException message: " + e.getMessage());	}	//System.err.println("min: " + min + " max: " + max); //debug	if(max == 0 && __input._getValue(pos) != '0')	  max = Character.MAX_VALUE;	__input._setOffset(next);	__getNextChar();	//System.err.println("min: " + min + " max: " + max); //debug	nestCheck = true;	handleRepetition = true;      }    }    if(!nestCheck) {      handleRepetition = false;      if(!__isSimpleRepetitionOp(operator)) {	retFlags[0] = flags[0];	return offset;      }      __getNextChar();      retFlags[0] = ((operator != '+') ?		  (__WORSTCASE | __SPSTART) : (__WORSTCASE | __NONNULL));      if(operator == '*' && ((flags[0] & __SIMPLE) != 0)) {	__programInsertOperator(OpCode._STAR, offset);	__cost+=4;      } else if(operator == '*') {	min = 0;	handleRepetition = true;      } else if(operator == '+' && (flags[0] & __SIMPLE) != 0) {	__programInsertOperator(OpCode._PLUS, offset);	__cost+=3;      } else if(operator == '+') {	min = 1;	handleRepetition = true;      } else if(operator == '?') {	min = 0;	max = 1;	handleRepetition = true;      }    }    if(handleRepetition) {      // handle repetition      if((flags[0] & __SIMPLE) != 0){	__cost+= ((2 + __cost) / 2);	__programInsertOperator(OpCode._CURLY, offset);      } else {	__cost += (4 + __cost);	__programAddTail(offset, __emitNode(OpCode._WHILEM));	__programInsertOperator(OpCode._CURLYX, offset);	__programAddTail(offset, __emitNode(OpCode._NOTHING));      }      if(min > 0)	retFlags[0] = (__WORSTCASE | __NONNULL);      if(max != 0 && max < min)	throw new MalformedPatternException(       "Invalid interval {" + min + "," + max + "}");      if(__program!= null) {	__program[offset + 2] = (char)min;	__program[offset + 3] = (char)max;      }    }    if(__input._getValue() == '?') {      __getNextChar();      __programInsertOperator(OpCode._MINMOD, offset);      __programAddTail(offset, offset + 2);    }    if(__isComplexRepetitionOp(__input._array, __input._getOffset()))      throw new MalformedPatternException(        "Nested repetitions *?+ in expression");    return offset;  }  private int __parseExpression(boolean isParenthesized, int[] hintFlags)    throws MalformedPatternException {    char value, paren;    int nodeOffset = OpCode._NULL_OFFSET, parenthesisNum = 0, br, ender;    int[] flags = { 0 };    String modifiers = "iogmsx";    // Initially we assume expression doesn't match null string.    hintFlags[0] = __NONNULL;    if (isParenthesized) {      paren = 1;      if(__input._getValue() == '?') {	__input._increment();	paren = value = __input._postIncrement();	switch(value) {	case ':' :	case '=' :	case '!' : break;	case '#' :	  value = __input._getValue();	  while(value != CharStringPointer._END_OF_STRING && value != ')')	    value = __input._increment();	  if(value != ')')	    throw new MalformedPatternException(	       "Sequence (?#... not terminated");	  __getNextChar();	  hintFlags[0] = __TRYAGAIN;	  return OpCode._NULL_OFFSET;	default :	  __input._decrement();	  value = __input._getValue();	  while(value != CharStringPointer._END_OF_STRING &&		modifiers.indexOf(value) != -1) {	    __setModifierFlag(__modifierFlags, value);	    value = __input._increment();	  }	  if(value != ')')	    throw new MalformedPatternException(	       "Sequence (?" + value + "...) not recognized");	  __getNextChar();	  hintFlags[0] = __TRYAGAIN;	  return OpCode._NULL_OFFSET;	}      } else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -