GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add: input · CrazyProger1/FastPy@c2bffc0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • config
    • builtin.json
    • parser.json
  • cpp_code/libs
    • builtin.hpp
  • fastpy_build
    • bin
      • main.exe
    • src
      • include
        • builtin.hpp
      • main.cpp
  • fastpy
    • parser
      • node_parsers.py
      • nodes.py
    • transpiler
      • node_transpilers.py
  • main.fpy
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎config/builtin.json‎

Copy file name to clipboardExpand all lines: config/builtin.json
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"builtin_functions": {
33
"import": "import",
4-
"log": "log"
4+
"log": "log",
5+
"log_error": "log_error",
6+
"log_warning": "log_waring",
7+
"log_info": "log_info",
8+
"input": "input"
59
},
610
"builtin_types": {
711
"string": "str",
Collapse file

‎config/parser.json‎

Copy file name to clipboardExpand all lines: config/parser.json
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"possible_node_classes": [
4343
"fastpy.parser.nodes.ValueNode",
4444
"fastpy.parser.nodes.VariableNode",
45-
"fastpy.parser.nodes.BinOpNode"
45+
"fastpy.parser.nodes.BinOpNode",
46+
"fastpy.parser.nodes.CallNode"
4647
],
4748
"tokens_slice": {
4849
"start_index": 4
@@ -298,7 +299,8 @@
298299
"condition": {
299300
"parser_class": "fastpy.parser.node_parsers.ConditionParser",
300301
"possible_node_classes": [
301-
"fastpy.parser.nodes.LogicOpNode"
302+
"fastpy.parser.nodes.LogicOpNode",
303+
"fastpy.parser.nodes.BinOpNode"
302304
],
303305
"tokens_slice": {
304306
"start_index": 1
@@ -309,7 +311,7 @@
309311
]
310312
},
311313
"LogicOpNode": {
312-
"parser_class": "fastpy.parser.node_parsers.BinOpNodeParser",
314+
"parser_class": "fastpy.parser.node_parsers.OperationNodeParser",
313315
"node_class": "fastpy.parser.nodes.LogicOpNode",
314316
"cases": [
315317
{
@@ -321,7 +323,7 @@
321323
]
322324
},
323325
"BinOpNode": {
324-
"parser_class": "fastpy.parser.node_parsers.BinOpNodeParser",
326+
"parser_class": "fastpy.parser.node_parsers.OperationNodeParser",
325327
"node_class": "fastpy.parser.nodes.BinOpNode",
326328
"cases": [
327329
{
Collapse file

‎cpp_code/libs/builtin.hpp‎

Copy file name to clipboardExpand all lines: cpp_code/libs/builtin.hpp
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,15 @@ void log_warning(const T &t, bool endl = false) {
4444
std::cout << termcolor::on_yellow << termcolor::grey;
4545
log(t, endl);
4646
}
47+
48+
template<typename T>
49+
T input(const str &t) {
50+
if (!t.empty()) {
51+
log(t);
52+
}
53+
54+
T inp;
55+
56+
std::cin >> inp;
57+
return inp;
58+
}
Collapse file

‎fastpy/parser/node_parsers.py‎

Copy file name to clipboardExpand all lines: fastpy/parser/node_parsers.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def parse(self,
113113

114114

115115
@singleton
116-
class BinOpNodeParser(BaseNodeParser):
116+
class OperationNodeParser(BaseNodeParser):
117117
parses = (BinOpNode, LogicOpNode)
118118

119119
def validate(self,
@@ -294,7 +294,7 @@ def parse(self,
294294
expr_tokens.clear()
295295
continue
296296
elif token.type == TokenTypes.end_parenthesis:
297-
if BinOpNodeParser().validate(expr_tokens, BinOpNode):
297+
if OperationNodeParser().validate(expr_tokens, BinOpNode):
298298
try:
299299
node = parse_node_clb(expr_tokens)
300300
except ParsingError:
@@ -323,6 +323,6 @@ def parse(self,
323323
**extra_data) -> BaseNode | list[BaseNode]:
324324
return parse_node_clb(
325325
tokens[0:-1],
326-
(LogicOpNode,),
327-
BinOpNodeParser()
326+
(LogicOpNode, BinOpNode),
327+
OperationNodeParser()
328328
)
Collapse file

‎fastpy/parser/nodes.py‎

Copy file name to clipboardExpand all lines: fastpy/parser/nodes.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ def __init__(self,
7070
identifier: BaseToken,
7171
arguments: list[AssignNode] = None,
7272
body: list[BaseNode] = None,
73-
return_type: BaseToken = None):
73+
return_type: BaseToken = None,
74+
template: bool = False):
7475
self.identifier = identifier
7576
self.arguments = arguments or []
7677
self.body = body or []
7778
self.return_type = return_type
79+
self.template = template
7880

7981
@property
8082
def line(self) -> int:
Collapse file

‎fastpy/transpiler/node_transpilers.py‎

Copy file name to clipboardExpand all lines: fastpy/transpiler/node_transpilers.py
+21-3Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@ def transpile(self,
1717
class AssignNodeTranspiler(BaseNodeTranspiler):
1818
def transpile(self, node: AssignNode, transpile_node_clb: callable, **kwargs) -> BaseCode:
1919
code = Code()
20+
value_node = node.value
21+
value = ''
22+
if value_node:
23+
value = transpile_node_clb(
24+
node=value_node,
25+
**kwargs,
26+
type=node.value_type.text if node.value_type else None
27+
).internal
28+
2029
code.push_internal(
2130
f'{node.value_type.text if node.value_type is not None else "auto"} '
22-
f'{node.identifier.text}{" = " if node.value else ""}'
23-
f'{transpile_node_clb(node=node.value, **kwargs).internal if node.value else ""}',
31+
f'{node.identifier.text}{" = " if value else ""}'
32+
f'{value}',
2433
**kwargs
2534
)
2635

@@ -117,8 +126,17 @@ def transpile(self,
117126
transpile_node_clb: callable,
118127
**kwargs) -> BaseCode:
119128
code = Code()
129+
130+
cast_type = kwargs.get('type')
131+
specify_type = False
132+
133+
if node.identifier.text == BUILTIN_FUNCTIONS['input']:
134+
specify_type = True
135+
120136
code.push_internal(
121-
f'{node.identifier.text}({self._transpile_arguments(node.arguments, transpile_node_clb)})',
137+
f'{node.identifier.text}'
138+
f'{("<" + cast_type + ">") if specify_type else ""}'
139+
f'({self._transpile_arguments(node.arguments, transpile_node_clb)})',
122140
**kwargs
123141
)
124142
return code
Collapse file

‎fastpy_build/bin/main.exe‎

Copy file name to clipboard
4.54 KB
Binary file not shown.
Collapse file

‎fastpy_build/src/include/builtin.hpp‎

Copy file name to clipboardExpand all lines: fastpy_build/src/include/builtin.hpp
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,15 @@ void log_warning(const T &t, bool endl = false) {
4444
std::cout << termcolor::on_yellow << termcolor::grey;
4545
log(t, endl);
4646
}
47+
48+
template<typename T>
49+
T input(const str &t) {
50+
if (!t.empty()) {
51+
log(t);
52+
}
53+
54+
T inp;
55+
56+
std::cin >> inp;
57+
return inp;
58+
}
Collapse file

‎fastpy_build/src/main.cpp‎

Copy file name to clipboardExpand all lines: fastpy_build/src/main.cpp
+15-3Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,23 @@
1414

1515

1616
int main(){
17-
auto a = 1 + 1 - 1 * 1;
17+
str d = input<str>("hello>");
1818

19+
log(d);
1920

20-
if (a) {
21-
log("hello");
21+
auto a = 123123;
22+
23+
24+
auto b = 123412;
25+
26+
27+
auto c = a + b;
28+
29+
30+
log(c, true);
31+
32+
if (c - 246535) {
33+
log("hello, world!");
2234

2335
}
2436

Collapse file

‎main.fpy‎

Copy file name to clipboardExpand all lines: main.fpy
+19-3Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,23 @@
1616
# print_text(world_text)
1717
#
1818
#print('First FastPy run from IDE!!!!!!') # imported print function from print lib
19-
a = 1 + 1 - 1 * 1
19+
#a = 1 - 1 * 1
20+
#
21+
#if a:
22+
# log('hello')
23+
24+
#a = 10
25+
#
26+
#if true and (1 + 1 * a):
27+
# log('hello')
28+
29+
d: int = input('hello>')
30+
31+
a = 123123
32+
b = 123412
33+
34+
c = a + b
35+
log(c, true)
2036

21-
if a:
22-
log('hello')
37+
if c - 246535:
38+
log('hello, world!')

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.