File tree Expand file tree Collapse file tree
js/src/main/scala/tigerpython/parser
shared/src/main/scala/tigerpython/utilities/types Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,6 +130,15 @@ object TPyParser {
130130 }
131131 }
132132
133+ /**
134+ * TigerPython comes with some small modifications to the Python defaults, which are enabled by this method. Note
135+ * that this cannot be undone; the modifications to the types and built-in dictionary are persistent.
136+ */
137+ @ JSExport
138+ def enableTigerPythonModifications (): Unit = {
139+ tigerpython.utilities.types.BuiltinTypes .appyTigerPythonModifications()
140+ }
141+
133142 /**
134143 * Checks the syntax of the given source code and returns a list with all errors detected in the code.
135144 *
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ object BuiltinTypes {
106106 val TUPLE_TYPE = PrimitiveType (" tuple" , SEQ_TYPE )
107107 val BYTEARRAY_TYPE = PrimitiveType (" bytearray" , SEQ_TYPE )
108108 val BUFFER_TYPE = PrimitiveType (" buffer" , SEQ_TYPE )
109- val XRANGE_TYPE = PrimitiveType (" xrange" , SEQ_TYPE )
109+ // val XRANGE_TYPE = PrimitiveType("xrange", SEQ_TYPE)
110110 val UNICODE_TYPE : PrimitiveType = new PrimitiveType (" unicode" , SEQ_TYPE , Map ()) {
111111 override def getItemType : DataType = this
112112 }
@@ -293,4 +293,13 @@ object BuiltinTypes {
293293 val SET = new Instance (SET_TYPE )
294294 val STRING = new Instance (STRING_TYPE )
295295 val TUPLE = new Instance (TUPLE_TYPE )
296+
297+ def appyTigerPythonModifications (): Unit = {
298+ LIST_TYPE .addFields(
299+ PrimitiveType (" first" ),
300+ PrimitiveType (" head" ),
301+ PrimitiveType (" last" ),
302+ PrimitiveType (" tail" , LIST_TYPE )
303+ )
304+ }
296305}
You can’t perform that action at this time.
0 commit comments