93 lines
2.1 KiB
Plaintext
93 lines
2.1 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import import_ipynb\n",
|
|
"from PGenType import *\n",
|
|
"from PGenObject import *\n",
|
|
"\n",
|
|
"class PString(PGenType):\n",
|
|
" \n",
|
|
" def __init__(self, value = None, defined = None):\n",
|
|
" super(PString, self).__init__(value, defined)\n",
|
|
" \n",
|
|
" def getTypeName(self):\n",
|
|
" return 'string'\n",
|
|
" \n",
|
|
" def getTypeClass(self):\n",
|
|
" return self.__class__.__name__\n",
|
|
" \n",
|
|
" \n",
|
|
" \n",
|
|
" def __str__(self):\n",
|
|
" if self.getValue() == None:\n",
|
|
" return \"(string undefined)\"\n",
|
|
" return \"(String \" + str(self.getValue()) + \")\"\n",
|
|
" \n",
|
|
" def parse(self, text):\n",
|
|
" if text is None:\n",
|
|
" return None\n",
|
|
" else:\n",
|
|
" self.setValue(text)\n",
|
|
" return self\n",
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"######Test\n",
|
|
"#s1=PString('abs')\n",
|
|
"#print(s1.getValue())\n",
|
|
"#print(s1.getDefined())\n",
|
|
"#l= ['ABS', True]\n",
|
|
"#s1.InFromList(l)\n",
|
|
"#print(s1.getValue())\n",
|
|
"#print(s1.getDefined())\n",
|
|
"#print(s1.OutToList())\n",
|
|
"#print(s1.parse(\"abcd\"))\n",
|
|
"#s2=PString('efgh')\n",
|
|
"#s3 = s1 + s2\n",
|
|
"#print(s3.getValue(), s3.getDefined())\n",
|
|
"#print(s1 == s2)\n",
|
|
"#print(s2 > s1)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.7.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|