From aacdbf7dbbbc04f8d6cc4ce2b681e74ded9bed4e Mon Sep 17 00:00:00 2001 From: Joseph Hale Date: Thu, 31 Mar 2022 12:02:39 -0700 Subject: [PATCH] Create initial draft of language grammar. --- README.md | 11 ++++++ data/README.md | 3 ++ doc/README.md | 5 +++ doc/contribution.txt | 3 ++ doc/grammar.md | 81 ++++++++++++++++++++++++++++++++++++++++++++ src/README.md | 5 +++ 6 files changed, 108 insertions(+) create mode 100644 data/README.md create mode 100644 doc/README.md create mode 100644 doc/contribution.txt create mode 100644 doc/grammar.md create mode 100644 src/README.md diff --git a/README.md b/README.md index d23a9da..04e7e61 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ # 502lang The language created as the final project for Dr. Ajay Bansal's SER502 at Arizona State University in Spring 2022. + +**README Requirements** +Your ReadMe must include the following: +- System on which your compiler and runtime are built (GNUstep, Linux, Unix, +Windows or Mac OS) +- Tools used +- Directions/instructions to install your language +- Directions/instructions to build and run your language (compiler/runtime). +- ONE LINE of bash script that builds the compiler and ONE LINE that runs the +runtime. +- Link to the YouTube video \ No newline at end of file diff --git a/data/README.md b/data/README.md new file mode 100644 index 0000000..b99c2ac --- /dev/null +++ b/data/README.md @@ -0,0 +1,3 @@ +This directory should contain at least 5 sample source programs in your +language. The sample programs should cover the constraints listed above +in the instructions. \ No newline at end of file diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..6b4be89 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,5 @@ +A PDF copy of your PowerPoint presentation that provides complete +language description and intermediate form definition. A text file +named contribution.txt which details the specific individual +contribution that each member of the team has made in the project. This +file should be updated regularly over the duration of the project. \ No newline at end of file diff --git a/doc/contribution.txt b/doc/contribution.txt new file mode 100644 index 0000000..da2981f --- /dev/null +++ b/doc/contribution.txt @@ -0,0 +1,3 @@ +| DATE | GitHub Handle | Name | Summary of Contribution | +|------|---------------|------|-------------------------| +| 2022-03-31 | @jhale1805 | Joseph Hale | Formalized initial version of `grammar.md` | \ No newline at end of file diff --git a/doc/grammar.md b/doc/grammar.md new file mode 100644 index 0000000..0c22cf8 --- /dev/null +++ b/doc/grammar.md @@ -0,0 +1,81 @@ +// Initial Definitions +`identifier` := \w+(-\w+)* +`identifier_answer` := answer + +`block` := `assignment` \n +`block` := `assignment` \n `block` +`block` := `print_statement` \n +`block` := `print_statement` \n `block` + + +// Requirement 1a +`boolean` := true +`boolean` := false +`expression_boolean` := `expression_boolean` and `expression_boolean` +`expression_boolean` := `expression_boolean` or `expression_boolean` +`expression_boolean` := not `expression_boolean` + + +// Requirement 1b +`number` := [0-9]+(\.[0-9]+)? + +`expression` := `number` +`expression` := `boolean` +`expression` := `string` +`expression` := `identifier` +`expression` := `ternary` +`expression` := `function_call` +`expression` := `expression` plus `expression` +`expression` := `expression` minus `expression` +`expression` := `expression` times `expression` +`expression` := `expression` divided-by `expression` + + +// Requirement 1c +`string` := `identifier` +`string` := `identifier` `string` + + +// Requirement 2 +`assignment` := `identifier` equals `expression` +`assignment_answer` := `identifier_answer` equals `expression` + + +// Requirement 3a +`ternary` := `expression` if `expression_boolean` otherwise `expression` + + +// Requirement 3b +`if_statement` := if `expression_boolean` \n `block` \n move-on +`if_statement` := if `expression_boolean` \n `block` \n otherwise \n `block` \n move-on +`if_statement` := if `expression_boolean` \n `block` \n otherwise `if_statement` \n move-on + + +// Requirement 4a +`loop_for` := for `identifier` from `identifer` \n `block` \n repeat + + +// Requirement 4b +`loop_while` := while `expression_boolean` \n `block` \n repeat + + +// Requirement 4c +// TODO - I'm thinking that "range(2,5)" could be a function that returns an iterable collection. That's how Python does it... + + +// Requirement 5 +`print_statement` := show-value-of `identifier` + + +// Other Features: Functions +`argument` := `identifier` +`argument_list` := `argument` +`argument_list` := `argument` with `argument_list` + +`function_definition` := `identifier` needs `argument_list` \n `block` \n `assignment_answer` \n + +`function_call` := `identifier` of `argument_list` + + +// Other Features: Comments +`comment` := fyi `string` \n \ No newline at end of file diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..4969545 --- /dev/null +++ b/src/README.md @@ -0,0 +1,5 @@ +Source directory src that includes subdirectories compiler and runtime. +Include the language source files in these sub-directories. If you use +tools such as flex or bison, include their input files in these +directories. Make sure that all the source files have comment headers +indicating the authors, purpose, version and date. \ No newline at end of file -- 2.51.2