From 392538c8303a9d82afa6bdb02219a3506c7b942b Mon Sep 17 00:00:00 2001
From: Johann Hemmann <johann.hemmann@code.berlin>
Date: Tue, 30 Jan 2024 16:05:28 +0100
Subject: [PATCH] Add edition to parser struct

---
 crates/parser/src/lib.rs    |  7 ++++---
 crates/parser/src/parser.rs | 18 ++++++++++++++++--
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 86c771c0008..abce8e2f482 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -45,6 +45,7 @@ pub use crate::{
     input::Input,
     lexed_str::LexedStr,
     output::{Output, Step},
+    parser::Edition,
     shortcuts::StrStep,
     syntax_kind::SyntaxKind,
 };
@@ -98,7 +99,7 @@ impl TopEntryPoint {
             TopEntryPoint::MetaItem => grammar::entry::top::meta_item,
             TopEntryPoint::MacroEagerInput => grammar::entry::top::eager_macro_input,
         };
-        let mut p = parser::Parser::new(input);
+        let mut p = parser::Parser::new(input, Edition::Edition2021);
         entry_point(&mut p);
         let events = p.finish();
         let res = event::process(events);
@@ -163,7 +164,7 @@ impl PrefixEntryPoint {
             PrefixEntryPoint::Item => grammar::entry::prefix::item,
             PrefixEntryPoint::MetaItem => grammar::entry::prefix::meta_item,
         };
-        let mut p = parser::Parser::new(input);
+        let mut p = parser::Parser::new(input, Edition::Edition2021);
         entry_point(&mut p);
         let events = p.finish();
         event::process(events)
@@ -189,7 +190,7 @@ impl Reparser {
     /// sequence.
     pub fn parse(self, tokens: &Input) -> Output {
         let Reparser(r) = self;
-        let mut p = parser::Parser::new(tokens);
+        let mut p = parser::Parser::new(tokens, Edition::Edition2021);
         r(&mut p);
         let events = p.finish();
         event::process(events)
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index 051461243af..df53e13f6ef 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -26,13 +26,27 @@ pub(crate) struct Parser<'t> {
     pos: usize,
     events: Vec<Event>,
     steps: Cell<u32>,
+    edition: Edition,
+}
+
+#[non_exhaustive]
+pub enum Edition {
+    Edition2015,
+    Edition2018,
+    Edition2021,
 }
 
 static PARSER_STEP_LIMIT: Limit = Limit::new(15_000_000);
 
 impl<'t> Parser<'t> {
-    pub(super) fn new(inp: &'t Input) -> Parser<'t> {
-        Parser { inp, pos: 0, events: Vec::new(), steps: Cell::new(0) }
+    pub(super) fn new(inp: &'t Input, edition: Edition) -> Parser<'t> {
+        Parser {
+            inp,
+            pos: 0,
+            events: Vec::new(),
+            steps: Cell::new(0),
+            edition,
+        }
     }
 
     pub(crate) fn finish(self) -> Vec<Event> {