Example #1
0
PT_Production SDFProductionToPtProduction(SDF_Production sdfProduction)
{
  SDF_Symbol  sdfResult;
  SDF_Attributes sdfAttributes;
  PT_Symbols ptSymbols;
  PT_Symbol  ptResult;
  PT_Attributes ptAttributes;

  sdfResult  = SDF_getProductionResult(sdfProduction);
  sdfAttributes = SDF_getProductionAttributes(sdfProduction);
  ptResult  = SDFSymbolToPtSymbol(sdfResult);
  ptAttributes = SDFAttributesToPtAttributes(sdfAttributes);

  if (SDF_isProductionProd(sdfProduction)) {
    SDF_Symbols sdfSymbols = SDF_getProductionSymbols(sdfProduction);
    ptSymbols = SDFSymbolsToPtSymbols(sdfSymbols);
  }
  else {
    ATwarning("SDFProductionToPtProduction: unable to convert %s\n", 
	      PT_yieldTreeToString((PT_Tree) sdfProduction, ATfalse));
    return NULL;
  }

  return PT_makeProductionDefault(ptSymbols, ptResult, ptAttributes);
}
Example #2
0
PT_Tree PT_makeTreeLit(const char* string)
{
  int len = strlen(string);
  int i;
  PT_Args args = PT_makeArgsEmpty();
  PT_Symbols symbols = PT_makeSymbolsEmpty();
  PT_Symbol symbol = PT_makeSymbolLit(string);
  PT_Attributes attrs = PT_makeAttributesNoAttrs();
  PT_Production prod;

  for (i = len - 1; i >= 0; i--) {
    PT_Tree arg;
    PT_Symbol symbol;

    arg = PT_makeTreeChar(string[i]);
    args = PT_makeArgsMany(arg, args);

    symbol = PT_makeSymbolCharClass(
	      PT_makeCharRangesSingle(
	        PT_makeCharRangeCharacter(string[i])));
    symbols = PT_makeSymbolsMany(symbol, symbols);
  }

  prod = PT_makeProductionDefault(symbols, symbol, attrs);

  return PT_makeTreeAppl(prod, args);
}
Example #3
0
PT_Tree PT_makeTreeLexToCf(PT_Symbol sym, PT_Tree tree)
{
  PT_Symbol lexSymbol = PT_makeSymbolLex(sym);
  PT_Symbol cfSymbol = PT_makeSymbolCf(sym);
  PT_Symbols lhs = PT_makeSymbolsSingle(lexSymbol);
  PT_Attributes noattrs = PT_makeAttributesNoAttrs();
  PT_Production prod = PT_makeProductionDefault(lhs, cfSymbol, noattrs);
  PT_Args args = PT_makeArgsSingle(tree);

  return PT_makeTreeAppl(prod, args);
}
Example #4
0
PT_Tree PT_makeTreeCilit(const char* string)
{
  int len = strlen(string);
  int i;
  PT_Args args = PT_makeArgsEmpty();
  PT_Symbols symbols = PT_makeSymbolsEmpty();
  PT_Symbol symbol = PT_makeSymbolCilit(string);
  PT_Attributes attrs = PT_makeAttributesNoAttrs();
  PT_Production prod;

  for (i = len - 1; i >= 0; i--) {
    PT_Tree arg;
    PT_Symbol symbol;

    arg = PT_makeTreeChar(string[i]);
    args = PT_makeArgsMany(arg, args);

    if (string[i] >= 'A' && string[i] <= 'Z') {
      PT_CharRanges range1 =  PT_makeCharRangesSingle(              
	                         PT_makeCharRangeCharacter(string[i]));
      PT_CharRanges range2 =  PT_makeCharRangesSingle(              
	                         PT_makeCharRangeCharacter(string[i]+
							   ('a' - 'A')));
      symbol = PT_makeSymbolCharClass(PT_concatCharRanges(range1,range2));
    }
    else if (string[i] >= 'a' && string[i] <= 'z') {
      PT_CharRanges range1 =  PT_makeCharRangesSingle(              
	                         PT_makeCharRangeCharacter(string[i]));
      PT_CharRanges range2 =  PT_makeCharRangesSingle(              
	                         PT_makeCharRangeCharacter(string[i]-
							   ('a' - 'A')));
      symbol = PT_makeSymbolCharClass(PT_concatCharRanges(range2,range1));
    }
    else {
      symbol = PT_makeSymbolCharClass(
	         PT_makeCharRangesSingle(
	           PT_makeCharRangeCharacter(string[i])));
    }

    symbols = PT_makeSymbolsMany(symbol, symbols);
  }

  prod = PT_makeProductionDefault(symbols, symbol, attrs);

  return PT_makeTreeAppl(prod, args);
}