Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
C0mRD committed Feb 24, 2023
1 parent f8c4e35 commit 024e516
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 34 deletions.
2 changes: 1 addition & 1 deletion example/input.bro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jotokhon bro b<a{
na hole bro{
bol bro "b greater than 10";
}
b = b+1;
b -> b+1;
}
stop bro
6 changes: 3 additions & 3 deletions frontend/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.e2d25149.css",
"main.js": "/static/js/main.00b99dc3.js",
"main.js": "/static/js/main.46a6e5f5.js",
"index.html": "/index.html",
"main.e2d25149.css.map": "/static/css/main.e2d25149.css.map",
"main.00b99dc3.js.map": "/static/js/main.00b99dc3.js.map"
"main.46a6e5f5.js.map": "/static/js/main.46a6e5f5.js.map"
},
"entrypoints": [
"static/css/main.e2d25149.css",
"static/js/main.00b99dc3.js"
"static/js/main.46a6e5f5.js"
]
}
2 changes: 1 addition & 1 deletion frontend/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"><title>BroCode</title><script defer="defer" src="/static/js/main.00b99dc3.js"></script><link href="/static/css/main.e2d25149.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"><title>BroCode</title><script defer="defer" src="/static/js/main.46a6e5f5.js"></script><link href="/static/css/main.e2d25149.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/components/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const CodeEditorWindow = ({ language, code}) => {
na hole bro{\n\
bol bro 'b greater than 10';\n\
}\n\
b = b+1;\n\
b -> b+1;\n\
}\n\
stop bro"

Expand Down
28 changes: 6 additions & 22 deletions src/broCodeInterpreter.py → src/brocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,6 @@ def visitConstant(self, ctx:broCodeParser.ConstantContext):
return ct.BOOL().getText() == 'true'
elif ct.NULL() is not None:
return None


# if __name__ == '__main__':
# input_stream = FileStream('path/to/your/brocode/file')
# lexer = broCodeLexer(input_stream)
# stream = CommonTokenStream(lexer)
# parser = broCodeParser(stream)
# tree = parser.program()
# interpreter = broCodeInterpreter()
# walker = ParseTreeWalker()
# walker.walk(interpreter, tree)

def interpret_file(path:str):
input_stream = FileStream(path)
Expand All @@ -237,19 +226,14 @@ def interpret_file(path:str):
ast = parser.program()
visitor = broCodeInterpreter()
visitor.visit(ast)

def interpret(code:str):
lexer = broCodeLexer(code)
stream = CommonTokenStream(lexer)
parser = broCodeParser(stream)
ast = parser.program()
visitor = broCodeInterpreter()
visitor.visit(ast)

def main():
file = sys.argv[1]
interpret_file(file)

if len(sys.argv)>1:
file = sys.argv[1]
interpret_file(file)
else:
print("Input filename missing")

if __name__ == '__main__':
main()

2 changes: 1 addition & 1 deletion src/code.bro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ start bro
na hole bro{
bol bro 'b greater than 10';
}
b = b+1;
b -> b+1;
}
stop bro
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def interpret():
with open('code.bro', 'w+') as f:
f.write(code)
f.close()
p = subprocess.Popen(["python","broCodeInterpreter.py","code.bro"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p = subprocess.Popen(["python","brocode.py","code.bro"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
return output.decode()

Expand Down

0 comments on commit 024e516

Please sign in to comment.