diff --git a/docs/examples/greeting.txt b/docs/examples/greeting.txt index c35f8f7..e2f840d 100644 --- a/docs/examples/greeting.txt +++ b/docs/examples/greeting.txt @@ -1,19 +1,19 @@ NewLang 0 -BeginNote +StartNote Copyright 2021 Jookia SPDX-License-Identifier: LGPL-2.1-or-later This is a comment and should be ignored by the parser EndNote -System Print BeginText Hello, there! EndText Done -System Print BeginText Please enter your name: EndText Done -Set Name To System Read EndSet BeginNote Reads an entire line EndNote -Set Prefix To BeginText Hi there, EndText EndSet +System Print StartText Hello, there! EndText Done +System Print StartText Please enter your name: EndText Done +Set Name To System Read EndSet StartNote Reads an entire line EndNote +Set Prefix To StartText Hi there, EndText EndSet Set Greeting To Prefix Append Name EndSet -If Name Equals BeginText Jookia EndText -Then System Print BeginText Hi creator! EndText +If Name Equals StartText Jookia EndText +Then System Print StartText Hi creator! EndText Else System Print Greeting EndIf diff --git a/docs/examples/menu.txt b/docs/examples/menu.txt index af1e590..f32b850 100644 --- a/docs/examples/menu.txt +++ b/docs/examples/menu.txt @@ -1,24 +1,24 @@ NewLang 0 -BeginNote +StartNote Copyright 2021 Jookia SPDX-License-Identifier: LGPL-2.1-or-later EndNote -System Print BeginText Type 'Hi' for a greeting EndText Done -System Print BeginText Type 'Exit' to exit EndText Done +System Print StartText Type 'Hi' for a greeting EndText Done +System Print StartText Type 'Exit' to exit EndText Done Set Command To System Read EndSet -If Command Equals BeginText Hi EndText -Then System Print BeginText Hey there! EndText -Else True BeginNote Does nothing EndNote +If Command Equals StartText Hi EndText +Then System Print StartText Hey there! EndText +Else True StartNote Does nothing EndNote EndIf -If Command Equals BeginText Exit EndText +If Command Equals StartText Exit EndText Then System Exit Else True EndIf -System Print BeginText What next? EndText Done +System Print StartText What next? EndText Done -BeginNote Without an Exit, NewLang will loop the file EndNote +StartNote Without an Exit, NewLang will loop the file EndNote diff --git a/src/parse.py b/src/parse.py index 2913ccd..b541e1d 100644 --- a/src/parse.py +++ b/src/parse.py @@ -180,13 +180,13 @@ context = ParseContext( None, "reading word", ParseLocation(line, column, self.filename) ) - if token == "BeginNote": + if token == "StartNote": self.skip_note(line, column) word = self.read_word() continue elif token == "EndNote": raise ParseError(context, "Found stray EndNote") - elif token == "BeginText": + elif token == "StartText": type = "text" value = self.read_text(line, column) elif token == "EndText": diff --git a/tests/test_parse.py b/tests/test_parse.py index 5c22076..62f5a1b 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -79,10 +79,10 @@ def draw_token_text(draw): value = draw(text()) text_tokens = split_by(value, lexer_whitespace) - assume("BeginText" not in text_tokens and "EndText" not in text_tokens) + assume("StartText" not in text_tokens and "EndText" not in text_tokens) space1 = draw(sampled_from(lexer_whitespace)) space2 = draw(sampled_from(lexer_whitespace)) - code = "BeginText" + space1 + value + space2 + "EndText" + code = "StartText" + space1 + value + space2 + "EndText" return SampleToken(code, "text", value) @@ -139,12 +139,12 @@ assert tokens[1].type == "EOF" -# Test that we can make notes using BeginNote and EndNote syntax. +# Test that we can make notes using StartNote and EndNote syntax. @given(text(), sampled_from(lexer_whitespace), sampled_from(lexer_whitespace)) def test_lexer_note(text, space1, space2): note_tokens = split_by(text, lexer_whitespace) - assume("BeginNote" not in note_tokens and "EndNote" not in note_tokens) - code = "BeginNote" + space1 + text + space2 + "EndNote" + assume("StartNote" not in note_tokens and "EndNote" not in note_tokens) + code = "StartNote" + space1 + text + space2 + "EndNote" tokens = safe_tokenize(code, "") assert tokens[0].type == "EOF" diff --git a/tests/test_parse_regress.py b/tests/test_parse_regress.py index b6b75d8..5f2a5a2 100644 --- a/tests/test_parse_regress.py +++ b/tests/test_parse_regress.py @@ -14,13 +14,13 @@ # The parser would read text literals by tracking the position just after of -# the BeginText and EndText tokens, then reading the literal text between them. +# the StartText and EndText tokens, then reading the literal text between them. # It would automatically remove EndText as well as the character after it. # However, if EndText was the last token, this would cause the text to cut off. # Make sure the parser can handle reading text at the end of a file. def test_regress_text_eof(): text = "Hi there!" - code = "BeginText " + text + " EndText" + code = "StartText " + text + " EndText" tokenizer1 = parse.Tokenizer(code, "") tokens1 = tokenizer1.tokenize() tokenizer2 = parse.Tokenizer(code + " ", "") @@ -31,14 +31,14 @@ assert tokens2[0].value == text -# The parser would read text literals by reading literal text after BeginText +# The parser would read text literals by reading literal text after StartText # to the end of the token just before EndText. # This solved the previous bug, but cut off any whitespace between the last # token and EndText. # Make sure the parser can handle trailing whitespace properly now. def test_regress_text_trailing_whitespace(): text = "Hi there!\n\n\n" - code = "BeginText " + text + " EndText" + code = "StartText " + text + " EndText" tokenizer = parse.Tokenizer(code, "") tokens = tokenizer.tokenize() assert tokens[0].type == "text"