jonigata / caper Goto Github PK
View Code? Open in Web Editor NEWHome Page: http://jonigata.github.io/caper/caper.html
License: Other
Home Page: http://jonigata.github.io/caper/caper.html
License: Other
Foo/...
なルールが2回現れると assertion で落ちます。
文法ファイル1
%token Number<int> LParen RParen LBracket RBracket Comma Semicolon Star;
%namespace list;
%dont_use_stl;
%recover error;
%allow_ebnf;
Document<int> : [Document] LParen Number/Comma(0) RParen
| [] Document2
;
Document2<int> : [Document2] LBracket Number/Semicolon(0) RBracket
;
出力1
File: grammar.hpp, Line 577
Expression: !exists(r)
文法ファイル2
%token Number<int> LParen RParen LBracket RBracket Comma Semicolon Star;
%namespace list;
%dont_use_stl;
%recover error;
%allow_ebnf;
Document<int> : [Document] LParen Number/Comma(0) RParen
| [Document2] LBracket Number/Semicolon(0) RBracket
;
出力2
File: grammar.hpp, Line 577
Expression: !exists(r)
grammer:
%token Exp<Expression*>;
%allow_ebnf;
ast<ASTNode*>
: [make_exp] Exp?(0)
;
c++
#include "../prob3.hpp"
class ASTNode {
};
class Expression : public ASTNode {
};
class SemanticAction {
public:
void syntax_error()
{
}
void stack_overflow()
{
}
template<class T>
void upcast(ASTNode*& x, T* y)
{
x = y;
}
template<class T>
void downcast(T*& x, ASTNode* y)
{
x = static_cast<T*>(y);
}
template<class S>
ASTNode* make_exp(S& x)
{
Expression* exp = x ? *x : nullptr;
return nullptr;
}
};
void test()
{
SemanticAction sa;
caper_parser::Parser<ASTNode*, SemanticAction> parser(sa);
}
output:
error C2440: 'return' : 'ASTNode *' から 'Expression *' に変換できません。
grammer:
%token A B C;
%allow_ebnf;
declaration<int>
: [make_a] attribute* A
| [make_b] attribute* B
;
attribute<int>
: [make_c] C
;
output:
File: grammar.hpp, Line 577
Expression: !exists(r)
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
できればエラー行などを表示してほしい。
grammer:
%token Token;
module<>
: [make_module] decl(0)
;
decl<>
: [make_decl] Token
;
output:
File: caper_tgt.cpp, Line 221
Expression: type.name != ""
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
grammer:
%token Token;
module<>
: [make_module] Token
;
c++
#include "../prob1_2.hpp"
class Module {
};
class SemanticAction {
public:
void syntax_error()
{
}
void stack_overflow()
{
}
template<class T>
void upcast(Module*& x, T* y)
{
x = y;
}
template<class T>
void downcast(T*& x, Module* y)
{
x = static_cast<T*>(y);
}
Module* make_module()
{
return nullptr;
}
};
void test()
{
SemanticAction sa;
caper_parser::Parser<Module*, SemanticAction> parser(sa);
}
output:
error C2065: 'r' : 定義されていない識別子です。
error C2065: 'r' : 定義されていない識別子です。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.