diff --git a/src/compiler/compiler.go b/src/compiler/compiler.go index a3dd4da..5ca3dba 100644 --- a/src/compiler/compiler.go +++ b/src/compiler/compiler.go @@ -16,14 +16,16 @@ func main() { } fileContents := string(file) - tokens, err := tokenize([]rune(fileContents)) + tokens, err := tokenizeMdem([]rune(fileContents)) if (err != nil) { fmt.Printf("%s\n", err.Error()) return } - log.Println("Lexer output:") - for _, el := range tokens { - fmt.Print(el.ToString()) + if (true) { + log.Println("Lexer output:") + for _, el := range tokens { + fmt.Print(el.ToString()) + } } automata = parserAutomata() @@ -36,9 +38,11 @@ func main() { if (err != nil) { log.Fatal(err.Error()) } - log.Println("Parser output:") - for _, element := range questions { - fmt.Printf("%s", element.ToString()) + if (true) { + log.Println("Parser output:") + for _, element := range questions { + fmt.Printf("%s", element.ToString()) + } } log.Println("Compilation completed") diff --git a/src/compiler/deck.mdec b/src/compiler/deck.moml similarity index 99% rename from src/compiler/deck.mdec rename to src/compiler/deck.moml index 23fa3a0..24a1a96 100644 --- a/src/compiler/deck.mdec +++ b/src/compiler/deck.moml @@ -1,4 +1,3 @@ - [MathTest] items = {graph_theory.networks, linear_algebra.*} base_interval = 2 diff --git a/src/compiler/go.mod b/src/compiler/go.mod index d9afeb0..58dc732 100644 --- a/src/compiler/go.mod +++ b/src/compiler/go.mod @@ -1,5 +1,3 @@ module github.com/jorenchik/mdemory/src/compiler go 1.22.5 - -require golang.org/x/text v0.16.0 diff --git a/src/compiler/go.sum b/src/compiler/go.sum index e85a4c4..e69de29 100644 --- a/src/compiler/go.sum +++ b/src/compiler/go.sum @@ -1,2 +0,0 @@ -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= diff --git a/src/compiler/lexer.go b/src/compiler/lexer.go index f2d4079..8932cb0 100644 --- a/src/compiler/lexer.go +++ b/src/compiler/lexer.go @@ -5,7 +5,6 @@ import ( "strings" ) -var tokens []Token var buffer []rune var row int32 = 1 var column int32 = 1 @@ -37,7 +36,6 @@ type Token struct { column int32; } - func (token Token)ToString() string { content := token.content if (token.tokenType == TextFragment) { @@ -57,6 +55,7 @@ func (token Token)ToString() string { ) } +var tokens []Token func makePostTextToken(ttype TokenType, tokenLen int32, textType TokenType) { if (len(strings.Trim(string(buffer), " \n\t")) - 1 > 0) { @@ -89,7 +88,7 @@ func makePostTextToken(ttype TokenType, tokenLen int32, textType TokenType) { buffer = []rune{} } -func tokenize(fileRunes []rune) ( []Token, error ) { +func tokenizeMdem(fileRunes []rune) ( []Token, error ) { tokens = []Token{} buffer = []rune{} @@ -187,29 +186,17 @@ func tokenize(fileRunes []rune) ( []Token, error ) { func ToString (ttype *TokenType) string { switch *ttype { - case TextFragment: - return "TextFragment" - case QuestionEnd: - return "QuestionEnd" - case ElementDashStart: - return "ElementDashStart" - case ElementPlusStart: - return "ElementPlusStart" - case Identifier: - return "Identifier" - case IdentifierStart: - return "IdentifierStart" - case IdentifierEnd: - return "IdentifierEnd" - case SectionIdentifierStart: - return "SectionIdentifierStart" - case SectionStart: - return "SectionStart" - case SectionEnd: - return "SectionEnd" - case EOF: - return "EndOfFile" - default: - return "NOT_DEFINED" + case TextFragment: return "TextFragment" + case QuestionEnd: return "QuestionEnd" + case ElementDashStart: return "ElementDashStart" + case ElementPlusStart: return "ElementPlusStart" + case Identifier: return "Identifier" + case IdentifierStart: return "IdentifierStart" + case IdentifierEnd: return "IdentifierEnd" + case SectionIdentifierStart: return "SectionIdentifierStart" + case SectionStart: return "SectionStart" + case SectionEnd: return "SectionEnd" + case EOF: return "EndOfFile" + default: return "NOT_DEFINED" } }