Skip to content

Commit

Permalink
Add support for Python 3.13.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Oct 12, 2024
1 parent c79f8cc commit 633aca2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,8 @@ public static int getGrammarVersionFromStr(String grammarVersion) {
return GRAMMAR_PYTHON_VERSION_3_11;
case "3.12":
return GRAMMAR_PYTHON_VERSION_3_12;
case "3.13":
return GRAMMAR_PYTHON_VERSION_3_13;
/*[[[end]]]*/
// @formatter:on
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public interface IGrammarVersionProvider {
public static final int GRAMMAR_PYTHON_VERSION_3_10 = 104;
public static final int GRAMMAR_PYTHON_VERSION_3_11 = 105;
public static final int GRAMMAR_PYTHON_VERSION_3_12 = 106;
public static final int LATEST_GRAMMAR_PY3_VERSION = GRAMMAR_PYTHON_VERSION_3_12;
public static final int LATEST_GRAMMAR_PY2_VERSION = GRAMMAR_PYTHON_VERSION_3_12;
public static final int GRAMMAR_PYTHON_VERSION_3_13 = 107;
public static final int LATEST_GRAMMAR_PY3_VERSION = GRAMMAR_PYTHON_VERSION_3_13;
public static final int LATEST_GRAMMAR_PY2_VERSION = GRAMMAR_PYTHON_VERSION_3_13;
/*[[[end]]]*/

/**
Expand Down Expand Up @@ -111,6 +112,7 @@ public static List<Integer> createList() {
grammarVersions.add(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_10);
grammarVersions.add(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_11);
grammarVersions.add(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_12);
grammarVersions.add(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_13);
/*[[[end]]]*/
return Collections.unmodifiableList(grammarVersions);
}
Expand All @@ -134,6 +136,7 @@ public static List<String> createStr() {
grammarVersions.add("3.10");
grammarVersions.add("3.11");
grammarVersions.add("3.12");
grammarVersions.add("3.13");
/*[[[end]]]*/
return Collections.unmodifiableList(grammarVersions);
}
Expand All @@ -158,6 +161,7 @@ public static Map<Integer, String> createDict() {
ret.put(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_10, "3.10");
ret.put(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_11, "3.11");
ret.put(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_12, "3.12");
ret.put(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_13, "3.13");
/*[[[end]]]*/
return Collections.unmodifiableMap(ret);
}
Expand All @@ -182,6 +186,7 @@ public static Map<String, Integer> createStrToInt() {
ret.put("3.10", IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_10);
ret.put("3.11", IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_11);
ret.put("3.12", IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_12);
ret.put("3.13", IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_13);
/*[[[end]]]*/
return Collections.unmodifiableMap(ret);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static class Versions {
cog.outl(f'public static final String LATEST_VERSION_NUMBER = "{python_versions_base[-1]}";')
]]]*/
public static final String LATEST_VERSION_NUMBER = "3.12";
public static final String LATEST_VERSION_NUMBER = "3.13";
/*[[[end]]]*/

static {
Expand Down Expand Up @@ -112,6 +112,7 @@ public static class Versions {
ALL_PYTHON_VERSIONS.add(PYTHON_VERSION_3_10);
ALL_PYTHON_VERSIONS.add(PYTHON_VERSION_3_11);
ALL_PYTHON_VERSIONS.add(PYTHON_VERSION_3_12);
ALL_PYTHON_VERSIONS.add(PYTHON_VERSION_3_13);

ALL_JYTHON_VERSIONS.add(JYTHON_VERSION_3_5);
ALL_JYTHON_VERSIONS.add(JYTHON_VERSION_3_6);
Expand All @@ -121,6 +122,7 @@ public static class Versions {
ALL_JYTHON_VERSIONS.add(JYTHON_VERSION_3_10);
ALL_JYTHON_VERSIONS.add(JYTHON_VERSION_3_11);
ALL_JYTHON_VERSIONS.add(JYTHON_VERSION_3_12);
ALL_JYTHON_VERSIONS.add(JYTHON_VERSION_3_13);

ALL_IRONPYTHON_VERSIONS.add(IRONPYTHON_VERSION_3_5);
ALL_IRONPYTHON_VERSIONS.add(IRONPYTHON_VERSION_3_6);
Expand All @@ -130,6 +132,7 @@ public static class Versions {
ALL_IRONPYTHON_VERSIONS.add(IRONPYTHON_VERSION_3_10);
ALL_IRONPYTHON_VERSIONS.add(IRONPYTHON_VERSION_3_11);
ALL_IRONPYTHON_VERSIONS.add(IRONPYTHON_VERSION_3_12);
ALL_IRONPYTHON_VERSIONS.add(IRONPYTHON_VERSION_3_13);

VERSION_NUMBERS.add("3.5");
VERSION_NUMBERS.add("3.6");
Expand All @@ -139,6 +142,7 @@ public static class Versions {
VERSION_NUMBERS.add("3.10");
VERSION_NUMBERS.add("3.11");
VERSION_NUMBERS.add("3.12");
VERSION_NUMBERS.add("3.13");

mappedVersions.put("3.5", "3.5");
mappedVersions.put("3.6", "3.6");
Expand All @@ -148,6 +152,7 @@ public static class Versions {
mappedVersions.put("3.10", "3.10");
mappedVersions.put("3.11", "3.11");
mappedVersions.put("3.12", "3.12");
mappedVersions.put("3.13", "3.13");
/*[[[end]]]*/

ALL_PYTHON_VERSIONS.add(PYTHON_VERSION_INTERPRETER);
Expand Down Expand Up @@ -271,6 +276,7 @@ public static int getInternalVersion(String version) {
public static final String PYTHON_VERSION_3_10 = "python 3.10";
public static final String PYTHON_VERSION_3_11 = "python 3.11";
public static final String PYTHON_VERSION_3_12 = "python 3.12";
public static final String PYTHON_VERSION_3_13 = "python 3.13";

public static final String JYTHON_VERSION_3_5 = "jython 3.5";
public static final String JYTHON_VERSION_3_6 = "jython 3.6";
Expand All @@ -280,6 +286,7 @@ public static int getInternalVersion(String version) {
public static final String JYTHON_VERSION_3_10 = "jython 3.10";
public static final String JYTHON_VERSION_3_11 = "jython 3.11";
public static final String JYTHON_VERSION_3_12 = "jython 3.12";
public static final String JYTHON_VERSION_3_13 = "jython 3.13";

public static final String IRONPYTHON_VERSION_3_5 = "ironpython 3.5";
public static final String IRONPYTHON_VERSION_3_6 = "ironpython 3.6";
Expand All @@ -289,6 +296,7 @@ public static int getInternalVersion(String version) {
public static final String IRONPYTHON_VERSION_3_10 = "ironpython 3.10";
public static final String IRONPYTHON_VERSION_3_11 = "ironpython 3.11";
public static final String IRONPYTHON_VERSION_3_12 = "ironpython 3.12";
public static final String IRONPYTHON_VERSION_3_13 = "ironpython 3.13";
/*[[[end]]]*/

public static final String JYTHON_VERSION_INTERPRETER = "jython interpreter";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public static String getGrammarVersionStr(int grammarVersion) {
return "grammar: Python 3.11";
case IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_12:
return "grammar: Python 3.12";
case IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_13:
return "grammar: Python 3.13";
/*[[[end]]]*/
}

Expand Down Expand Up @@ -577,6 +579,9 @@ public static IGrammar createGrammar(boolean generateTree, int grammarVersion, c
case IPythonNature.GRAMMAR_PYTHON_VERSION_3_12:
grammar = new PythonGrammar312(generateTree, in);
break;
case IPythonNature.GRAMMAR_PYTHON_VERSION_3_13:
grammar = new PythonGrammar312(generateTree, in);
break;
/*[[[end]]]*/
//case CYTHON: not treated here (only in reparseDocument).
default:
Expand Down
3 changes: 2 additions & 1 deletion rootproject/codegen_helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
python_versions_base = ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python_versions_base = ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

python_versions_underscore = [x.replace('.', '_') for x in python_versions_base]

Expand All @@ -11,4 +11,5 @@
'3_10': 'PythonGrammar310',
'3_11': 'PythonGrammar311',
'3_12': 'PythonGrammar312',
'3_13': 'PythonGrammar312',
}

0 comments on commit 633aca2

Please sign in to comment.