[#24] New language: Flex

This commit is contained in:
Radon Rosborough 2020-09-28 19:36:27 -07:00
parent 014a97fd2a
commit 810673ee2e
3 changed files with 32 additions and 1 deletions

View File

@ -1132,6 +1132,31 @@ USE: io
input: `echo $x`,
},
template: `echo "Hello, world!"
`,
},
flex: {
aliases: ["lex"],
name: "Flex",
main: "main.lex",
compile: "lex -o main.c main.lex && clang main.c -o main",
run: "echo 'Reading from stdin, ctrl+D to end input...' >&2 && ./main",
helloInput: "EOF",
template: `%{
#include <stdio.h>
%}
%%
%%
int yywrap() {
printf("Hello, world!\\n");
return 1;
}
int main() {
yylex();
return 0;
}
`,
},
forth: {

View File

@ -31,7 +31,9 @@ function findPosition(str: string, idx: number) {
async function sendInput(send: (msg: any) => any, input: string) {
for (const line of input.split("\n")) {
if (line.startsWith("DELAY:")) {
if (line === "EOF") {
send({ event: "terminalInput", input: "\u0004" });
} else if (line.startsWith("DELAY:")) {
const delay = parseFloat(line.replace(/DELAY: */, ""));
if (Number.isNaN(delay)) continue;
await new Promise((resolve) =>

View File

@ -35,6 +35,10 @@ fsharp
# Fish
fish
# Flex
flex
flex-doc
# FORTRAN
flang