Skip to content

Commit

Permalink
parse out some more complicated rebase scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Dec 24, 2021
1 parent 916e5ca commit f0cb000
Show file tree
Hide file tree
Showing 6 changed files with 2,372 additions and 1,997 deletions.
46 changes: 29 additions & 17 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ module.exports = grammar({
"You",
"are",
"currently",
repeat(/\S+/),
"rebasing",
"branch",
"'",
Expand All @@ -109,6 +110,34 @@ module.exports = grammar({
optional("#")
),

_rebase_header: ($) =>
choice(
seq(
"Last",
/commands?/,
"done",
"(",
/\d+/,
/commands?/,
"done",
")",
":"
),
seq(
"Next",
/commands?/,
"to",
"do",
"(",
/\d+/,
"remaining",
/commands?/,
")",
":"
),
seq("No", "commands", "remaining", ".")
),

summary: ($) =>
choice(
seq(
Expand All @@ -125,23 +154,6 @@ module.exports = grammar({
)
),

_rebase_header: ($) =>
choice(
seq("Last", "command", "done", "(", /\d+/, "command", "done", ")", ":"),
seq(
"Next",
"commands",
"to",
"do",
"(",
/\d+/,
"remaining",
"commands",
")",
":"
)
),

_change_header: ($) =>
choice(
seq("Changes", "to", "be", "committed", ":"),
Expand Down
210 changes: 119 additions & 91 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,13 @@
"type": "STRING",
"value": "currently"
},
{
"type": "REPEAT",
"content": {
"type": "PATTERN",
"value": "\\S+"
}
},
{
"type": "STRING",
"value": "rebasing"
Expand Down Expand Up @@ -433,6 +440,118 @@
}
]
},
"_rebase_header": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Last"
},
{
"type": "PATTERN",
"value": "commands?"
},
{
"type": "STRING",
"value": "done"
},
{
"type": "STRING",
"value": "("
},
{
"type": "PATTERN",
"value": "\\d+"
},
{
"type": "PATTERN",
"value": "commands?"
},
{
"type": "STRING",
"value": "done"
},
{
"type": "STRING",
"value": ")"
},
{
"type": "STRING",
"value": ":"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Next"
},
{
"type": "PATTERN",
"value": "commands?"
},
{
"type": "STRING",
"value": "to"
},
{
"type": "STRING",
"value": "do"
},
{
"type": "STRING",
"value": "("
},
{
"type": "PATTERN",
"value": "\\d+"
},
{
"type": "STRING",
"value": "remaining"
},
{
"type": "PATTERN",
"value": "commands?"
},
{
"type": "STRING",
"value": ")"
},
{
"type": "STRING",
"value": ":"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "No"
},
{
"type": "STRING",
"value": "commands"
},
{
"type": "STRING",
"value": "remaining"
},
{
"type": "STRING",
"value": "."
}
]
}
]
},
"summary": {
"type": "CHOICE",
"members": [
Expand Down Expand Up @@ -533,97 +652,6 @@
}
]
},
"_rebase_header": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Last"
},
{
"type": "STRING",
"value": "command"
},
{
"type": "STRING",
"value": "done"
},
{
"type": "STRING",
"value": "("
},
{
"type": "PATTERN",
"value": "\\d+"
},
{
"type": "STRING",
"value": "command"
},
{
"type": "STRING",
"value": "done"
},
{
"type": "STRING",
"value": ")"
},
{
"type": "STRING",
"value": ":"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Next"
},
{
"type": "STRING",
"value": "commands"
},
{
"type": "STRING",
"value": "to"
},
{
"type": "STRING",
"value": "do"
},
{
"type": "STRING",
"value": "("
},
{
"type": "PATTERN",
"value": "\\d+"
},
{
"type": "STRING",
"value": "remaining"
},
{
"type": "STRING",
"value": "commands"
},
{
"type": "STRING",
"value": ")"
},
{
"type": "STRING",
"value": ":"
}
]
}
]
},
"_change_header": {
"type": "CHOICE",
"members": [
Expand Down
12 changes: 6 additions & 6 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"type": "Next",
"named": false
},
{
"type": "No",
"named": false
},
{
"type": "On",
"named": false
Expand Down Expand Up @@ -257,21 +261,17 @@
"type": "by",
"named": false
},
{
"type": "command",
"named": false
},
{
"type": "commands",
"named": false
},
{
"type": "commit",
"named": true
"named": false
},
{
"type": "commit",
"named": false
"named": true
},
{
"type": "committed",
Expand Down
Loading

0 comments on commit f0cb000

Please sign in to comment.