Skip to content

Commit

Permalink
✨ feat(Gen): 现在结构体中的字段可以被赋值或引用
Browse files Browse the repository at this point in the history
  • Loading branch information
wangziwenhk committed Aug 9, 2024
1 parent 56a14ed commit dd08f15
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 96 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '27 21 * * *'

jobs:
build:
Expand Down Expand Up @@ -52,24 +50,3 @@ jobs:
run: |
cd build
make
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly-${{ github.run_id }} # 使用运行ID作为唯一标识
release_name: "Nightly Build - ${{ github.run_id }}"
draft: false
prerelease: true

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/Riddle_Language.exe
asset_name: Riddle_Language.exe
asset_content_type: application/octet-stream
6 changes: 3 additions & 3 deletions RiddleParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ classBody

// 这一块就是使用
exprPtr
: funcName=id LeftBracket args=argsExpr RightBracket #funcExpr
| id #objectExpr
| exprPtr Dot exprPtr #blendExpr
: funcName=Identifier LeftBracket args=argsExpr RightBracket #funcExpr
| Identifier #objectExpr
| parent=exprPtr Dot child=exprPtr #blendExpr
;
expression
: Less type=typeName Greater LeftBracket value=exprPtr RightBracket #castExpr
Expand Down
43 changes: 22 additions & 21 deletions parser/RiddleParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ void riddleparserParserInitialize() {
27,1,0,0,0,205,206,5,11,0,0,206,207,3,36,18,0,207,208,5,24,0,0,208,209,
3,30,15,0,209,210,5,25,0,0,210,29,1,0,0,0,211,213,3,2,1,0,212,211,1,0,
0,0,213,216,1,0,0,0,214,212,1,0,0,0,214,215,1,0,0,0,215,31,1,0,0,0,216,
214,1,0,0,0,217,218,6,16,-1,0,218,219,3,36,18,0,219,220,5,20,0,0,220,
221,3,12,6,0,221,222,5,21,0,0,222,225,1,0,0,0,223,225,3,36,18,0,224,217,
1,0,0,0,224,223,1,0,0,0,225,231,1,0,0,0,226,227,10,1,0,0,227,228,5,45,
0,0,228,230,3,32,16,2,229,226,1,0,0,0,230,233,1,0,0,0,231,229,1,0,0,0,
231,232,1,0,0,0,232,33,1,0,0,0,233,231,1,0,0,0,234,235,6,17,-1,0,235,
236,5,32,0,0,236,237,3,52,26,0,237,238,5,31,0,0,238,239,5,20,0,0,239,
240,3,32,16,0,240,241,5,21,0,0,241,335,1,0,0,0,242,243,5,20,0,0,243,244,
3,34,17,0,244,245,5,21,0,0,245,335,1,0,0,0,246,247,5,41,0,0,247,335,3,
34,17,43,248,249,5,36,0,0,249,335,3,34,17,42,250,251,5,37,0,0,251,335,
3,34,17,41,252,253,5,36,0,0,253,254,5,36,0,0,254,335,3,32,16,0,255,256,
214,1,0,0,0,217,218,6,16,-1,0,218,219,5,49,0,0,219,220,5,20,0,0,220,221,
3,12,6,0,221,222,5,21,0,0,222,225,1,0,0,0,223,225,5,49,0,0,224,217,1,
0,0,0,224,223,1,0,0,0,225,231,1,0,0,0,226,227,10,1,0,0,227,228,5,45,0,
0,228,230,3,32,16,2,229,226,1,0,0,0,230,233,1,0,0,0,231,229,1,0,0,0,231,
232,1,0,0,0,232,33,1,0,0,0,233,231,1,0,0,0,234,235,6,17,-1,0,235,236,
5,32,0,0,236,237,3,52,26,0,237,238,5,31,0,0,238,239,5,20,0,0,239,240,
3,32,16,0,240,241,5,21,0,0,241,335,1,0,0,0,242,243,5,20,0,0,243,244,3,
34,17,0,244,245,5,21,0,0,245,335,1,0,0,0,246,247,5,41,0,0,247,335,3,34,
17,43,248,249,5,36,0,0,249,335,3,34,17,42,250,251,5,37,0,0,251,335,3,
34,17,41,252,253,5,36,0,0,253,254,5,36,0,0,254,335,3,32,16,0,255,256,
3,32,16,0,256,257,5,36,0,0,257,258,5,36,0,0,258,335,1,0,0,0,259,260,5,
37,0,0,260,261,5,37,0,0,261,335,3,32,16,0,262,263,3,32,16,0,263,264,5,
37,0,0,264,265,5,37,0,0,265,335,1,0,0,0,266,335,3,32,16,0,267,268,3,32,
Expand Down Expand Up @@ -2016,8 +2016,8 @@ tree::TerminalNode* RiddleParser::FuncExprContext::RightBracket() {
return getToken(RiddleParser::RightBracket, 0);
}

RiddleParser::IdContext* RiddleParser::FuncExprContext::id() {
return getRuleContext<RiddleParser::IdContext>(0);
tree::TerminalNode* RiddleParser::FuncExprContext::Identifier() {
return getToken(RiddleParser::Identifier, 0);
}

RiddleParser::ArgsExprContext* RiddleParser::FuncExprContext::argsExpr() {
Expand Down Expand Up @@ -2045,8 +2045,8 @@ std::any RiddleParser::FuncExprContext::accept(tree::ParseTreeVisitor *visitor)
}
//----------------- ObjectExprContext ------------------------------------------------------------------

RiddleParser::IdContext* RiddleParser::ObjectExprContext::id() {
return getRuleContext<RiddleParser::IdContext>(0);
tree::TerminalNode* RiddleParser::ObjectExprContext::Identifier() {
return getToken(RiddleParser::Identifier, 0);
}

RiddleParser::ObjectExprContext::ObjectExprContext(ExprPtrContext *ctx) { copyFrom(ctx); }
Expand All @@ -2070,6 +2070,10 @@ std::any RiddleParser::ObjectExprContext::accept(tree::ParseTreeVisitor *visitor
}
//----------------- BlendExprContext ------------------------------------------------------------------

tree::TerminalNode* RiddleParser::BlendExprContext::Dot() {
return getToken(RiddleParser::Dot, 0);
}

std::vector<RiddleParser::ExprPtrContext *> RiddleParser::BlendExprContext::exprPtr() {
return getRuleContexts<RiddleParser::ExprPtrContext>();
}
Expand All @@ -2078,10 +2082,6 @@ RiddleParser::ExprPtrContext* RiddleParser::BlendExprContext::exprPtr(size_t i)
return getRuleContext<RiddleParser::ExprPtrContext>(i);
}

tree::TerminalNode* RiddleParser::BlendExprContext::Dot() {
return getToken(RiddleParser::Dot, 0);
}

RiddleParser::BlendExprContext::BlendExprContext(ExprPtrContext *ctx) { copyFrom(ctx); }

void RiddleParser::BlendExprContext::enterRule(tree::ParseTreeListener *listener) {
Expand Down Expand Up @@ -2136,7 +2136,7 @@ RiddleParser::ExprPtrContext* RiddleParser::exprPtr(int precedence) {
previousContext = _localctx;

setState(218);
antlrcpp::downCast<FuncExprContext *>(_localctx)->funcName = id();
antlrcpp::downCast<FuncExprContext *>(_localctx)->funcName = match(RiddleParser::Identifier);
setState(219);
match(RiddleParser::LeftBracket);
setState(220);
Expand All @@ -2151,7 +2151,7 @@ RiddleParser::ExprPtrContext* RiddleParser::exprPtr(int precedence) {
_ctx = _localctx;
previousContext = _localctx;
setState(223);
id();
match(RiddleParser::Identifier);
break;
}

Expand All @@ -2169,14 +2169,15 @@ RiddleParser::ExprPtrContext* RiddleParser::exprPtr(int precedence) {
previousContext = _localctx;
auto newContext = _tracker.createInstance<BlendExprContext>(_tracker.createInstance<ExprPtrContext>(parentContext, parentState));
_localctx = newContext;
newContext->parent = previousContext;
pushNewRecursionContext(newContext, startState, RuleExprPtr);
setState(226);

if (!(precpred(_ctx, 1))) throw FailedPredicateException(this, "precpred(_ctx, 1)");
setState(227);
match(RiddleParser::Dot);
setState(228);
exprPtr(2);
antlrcpp::downCast<BlendExprContext *>(_localctx)->child = exprPtr(2);
}
setState(233);
_errHandler->sync(this);
Expand Down
10 changes: 6 additions & 4 deletions parser/RiddleParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,11 @@ class RiddleParser : public antlr4::Parser {
public:
FuncExprContext(ExprPtrContext *ctx);

RiddleParser::IdContext *funcName = nullptr;
antlr4::Token *funcName = nullptr;
RiddleParser::ArgsExprContext *args = nullptr;
antlr4::tree::TerminalNode *LeftBracket();
antlr4::tree::TerminalNode *RightBracket();
IdContext *id();
antlr4::tree::TerminalNode *Identifier();
ArgsExprContext *argsExpr();
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;
Expand All @@ -444,7 +444,7 @@ class RiddleParser : public antlr4::Parser {
public:
ObjectExprContext(ExprPtrContext *ctx);

IdContext *id();
antlr4::tree::TerminalNode *Identifier();
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;

Expand All @@ -455,9 +455,11 @@ class RiddleParser : public antlr4::Parser {
public:
BlendExprContext(ExprPtrContext *ctx);

RiddleParser::ExprPtrContext *parent = nullptr;
RiddleParser::ExprPtrContext *child = nullptr;
antlr4::tree::TerminalNode *Dot();
std::vector<ExprPtrContext *> exprPtr();
ExprPtrContext* exprPtr(size_t i);
antlr4::tree::TerminalNode *Dot();
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;

Expand Down
Loading

0 comments on commit dd08f15

Please sign in to comment.