Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Responsivo #2

Merged
merged 2 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Notas de Aula de Compiladores.pdf
Binary file not shown.
41 changes: 36 additions & 5 deletions compilador/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,48 @@

<!-- CodeMirror Editor-->
<link rel="stylesheet" href="codemirror/lib/codemirror.css" />
<script src="codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="codemirror/theme/dracula.css" />
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css" />
<link rel="stylesheet" href="codemirror/addon/display/fullscreen.css" />

<script src="codemirror/lib/codemirror.js"></script>
<script src="codemirror/mode/javascript/javascript.js"></script>
<script src="codemirror/addon/display/fullscreen.js"></script>

<!-- Script imports -->
<script type="module" src="js/main.js"></script>
</head>

<body>
<div id="menu">
<h1 id="logo">compilaDOR</h1>
<nav id="menu_container">
<script>
function openNav() {
var x = document.getElementById("nav");
if (x.className === "menu") {
x.className += " responsive";
} else {
x.className = "menu";
}
}
</script>

<div id="nav" class="menu responsive">
<div
style="
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
"
>
<h1 id="logo">compilaDOR</h1>

<div onclick="openNav()" class="menu_btn" id="menu_icon">
<span class="material-icons"> menu </span>
<p>Menu</p>
</div>
</div>

<div id="menu_container">
<div class="menu_btn" id="compilar">
<span class="material-icons"> play_arrow </span>
<p>Compilar</p>
Expand All @@ -41,7 +72,7 @@ <h1 id="logo">compilaDOR</h1>
<p>Carregar</p>
<input id="file-input" type="file" accept=".txt" />
</div>
</nav>
</div>
</div>

<div id="codeeditor">
Expand Down
5 changes: 4 additions & 1 deletion compilador/js/lexico.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Author: Iago Lourenço (iagojlourenco@gmail.com) / lexico.js

function pegaToken(data) {
let isComment = false;
let listaTokens = [];
Expand Down Expand Up @@ -56,9 +58,10 @@ function pegaToken(data) {
continue;
}

// Se o caracter for uma letra ou "_", trata como identificador
// Se o caracter for uma letra, trata como identificador
if (caracter.match(/[a-zA-Z]/)) {
let tokenId = "";
// Enquanto for letra, "_" ou número
while (caracter != undefined && caracter.match(/[a-zA-Z0-9_]/)) {
tokenId += caracter;
caracter = data[++i];
Expand Down
10 changes: 10 additions & 0 deletions compilador/js/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Author: Iago Lourenço (iagojlourenco@gmail.com) / main.js

function loadLocalFile(files, editor) {
if (files.length == 1) {
var reader = new FileReader();
Expand Down Expand Up @@ -47,6 +49,14 @@ window.onload = function () {
lineNumbers: true,
autofocus: true,
viewportMargin: 150,
extraKeys: {
F11: function (cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
Esc: function (cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
},
},
});
editor.on("cursorActivity", function () {
document.getElementById("posicao").innerHTML = `Ln ${
Expand Down
1 change: 1 addition & 0 deletions compilador/js/sintatico.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Author: Iago Lourenço (iagojlourenco@gmail.com) / sintatico.js
43 changes: 41 additions & 2 deletions compilador/styles/main.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
html,
body {
height: 100%;
width: 100%;
min-width: 270px;
margin: 0;
padding: 0;
overflow-x: hidden;
}

#menu {
#menu_icon {
display: none;
}

@media screen and (max-width: 460px) {
#menu_container * {
display: none;
}
div#menu_icon {
display: flex;
}
.menu.responsive {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
}

.menu.responsive #menu_container * {
display: flex;
transition: 0.5s;
}

.menu {
display: flex;
align-items: center;
width: 95%;
margin: auto;
justify-content: space-between;
}

#menu_container {
display: flex;
align-items: center;
Expand All @@ -18,7 +51,8 @@ body {
align-items: center;
justify-content: center;
cursor: pointer;
margin: 4px;
margin: 2px;
padding: 2px;
font-family: monospace;
min-width: 75px;
border-radius: 5px;
Expand All @@ -39,13 +73,16 @@ body {
.CodeMirror {
resize: vertical;
overflow: hidden !important;
font-family: monospace;
font-size: large;
}

#codeeditor {
display: flex;
flex-direction: column;
border: 1px solid rgba(248, 248, 242, 1) !important;
max-width: 1200px;
width: 95%;
margin: auto;
}

Expand All @@ -69,6 +106,8 @@ body {
border: 1px solid rgba(248, 248, 242, 1) !important;
min-height: 100px;
max-width: 1200px;
width: 95%;

margin: 20px auto auto auto;
}

Expand Down