Giter Site home page Giter Site logo

onegin's Introduction

Onegin

This is a second task in compiler course. The task is simple you need to sort big russian text, for example Evgeniy Onegin by Alexander Pushkin. Then you have to write the text in an output file. After that you have to generate new rhymes wich bysed on Evgeniy Onegin text and also dump in a file. At the end you write basic text in a file. To solve the problem was developed a struct OneginText wich based on struct Text:

struct OneginText
{
    Text text;
};

Onegin Text supports ctor/dtor functions and it also supports 4 function to work with text.

/*!
 *  \brief Sorts OneginText tokens.
 *  \param cmp:  may be NULL if you want to use default comparator based on strcmp or 
 *               you can write your own custom comparator.
 */
ONEGIN_TEXT_ERROR onegin_text_sort (OneginText *_this, token_comparator_t cmp);
/*!
 *  \brief Prints rhymes using OneginText in fout.
 *  \param cmp:  may be NULL if you want to use default reverse Token comparator or 
 *               you can write your own custom reverse comparator.
 *  \param title: framed title befor rhyme dump.
 *  \note  After call OneginText will be sorted by reverse comporator, because the rhyme printing alorithm need it. 
 */
ONEGIN_TEXT_ERROR onegin_text_rhymes_dump (OneginText *_this, FILE *fout, const char *title, token_comparator_t cmp);

/*! \brief Dumping OneginText tekens under the framed title. */
ONEGIN_TEXT_ERROR onegin_text_dump (OneginText *_this, FILE *fout, const char *title);

ONEGIN_TEXT_ERROR onegin_text_raw_dump (OneginText *_this, FILE *fout, const char *title);

The text struct is simple and doesn't support many functions because it basic text working class and if you want to expand functionality of the struct you can follow the OneginText example.

struct Text
{
    Buffer        buff;
    vector_Token  tokens;
    bool          null_terminated;
};

/*! \brief Construct Text object. Reading all symbols from pfile. */
TEXT_ERRORS text_ctor_by_file (Text *_this, FILE *pfile);

/*! 
 * \brief Tokenizing the text of previously constructed Text object. 
 * \param delim: Text deim symbols.
 * \param null_retm: cahnging last token symbols to '\0' if it's true
 * \param tok_verify: Token verificator. Must return true for valid tokens, invalid tokens will be ignored. 
 */

TEXT_ERRORS text_tokenize (Text *_this, const char *delim, 
                           bool null_term, token_verifier_t tok_verify);
                           
/*! \brief Distructs previously constructed Text object. */
TEXT_ERRORS text_dtor (Text *_this);

onegin's People

Contributors

elmaxxo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.