[#24] New language: Flex
This commit is contained in:
parent
014a97fd2a
commit
810673ee2e
|
@ -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: {
|
||||
|
|
|
@ -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) =>
|
||||
|
|
|
@ -35,6 +35,10 @@ fsharp
|
|||
# Fish
|
||||
fish
|
||||
|
||||
# Flex
|
||||
flex
|
||||
flex-doc
|
||||
|
||||
# FORTRAN
|
||||
flang
|
||||
|
||||
|
|
Loading…
Reference in New Issue