GithubHelp home page GithubHelp logo

lexected / astir Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 0.0 3.07 MB

A flexible parser generator producing output from object-oriented hierarchical context-free grammar specifications.

C++ 97.51% CMake 0.71% Shell 1.74% C 0.04%
compiler-design grammar-parser grammars language-processing parser parser-generator tokenizer

astir's People

Contributors

lexected avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

astir's Issues

Is it possible to switch tokenizers in a parser?

I'm trying to write a parser when the syntax is generally whitespace delimited tokens; however, in certain contexts, the whitespace is significant; examples such as quoted strings, but I also have instances where a block is delimited by the tokens:

action ... {
  /* start of whitespace significant block
   * where we read everything until the closing brace
   */
}

Would I perhaps need two tokenizers? One that basically looks for these special conditions, and then another that feeds these in and generates a more specific token stream?

Am trying to rewrite a parser using yacc, and it has three "parsing modes" in what appears to be a character-by-character scanning function.

Compilation Errors

First, std::exception doesn't have a constructor taking const char *; I fixed this by subclassing std::runtime_error instead, as suggested at https://en.cppreference.com/w/cpp/error/exception/exception:

The Microsoft implementation includes non-standard constructors taking strings thus allowing instances to be thrown directly with a meaningful error message. The nearest standard equivalents are std::runtime_error or std::logic_error.

Running into (added flag to treat as warning):
MyTokenizer.cpp: warning: ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say &MyTokenizer::MyTokenizer::actionRegister105 [-fpermissive]

And then, trying to use the example documentation to make my stuff run...

	TextFileStream tfs("Testfile");

	MyTokenizer::MyTokenizer myTokenizer;
	auto tokenizedStream = myTokenizer.processStreamWithIgnorance(tfs);

	auto processedStream(tokenizedStream);
	
	MyParser::MyParser myParser;
	auto parsedStream = myParser.parseStream(processedStream);

gives

main.cpp: In function ‘int main()’:
main.cpp:77:44: error: cannot convert ‘std::__cxx11::list<std::shared_ptr<MyTokenizer::MyTokenizerTerminal>, std::allocator<std::shared_ptr<MyTokenizer::MyTokenizerTerminal> > >’ to ‘ProductionStream<MyTokenizer::MyTokenizerTerminal>&’
   77 |  auto parsedStream = myParser.parseStream(processedStream);
      |                                            ^~~~~~~~~~~~~~~
      |                                            |
      |                                            std::__cxx11::list<std::shared_ptr<MyTokenizer::MyTokenizerTerminal>, std::allocator<std::shared_ptr<MyTokenizer::MyTokenizerTerminal> > >
In file included from MyParser.h:15,
                 from main.cpp:15:
Parser.h:71:133: note:   initializing argument 1 of ‘std::__cxx11::list<std::shared_ptr<_Tp> > Parser<InputStreamType, OutputProductionType>::parseStream(InputStreamType&) [with InputStreamType = ProductionStream<MyTokenizer::MyTokenizerTerminal>; OutputProductionType = Production]’
   71 | inline std::list<std::shared_ptr<OutputProductionType>> Parser<InputStreamType, OutputProductionType>::parseStream(InputStreamType& rs) {
      |                                                                                                                    ~~~~~~~~~~~~~~~~~^~

It seems like perhaps ListProductionStream template class is meant to be used somewhere, but I haven't been able to figure out what needs changing.

Building with g++ 9.3.0 and current master.

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.