Exemple #1
0
bool Web::parseXML(string xml)
{
	int iter = 0;
	vector<string> lines;
	string rootName;

	splitStr(xml, '\n', lines);

	while(myUtil.match(lines[iter], IGNORE_TAG))
	{
		iter++;
	}

	rootName = myUtil.getMatch(lines[iter], OPEN_TAG_NAME, 1);

	if(rootName == "concepts")
	{
		return parseConcepts(lines);
	}
	else if(rootName == "words")
	{
		return parseWords(lines);
	}
	else
	{
		fprintf(outFile, "Invalid root name in xml file\n");
		return false;
	}
}
Exemple #2
0
static ASTPtr parseSpecifiedLengthContent(const char** fptr, const char*** wordSourcesPtr, const LengthFunc** lengthFuncsPtr) {
  assert(**fptr == '\'' || std::isdigit(**fptr) || **fptr == '#');
  ASTPtr slc;
  if (**fptr == '\'') {
    slc = parseStringLiteral(fptr);
  } else if (**fptr == '#') {
    slc = parseRepeatedCharFL(fptr, lengthFuncsPtr);
  } else {
    const char* f_at = *fptr;
    LiteralLength length = parseLiteralLength(fptr);
    if (**fptr == '\'') {
      slc.reset(new RepeatedCharLL(f_at, length, parseCharLiteral(fptr)));
    } else if (**fptr == '[') {
      Block* block = new Block(f_at, length);
      slc.reset(block);
      ++*fptr;
      parseWhitespaces(fptr); // [ is a token
      while (**fptr != ']') {
        if (**fptr == '\'' || std::isdigit(**fptr) || **fptr == '#') {
          block->addChild(parseSpecifiedLengthContent(fptr, wordSourcesPtr, lengthFuncsPtr));
        } else if (**fptr == '{') {
          block->addWords(parseWords(fptr, wordSourcesPtr));
        } else {
          throw DSLException(*fptr, "Expected ', digit, or # to begin specified-length content, "
            "or { to begin greedy-length content.");
        }
      }
      ++*fptr;
      parseWhitespaces(fptr); // ] is a token
      if (**fptr == '^') {
        parseTopOrBottomFiller(fptr, &block->topFillers, true);
        if (**fptr == 'v') {
          parseTopOrBottomFiller(fptr, &block->bottomFillers, false);
        }
      } else if (**fptr == 'v') {
        parseTopOrBottomFiller(fptr, &block->bottomFillers, false);
        if (**fptr == '^') {
          parseTopOrBottomFiller(fptr, &block->topFillers, true);
        }
      }
    } else {
      throw DSLException(*fptr, "Expected ' or [ after length specifier.");
    }
  }
  return slc;
}
Exemple #3
0
void map(char *fName) {
    // implement the map operation here ...
    parseWords(fName);
}
 void DirectionReader::parseDirectionType( const core::DirectionType& directionType )
 {
     switch ( directionType.getChoice() )
     {
         case core::DirectionType::Choice::rehearsal:
         {
             parseRehearsal( directionType );
             break;
         }
         case core::DirectionType::Choice::segno:
         {
             parseSegno( directionType );
             break;
         }
         case core::DirectionType::Choice::words:
         {
             parseWords( directionType );
             break;
         }
         case core::DirectionType::Choice::coda:
         {
             parseCoda( directionType );
             break;
         }
         case core::DirectionType::Choice::wedge:
         {
             parseWedge( directionType );
             break;
         }
         case core::DirectionType::Choice::dynamics:
         {
             parseDynamics( directionType );
             break;
         }
         case core::DirectionType::Choice::dashes:
         {
             parseDashes( directionType );
             break;
         }
         case core::DirectionType::Choice::bracket:
         {
             parseBracket( directionType );
             break;
         }
         case core::DirectionType::Choice::pedal:
         {
             parsePedal( directionType );
             break;
         }
         case core::DirectionType::Choice::metronome:
         {
             parseMetronome( directionType );
             break;
         }
         case core::DirectionType::Choice::octaveShift:
         {
             parseOctaveShift( directionType );
             break;
         }
         case core::DirectionType::Choice::harpPedals:
         {
             parseHarpPedals( directionType );
             break;
         }
         case core::DirectionType::Choice::damp:
         {
             parseDamp( directionType );
             break;
         }
         case core::DirectionType::Choice::dampAll:
         {
             parseRehearsal( directionType );
             break;
         }
         case core::DirectionType::Choice::eyeglasses:
         {
             parseEyeglasses( directionType );
             break;
         }
         case core::DirectionType::Choice::stringMute:
         {
             parseStringMute( directionType );
             break;
         }
         case core::DirectionType::Choice::scordatura:
         {
             parseScordatura( directionType );
             break;
         }
         case core::DirectionType::Choice::image:
         {
             parseImage( directionType );
             break;
         }
         case core::DirectionType::Choice::principalVoice:
         {
             parsePrincipalVoice( directionType );
             break;
         }
         case core::DirectionType::Choice::accordionRegistration:
         {
             parseAccordionRegistration( directionType );
             break;
         }
         case core::DirectionType::Choice::percussion:
         {
             parsePercussion( directionType );
             break;
         }
         case core::DirectionType::Choice::otherDirection:
         {
             parseOtherDirection( directionType );
             break;
         }
         default: break;
     }
 }
Exemple #5
0
static int parseDir(MaHttp *http, cchar *key, char *value, MaConfigState *state)
{
    MaStage     *handler;
    Dir         *dir;
    
    char    *name, *extensions, *option, *nextTok, *junk;

    handler = maLookupStage(http, "dirHandler");
    dir = handler->stageData;
    mprAssert(dir);
    
    if (mprStrcmpAnyCase(key, "AddIcon") == 0) {
        /*  AddIcon file ext ext ext */
        /*  Not yet supported */
        name = mprStrTok(value, " \t", &extensions);
        parseWords(dir->extList, extensions);
        return 1;

    } else if (mprStrcmpAnyCase(key, "DefaultIcon") == 0) {
        /*  DefaultIcon file */
        /*  Not yet supported */
        dir->defaultIcon = mprStrTok(value, " \t", &junk);
        return 1;

    } else if (mprStrcmpAnyCase(key, "IndexOrder") == 0) {
        /*  IndexOrder ascending|descending name|date|size */
        mprFree(dir->sortField);
        dir->sortField = 0;
        option = mprStrTok(value, " \t", &dir->sortField);
        if (mprStrcmpAnyCase(option, "ascending") == 0) {
            dir->sortOrder = 1;
        } else {
            dir->sortOrder = -1;
        }
        if (dir->sortField) {
            dir->sortField = mprStrdup(dir, dir->sortField);
        }
        return 1;

    } else if (mprStrcmpAnyCase(key, "IndexIgnore") == 0) {
        /*  IndexIgnore pat ... */
        /*  Not yet supported */
        parseWords(dir->ignoreList, value);
        return 1;

    } else if (mprStrcmpAnyCase(key, "IndexOptions") == 0) {
        /*  IndexOptions FancyIndexing|FoldersFirst ... (set of options) */
        option = mprStrTok(value, " \t", &nextTok);
        while (option) {
            if (mprStrcmpAnyCase(option, "FancyIndexing") == 0) {
                dir->fancyIndexing = 1;
            } else if (mprStrcmpAnyCase(option, "HTMLTable") == 0) {
                dir->fancyIndexing = 2;
            } else if (mprStrcmpAnyCase(option, "FoldersFirst") == 0) {
                dir->foldersFirst = 1;
            }
            option = mprStrTok(nextTok, " \t", &nextTok);
        }
        return 1;

    } else if (mprStrcmpAnyCase(key, "Options") == 0) {
        /*  Options Indexes */
        option = mprStrTok(value, " \t", &nextTok);
        while (option) {
            if (mprStrcmpAnyCase(option, "Indexes") == 0) {
                dir->enabled = 1;
            }
            option = mprStrTok(nextTok, " \t", &nextTok);
        }
        return 1;
    }
    return 0;
}
Exemple #6
0
	BlockParser(QTextEngine *e, TextBlock *b, QFixed minResizeWidth, int32 blockFrom, const QString &str)
		: block(b), eng(e), str(str) {
		parseWords(minResizeWidth, blockFrom);
	}