1 package com.daffodilwoods.daffodildb.utils.parser; 2 3 import java.lang.reflect.Field ; 4 5 10 11 public class CharacterStringLiteralProductionRules 12 extends ProductionRules { 13 14 char c; 15 16 CharacterStringLiteralProductionRules(char c0, ClassLoader classLoader0) { 17 super(classLoader0); 18 c=c0; 19 ruleKey = nameOfRule; 20 className = c=='\'' ? "charactestringliteral" : "delimitedidentifier"; 21 } 22 23 30 Object parsePart(ParseElements pe) { 31 int position = pe.position; 32 char[] val = pe.queryArray; 33 int length = val.length; 34 35 while (position < pe.queryArray.length && Character.isWhitespace(val[position])) 36 position++; 37 38 if (position == pe.queryArray.length || val[position] != c){ 39 return pe.parseException; 40 } 41 42 position++; 43 StringBuffer stbfr = new StringBuffer (); while (position < length) { 45 if (val[position] == c) { 46 position++; 47 if (position < length && val[position] == c) { 48 stbfr.append(val[position]); 49 position++; 50 continue; 51 } 52 else { 53 pe.position = position; 54 57 if(c!='\'' && stbfr.toString().length()==0) 58 return pe.parseException; 59 return stbfr.toString(); 60 } 61 } 62 stbfr.append(val[position]); 63 position++; 64 } 65 return pe.parseException; 66 } 67 } 68 | Popular Tags |