foonathan / lexy

C++ parsing DSL
https://lexy.foonathan.net
Boost Software License 1.0
1.01k stars 68 forks source link

lexy doesn't compile in Visual Studio 2022 #51

Closed Derailedzack closed 2 years ago

Derailedzack commented 2 years ago
Build started...
1>------ Build started: Project: LangParserTest, Configuration: Debug x64 ------
1>LangParser.cpp
1>The contents of <bit> are available only with C++20 or later.
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(24,69): error C2938: 'lexy::parser_for' : Failed to specialize alias template
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(24): message : see reference to alias template instantiation 'lexy::parser_for<lexyd::_must_dsl<Branch>,lexyd::token_base<lexyd::_lit<CharT,102,117,110,99>,lexyd::branch_base>::p<NextParser>>' being compiled
1>        with
1>        [
1>            Branch=lexyd::ascii::_alpha,
1>            CharT=char
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(33): message : see reference to class template instantiation 'lexyd::_seq_impl<R,S>' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(33): message : see reference to alias template instantiation 'lexy::parser_for<lexyd::_seq_impl<R,S>,NextParser>' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(39): message : see reference to class template instantiation 'lexyd::_seq<R,S>' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\LangParserTest\LangParser.h(12): message : see reference to function template instantiation 'auto lexyd::operator +<lexyd::_must_dsl<Branch>,lexyd::_lit<CharT,102,117,110,99>>(R,S)' being compiled
1>        with
1>        [
1>            Branch=lexyd::ascii::_alpha,
1>            CharT=char,
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(24,49): error C2938: 'lexy::parser_for' : Failed to specialize alias template
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(24): message : see reference to alias template instantiation 'lexy::parser_for<lexyd::_must_dsl<Branch>,lexyd::token_base<lexyd::_lit<CharT,102,117,110,99>,lexyd::branch_base>::p<NextParser>>' being compiled
1>        with
1>        [
1>            Branch=lexyd::ascii::_alpha,
1>            CharT=char
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\base.hpp(88): message : see reference to alias template instantiation 'lexyd::_seq_impl<R,S>::p<NextParser>' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(33,49): error C2938: 'lexy::parser_for' : Failed to specialize alias template
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\identifier.hpp(239,25): error C2607: static assertion failed
1>C:\Users\admin\source\repos\LangParserTest\LangParserTest\LangParser.h(14): message : see reference to function template instantiation 'auto lexyd::identifier<lexyd::_seq<R,S>>(CharClass)' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>,
1>            CharClass=lexyd::_seq<lexyd::_must_dsl<lexyd::ascii::_alpha>,lexyd::_lit<char,102,117,110,99>>
1>        ]
1>Main.cpp
1>The contents of <bit> are available only with C++20 or later.
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(24,69): error C2938: 'lexy::parser_for' : Failed to specialize alias template
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(24): message : see reference to alias template instantiation 'lexy::parser_for<lexyd::_must_dsl<Branch>,lexyd::token_base<lexyd::_lit<CharT,102,117,110,99>,lexyd::branch_base>::p<NextParser>>' being compiled
1>        with
1>        [
1>            Branch=lexyd::ascii::_alpha,
1>            CharT=char
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(33): message : see reference to class template instantiation 'lexyd::_seq_impl<R,S>' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(33): message : see reference to alias template instantiation 'lexy::parser_for<lexyd::_seq_impl<R,S>,NextParser>' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(39): message : see reference to class template instantiation 'lexyd::_seq<R,S>' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\LangParserTest\LangParser.h(12): message : see reference to function template instantiation 'auto lexyd::operator +<lexyd::_must_dsl<Branch>,lexyd::_lit<CharT,102,117,110,99>>(R,S)' being compiled
1>        with
1>        [
1>            Branch=lexyd::ascii::_alpha,
1>            CharT=char,
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(24,49): error C2938: 'lexy::parser_for' : Failed to specialize alias template
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(24): message : see reference to alias template instantiation 'lexy::parser_for<lexyd::_must_dsl<Branch>,lexyd::token_base<lexyd::_lit<CharT,102,117,110,99>,lexyd::branch_base>::p<NextParser>>' being compiled
1>        with
1>        [
1>            Branch=lexyd::ascii::_alpha,
1>            CharT=char
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\base.hpp(88): message : see reference to alias template instantiation 'lexyd::_seq_impl<R,S>::p<NextParser>' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>
1>        ]
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\sequence.hpp(33,49): error C2938: 'lexy::parser_for' : Failed to specialize alias template
1>C:\Users\admin\source\repos\LangParserTest\deps\include\lexy\dsl\identifier.hpp(239,25): error C2607: static assertion failed
1>C:\Users\admin\source\repos\LangParserTest\LangParserTest\LangParser.h(14): message : see reference to function template instantiation 'auto lexyd::identifier<lexyd::_seq<R,S>>(CharClass)' being compiled
1>        with
1>        [
1>            R=lexyd::_must_dsl<lexyd::ascii::_alpha>,
1>            S=lexyd::_lit<char,102,117,110,99>,
1>            CharClass=lexyd::_seq<lexyd::_must_dsl<lexyd::ascii::_alpha>,lexyd::_lit<char,102,117,110,99>>
1>        ]
1>Generating Code...
1>Done building project "LangParserTest.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
#include"LangParser.h"
int main() {
    LangParser* langparser = new LangParser();
    langparser->ParseStr("#func", "!#");
}
#pragma once
//TODO:Convert to lexy
#include<string>
#include<lexy/dsl.hpp>
#include<lexy/callback.hpp>

//#include<pegtl.hpp>
class LangParser
{
private:
    static constexpr auto grammmer = [] {
        auto funcdecl = lexy::dsl::must(lexy::dsl::ascii::alpha) + LEXY_LIT("func");

        return lexy::dsl::identifier(funcdecl);
    }();
    static constexpr auto val = lexy::as_string<std::string>;
    /*struct FunDecl : tao::pegtl::one<'func', 'fun'> {};
    struct FunReturnType : tao::pegtl::alpha {};
    struct FuncImpl : tao::pegtl::must<FunReturnType>, tao::pegtl::opt<FunDecl> {};
    struct Grammer: tao::pegtl::must<tao::pegtl::must<tao::pegtl::shebang>,FunDecl>{};*/
public:

    LangParser();
    void ParseStr(std::string str_dat, std::string str_in);
    void ParseFile(std::string path);
};
#include "LangParser.h"
#include <iostream>

LangParser::LangParser()
{

}

void LangParser::ParseStr(std::string str_dat, std::string str_in)
{
    /*
    try {
        tao::pegtl::string_input str_input(str_dat, str_in);
        tao::pegtl::parse<Grammer>(str_input);
            std::cout << str_input.begin();

    }
    catch (tao::pegtl::parse_error e) {
        std::cout << e.what() << std::endl;
    }
    */

}

void LangParser::ParseFile(std::string path)
{
    /*
    tao::pegtl::file_input file_input(path);
    */
}
foonathan commented 2 years ago

The error message isn't great, but it's not a compiler bug:

I don't think your PEGTL grammar works, but this is code that parses a function declaration, maybe that helps: https://lexy.foonathan.net/playground/?id=dGGWMn37z&mode=tree