diff --git a/ldedit/.gitignore b/.gitignore similarity index 100% rename from ldedit/.gitignore rename to .gitignore diff --git a/ldtext/LDText.fs b/ldtext/LDText.fs new file mode 100644 index 0000000..08b29fd --- /dev/null +++ b/ldtext/LDText.fs @@ -0,0 +1,14 @@ +module LDText + +module Ast = + type Rung = Step list + + and Instr = { Op: string; Args: Operand list } + + and Step = + | StepInstr of Instr + | StepBranch of Step list + + and Operand = + | OperandHole + | OperandTag of string diff --git a/ldtext/Library.fs b/ldtext/Library.fs new file mode 100644 index 0000000..470ac73 --- /dev/null +++ b/ldtext/Library.fs @@ -0,0 +1,5 @@ +namespace ldtext + +module Say = + let hello name = + printfn "Hello %s" name diff --git a/ldtext/Parser.fsy b/ldtext/Parser.fsy new file mode 100644 index 0000000..bad1531 --- /dev/null +++ b/ldtext/Parser.fsy @@ -0,0 +1,38 @@ +%{ +open LDText.Ast +// helper functions +%} + +// start token +%start start + +// tokens, used by lexer +%token IDENTIFIER +%token LEFT_PAREN +%token RIGHT_PAREN +%token LEFT_BRACKET +%token RIGHT_BRACKET +%token COMMA +%token SEMICOLON +%token QUESTION_MARK +%token EOF + +// return type of parser, marked by start token +%type rung + +%% + +start: + | instr EOF { $1 } + +instr: + | IDENTIFIER LEFT_PAREN operands RIGHT_PAREN { StepInstr { Op = $1; Args = [ $3 ] } } + +operands: + | { } + | operand operands { $1; $2 } + +operand: + | IDENTIFIER { OperandTag $1 } + | QUESTION_MARK { OperandHole } +%% diff --git a/ldtext/ldtext.fsproj b/ldtext/ldtext.fsproj new file mode 100644 index 0000000..9bd8f1c --- /dev/null +++ b/ldtext/ldtext.fsproj @@ -0,0 +1,20 @@ + + + + net9.0 + true + + + + + + --module Parser + + + + + + + + + diff --git a/reference data/simple_program.L5X b/reference data/simple_program.L5X new file mode 100644 index 0000000..cdcbd53 --- /dev/null +++ b/reference data/simple_program.L5X @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100 + Embedded + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file