From 6aad9b40de4002ab061988b21ff1b806ffa1cb9e Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Tue, 21 Feb 2017 13:48:10 -0500 Subject: [PATCH 1/9] Finish grammar --- PLATYPUS Grammar Specification.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 82105ea..7effa17 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -161,13 +161,13 @@ #### 3.2.2 Selection Statement (`if` statement) ``` -> - IF () THEN + IF () THEN ELSE {}; ``` #### 3.2.3 Iteration Statement (the loop statement) ``` -> - + USING ( , , ) REPEAT { }; ``` #### 3.2.4 Input Statement ``` @@ -180,7 +180,7 @@ #### 3.2.5 Output Statement ``` -> - + OUTPUT( | ); ``` ### 3.3 Expressions #### 3.3.1 Arithmetic Expressions @@ -222,23 +222,27 @@ #### 3.3.3 Conditional Expression ``` -> - + + | + | -> - + .OR. -> - + .AND. ``` #### 3.3.4 Relational Expression ``` -> == | <= + | >= | > | < | == | <= + | >= | > | < @@ -248,5 +252,6 @@ | -> - + + | ``` \ No newline at end of file From f8109d40ec709f698a6f00a037d7e04705db2e09 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Tue, 21 Feb 2017 14:25:21 -0500 Subject: [PATCH 2/9] BNF: Add C's syntax for conditional expressions as potential solution --- .gitattributes | 63 +++++++++++++++++++++++++++++++ PLATYPUS Grammar Specification.md | 16 ++++++++ buffer/buffer.sln | 28 ++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 .gitattributes create mode 100644 buffer/buffer.sln diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 7effa17..48d3545 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -226,6 +226,22 @@ | | + +// BNF from C specification +// (translated to PLATYPUS because it does not implement all of C's grammar) +// source: https://cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The%20syntax%20of%20C%20in%20Backus-Naur%20form.htm + -> + + + -> + + | .OR. + + -> + .AND. +// END BNF from C specification + + -> .OR. diff --git a/buffer/buffer.sln b/buffer/buffer.sln new file mode 100644 index 0000000..49f3f35 --- /dev/null +++ b/buffer/buffer.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "buffer", "buffer\buffer.vcxproj", "{034E0E4B-DAFA-45D4-882B-1815AC73DA9E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Debug|x64.ActiveCfg = Debug|x64 + {034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Debug|x64.Build.0 = Debug|x64 + {034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Debug|x86.ActiveCfg = Debug|Win32 + {034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Debug|x86.Build.0 = Debug|Win32 + {034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x64.ActiveCfg = Release|x64 + {034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x64.Build.0 = Release|x64 + {034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x86.ActiveCfg = Release|Win32 + {034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From 1929d2760242d4cc324a9efc50b61db2f34a8178 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Tue, 21 Feb 2017 14:29:51 -0500 Subject: [PATCH 3/9] BNF: Fix --- PLATYPUS Grammar Specification.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 48d3545..064101b 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -238,7 +238,8 @@ | .OR. -> - .AND. + + | .AND. // END BNF from C specification From 3a0a4772259dc49b5e9eb174244e795687ce9c46 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Tue, 21 Feb 2017 14:46:11 -0500 Subject: [PATCH 4/9] BNF: Fix MAJOR ERROR in operators --- PLATYPUS Grammar Specification.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 064101b..56fcb47 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -123,6 +123,9 @@ + - * / -> one of + << + + -> one of > < == <> -> From 6b6226bba92114985bcc076a49307830931b18cf Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Tue, 21 Feb 2017 14:54:07 -0500 Subject: [PATCH 5/9] BNF correction: No >= or <= allowed in this spec --- PLATYPUS Grammar Specification.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 56fcb47..256754e 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -124,7 +124,7 @@ -> one of << - + -> one of > < == <> @@ -255,16 +255,8 @@ #### 3.3.4 Relational Expression ``` -> - == - | <= - | >= - | > - | < - | == - | <= - | >= - | > - | < + + | -> From 321cb4a95998ba4d95eb1a9aa839684f68d0d72c Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Tue, 21 Feb 2017 15:08:32 -0500 Subject: [PATCH 6/9] Clean up and remove 'one of's --- PLATYPUS Grammar Specification.md | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 256754e..5981456 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -82,7 +82,7 @@ 0 | -> one of - [1-9] + 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 -> 0 @@ -109,8 +109,8 @@ ``` ### 2.9 Separators ``` - -> one of - ( ) { } , ; " . + -> + ( | ) | { | } | , | ; | " |. ``` ### 2.10 Operators ``` @@ -119,14 +119,14 @@ | | | - -> one of - + - * / + -> + + | - | * | / - -> one of + -> << - -> one of - > < == <> + -> + > | < | == | <> -> .AND. | .OR. @@ -224,12 +224,6 @@ ``` #### 3.3.3 Conditional Expression ``` - -> - - | - | - - // BNF from C specification // (translated to PLATYPUS because it does not implement all of C's grammar) // source: https://cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The%20syntax%20of%20C%20in%20Backus-Naur%20form.htm @@ -244,13 +238,6 @@ | .AND. // END BNF from C specification - - - -> - .OR. - - -> - .AND. ``` #### 3.3.4 Relational Expression ``` From 7a371732638bb5fb796907e884ce301005110f14 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Wed, 22 Feb 2017 19:10:15 -0500 Subject: [PATCH 7/9] h --- PLATYPUS Grammar Specification.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 5981456..506a462 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -2,7 +2,9 @@ ## 2. Lexical Specification (INCOMPLETE) -## NOTE: **This is incredibly incomplete and broken, I am simply writing this down and will fix it as I read along the informal language specification provided to me** +## NOTE: +**This is incomplete, I am simply writing this down and will fix it as I read along the informal language specification provided to me +This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all the definitions correct and complete.** ### 2.1 Input Elements and Tokens ``` @@ -134,7 +136,7 @@ -> = ``` -## 3. The PLATYPUS Syntatic Specification +## 3. The PLATYPUS Syntactic Specification ### 3.1 PLATYPUS Program ``` -> @@ -158,8 +160,8 @@ -> - AVID = - | SVID = + = + | = ``` #### 3.2.2 Selection Statement (`if` statement) ``` @@ -225,14 +227,14 @@ #### 3.3.3 Conditional Expression ``` // BNF from C specification -// (translated to PLATYPUS because it does not implement all of C's grammar) +// (adapted to PLATYPUS specification because it does not implement all of C's grammar) // source: https://cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The%20syntax%20of%20C%20in%20Backus-Naur%20form.htm -> -> - | .OR. + | .OR. -> @@ -251,6 +253,6 @@ | -> - - | + + | ``` \ No newline at end of file From 6b6d084096b9a5369dbd06ef6380c0b7c38cd3b1 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Wed, 22 Feb 2017 19:18:48 -0500 Subject: [PATCH 8/9] BNF: end of statement character --- PLATYPUS Grammar Specification.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 506a462..65d15f8 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -157,7 +157,7 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all ### 3.3 Assignment Statement ``` -> - + ; -> = @@ -226,8 +226,7 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all ``` #### 3.3.3 Conditional Expression ``` -// BNF from C specification -// (adapted to PLATYPUS specification because it does not implement all of C's grammar) +// BNF from C specification adapted to PLATYPUS // source: https://cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The%20syntax%20of%20C%20in%20Backus-Naur%20form.htm -> From cd18b511767538dd07013bfd2b954d6e46c81e57 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Wed, 22 Feb 2017 19:23:31 -0500 Subject: [PATCH 9/9] Start converting UBNF (ugly BNF) into BNF --- PLATYPUS Grammar Specification.md | 116 +++++++++++++++--------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 65d15f8..5e764b5 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -7,147 +7,147 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all the definitions correct and complete.** ### 2.1 Input Elements and Tokens -``` - -> +``` bnf + ::= ASCII characters but not SEOF - -> + ::= SEOF - -> + ::= | - -> + ::= | | | | | | ``` ### 2.2 White Space ``` - -> + ::= ASCII SP character (space) | ASCII HT character (horizontal tab) | ASCII VT character (vertical tab) | ASCII FF character (form feed) | - -> + ::= CR | LF | CR LF ``` ### 2.3 Comments ``` - -> + ::= !< - -> + ::= | - -> + ::= but not ``` ### 2.4 Variable Identifiers ``` - -> + ::= | - -> + ::= - -> + ::= | - -> one of + ::= one of [a-z][A-Z] - -> one of + ::= one of [a-z][A-Z][0-9] - -> + ::= # ``` ### 2.5 Keywords ``` - -> + ::= PLATYPUS | IF | THEN | ELSE | USING | REPEAT | INPUT | OUTPUT ``` ### 2.6 Integer Literals ``` - -> + ::= | - -> + ::= 0 | - -> + ::= | - -> + ::= 0 | - -> one of + ::= one of 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 - -> + ::= 0 - -> + ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 - -> + ::= | ``` ### 2.7 Floating-point Literals ``` - -> + ::= . ``` ### 2.8 String Literals ``` - -> + ::= "" - -> + ::= | ``` ### 2.9 Separators ``` - -> + ::= ( | ) | { | } | , | ; | " |. ``` ### 2.10 Operators ``` - -> + ::= | | | | - -> + ::= + | - | * | / - -> + ::= << - -> + ::= > | < | == | <> - -> + ::= .AND. | .OR. - -> + ::= = ``` ## 3. The PLATYPUS Syntactic Specification ### 3.1 PLATYPUS Program ``` - -> + ::= PLATYPUS {} SEOF - -> + ::= | ``` ### 3.2 Statements ``` - -> + ::= | | @@ -156,59 +156,59 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all ``` ### 3.3 Assignment Statement ``` - -> + ::= ; - -> + ::= = | = ``` #### 3.2.2 Selection Statement (`if` statement) ``` - -> + ::= IF () THEN ELSE {}; ``` #### 3.2.3 Iteration Statement (the loop statement) ``` - -> + ::= USING ( , , ) REPEAT { }; ``` #### 3.2.4 Input Statement ``` - -> + ::= INPUT (); - -> + ::= | , ``` #### 3.2.5 Output Statement ``` - -> + ::= OUTPUT( | ); ``` ### 3.3 Expressions #### 3.3.1 Arithmetic Expressions ``` - -> + ::= | - -> + ::= - | + -> + ::= + | - | - -> + ::= * | / | - -> + ::= | | @@ -216,11 +216,11 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all ``` #### 3.3.2 String Expression ``` - -> + ::= | << - -> + ::= | ``` @@ -228,30 +228,30 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all ``` // BNF from C specification adapted to PLATYPUS // source: https://cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The%20syntax%20of%20C%20in%20Backus-Naur%20form.htm - -> + ::= - -> + ::= | .OR. - -> + ::= | .AND. // END BNF from C specification ``` #### 3.3.4 Relational Expression ``` - -> + ::= | - -> + ::= | | - -> + ::= | ``` \ No newline at end of file