94 lines
2.1 KiB
Plaintext
94 lines
2.1 KiB
Plaintext
|
|
{
|
||
|
|
"cells": [
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 7,
|
||
|
|
"metadata": {
|
||
|
|
"scrolled": true
|
||
|
|
},
|
||
|
|
"outputs": [],
|
||
|
|
"source": [
|
||
|
|
"import import_ipynb\n",
|
||
|
|
"from PGenType import *\n",
|
||
|
|
"from PGenObject import *\n",
|
||
|
|
"\n",
|
||
|
|
"class PBool(PGenType):\n",
|
||
|
|
" \n",
|
||
|
|
" def __init__(self, value = None, defined = None):\n",
|
||
|
|
" super(PBool, self).__init__(value, defined)\n",
|
||
|
|
" \n",
|
||
|
|
" def getTypeName(self):\n",
|
||
|
|
" return 'bool'\n",
|
||
|
|
" \n",
|
||
|
|
" def getTypeClass(self):\n",
|
||
|
|
" return self.__class__.__name__\n",
|
||
|
|
" \n",
|
||
|
|
" def __str__(self):\n",
|
||
|
|
" return \"(bool \" + str(self.value).upper() + \")\"\n",
|
||
|
|
" \n",
|
||
|
|
" def parse(self, text):\n",
|
||
|
|
" if \"true\" == text.lower():\n",
|
||
|
|
" result = PBool(True)\n",
|
||
|
|
" elif \"false\" == text.lower():\n",
|
||
|
|
" result = PBool(False)\n",
|
||
|
|
" return result\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 8,
|
||
|
|
"metadata": {},
|
||
|
|
"outputs": [],
|
||
|
|
"source": [
|
||
|
|
"#### Test\n",
|
||
|
|
"#b = PBool(True,False)\n",
|
||
|
|
"#print(b.getValue())\n",
|
||
|
|
"#print(b.getDefined())\n",
|
||
|
|
"#a=PBool(True)\n",
|
||
|
|
"#print(a.getValue())\n",
|
||
|
|
"#print(a.getDefined())\n",
|
||
|
|
"#print(a==b)\n",
|
||
|
|
"#print(a.getTypeName())\n",
|
||
|
|
"#print(a.getTypeClass())\n",
|
||
|
|
"#l=[False, False]\n",
|
||
|
|
"#a.InFromList(l)\n",
|
||
|
|
"#print(a.getValue())\n",
|
||
|
|
"#print(a.getDefined())\n",
|
||
|
|
"#print(a.OutToList())\n",
|
||
|
|
"#print(b.OutToList())\n",
|
||
|
|
"#print(a)\n",
|
||
|
|
"#c = a.parse(\"false\")\n",
|
||
|
|
"#print(c)"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"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
|
||
|
|
}
|