mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
support if and while in main.py
This commit is contained in:
parent
46882bd75a
commit
147141a479
@ -16,3 +16,7 @@ print('mem.max :')
|
||||
mem.max()
|
||||
print('mem.now :')
|
||||
mem.now()
|
||||
|
||||
while True:
|
||||
io1.low()
|
||||
io1.off()
|
||||
|
@ -3,6 +3,8 @@
|
||||
/* ******************************** */
|
||||
#include "PikaMain.h"
|
||||
#include "PikaStdLib_SysObj.h"
|
||||
#include "io1_low.h"
|
||||
#include "io1_off.h"
|
||||
#include "STM32_GPIO.h"
|
||||
#include "PikaStdLib_MemChecker.h"
|
||||
#include <stdio.h>
|
||||
@ -11,6 +13,8 @@
|
||||
|
||||
PikaObj *New_PikaMain(Args *args){
|
||||
PikaObj *self = New_PikaStdLib_SysObj(args);
|
||||
obj_import(self, "io1_low", New_io1_low);
|
||||
obj_import(self, "io1_off", New_io1_off);
|
||||
obj_import(self, "STM32_GPIO", New_STM32_GPIO);
|
||||
obj_newObj(self, "io1", "STM32_GPIO");
|
||||
obj_import(self, "PikaStdLib_MemChecker", New_PikaStdLib_MemChecker);
|
||||
|
File diff suppressed because one or more lines are too long
@ -5,3 +5,7 @@ line = Arm2D.Line()
|
||||
res = line.on()
|
||||
line.off()
|
||||
line.moveTo(20)
|
||||
|
||||
while True:
|
||||
line.off()
|
||||
line.on()
|
||||
|
@ -111,6 +111,7 @@ impl ClassInfo {
|
||||
script_fn.push_str("PikaObj * pikaScriptInit(){\r\n");
|
||||
script_fn.push_str(" PikaObj * pikaMain = newRootObj(\"pikaMain\", New_PikaMain);\r\n");
|
||||
script_fn.push_str(&self.script_list.content);
|
||||
script_fn.push_str(" obj_run(pikaMain, \"\");\r\n");
|
||||
script_fn.push_str(" return pikaMain;\r\n");
|
||||
script_fn.push_str("}\r\n\r\n");
|
||||
return script_fn;
|
||||
|
@ -50,6 +50,17 @@ impl Compiler {
|
||||
}
|
||||
if line.contains("(") && line.contains(")") {
|
||||
class_now.script_list.add(&line);
|
||||
return compiler;
|
||||
}
|
||||
|
||||
if line.starts_with("if ") {
|
||||
class_now.script_list.add(&line);
|
||||
return compiler;
|
||||
}
|
||||
|
||||
if line.starts_with("while ") {
|
||||
class_now.script_list.add(&line);
|
||||
return compiler;
|
||||
}
|
||||
return compiler;
|
||||
}
|
||||
@ -101,6 +112,11 @@ impl Compiler {
|
||||
class_now.push_method(line);
|
||||
return compiler;
|
||||
}
|
||||
|
||||
if file_name == "main" {
|
||||
return Compiler::analyze_main_line(compiler, line);
|
||||
}
|
||||
|
||||
if line.starts_with(" ")
|
||||
&& line.contains("(")
|
||||
&& line.contains(")")
|
||||
@ -124,10 +140,6 @@ impl Compiler {
|
||||
return compiler;
|
||||
}
|
||||
|
||||
if file_name == "main" {
|
||||
return Compiler::analyze_main_line(compiler, line);
|
||||
}
|
||||
|
||||
return compiler;
|
||||
}
|
||||
}
|
||||
|
BIN
src/package/pikascript/rust-msc-latest-linux.exe
Normal file
BIN
src/package/pikascript/rust-msc-latest-linux.exe
Normal file
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user