Merge branch 'master' of git.xeserv.us:victorvalenca/platypus

This commit is contained in:
Victor Fernandes 2017-03-06 10:59:20 -05:00
commit 214b6a49cd
3 changed files with 177 additions and 81 deletions

63
.gitattributes vendored Normal file
View File

@ -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

View File

@ -2,147 +2,152 @@
## 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
```
<input character> ->
``` bnf
<input character> ::=
ASCII characters but not SEOF
<input> ->
<input> ::=
<input elements> SEOF
<input elements> ->
<input elements> ::=
<input element> | <input elements> <input element>
<token> ->
<token> ::=
<variable identifier> | <keyword> | <floating-point literal>
| <integer literal> | <string literal> | <separator> | <operator>
```
### 2.2 White Space
```
<white space> ->
<white space> ::=
ASCII SP character (space)
| ASCII HT character (horizontal tab)
| ASCII VT character (vertical tab)
| ASCII FF character (form feed)
| <line terminator>
<line terminator> ->
<line terminator> ::=
CR | LF | CR LF
```
### 2.3 Comments
```
<comment> ->
<comment> ::=
!< <opt_characters in line> <line terminator>
<characters in line> ->
<characters in line> ::=
<comment character> | <characters in line> <comment character>
<comment character> ->
<comment character> ::=
<input character> but not <line terminator>
```
### 2.4 Variable Identifiers
```
<variable identifier> ->
<variable identifier> ::=
<arithmetic variable identifier> | <string variable identifier>
<arithmetic identifier> ->
<arithmetic identifier> ::=
<letter> <opt_letters or digits>
<letters or digits> ->
<letters or digits> ::=
<letter or digit> | <letters or digits> <letter or digit>
<letter> -> one of
<letter> ::= one of
[a-z][A-Z]
<letter or digit> -> one of
<letter or digit> ::= one of
[a-z][A-Z][0-9]
<string variable identifier> ->
<string variable identifier> ::=
<arithmetic variable identifier>#
```
### 2.5 Keywords
```
<keyword> ->
<keyword> ::=
PLATYPUS | IF | THEN | ELSE | USING | REPEAT | INPUT | OUTPUT
```
### 2.6 Integer Literals
```
<integer literal> ->
<integer literal> ::=
<decimal integer literal> | <octal integer literal>
<decimal integer literal> ->
<decimal integer literal> ::=
0 | <non-zero digit> <opt_digits>
<digits> ->
<digits> ::=
<digit> | <digits> <digit>
<digit> ->
<digit> ::=
0 | <non-zero digit>
<non-zero digit> -> one of
[1-9]
<non-zero digit> ::= one of
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<octal integer literal> ->
<octal integer literal> ::=
0 <octal digit> <octal digits>
<octal digit> ->
<octal digit> ::=
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
<octal digits> ->
<octal digits> ::=
<octal digit> | <octal digits> <octal digit>
```
### 2.7 Floating-point Literals
```
<floating-point literal> ->
<floating-point literal> ::=
<decimal integer literal> . <opt_digits>
```
### 2.8 String Literals
```
<string literal> ->
<string literal> ::=
"<opt_string characters>"
<string chacters> ->
<string chacters> ::=
<input character> | <string characters> <input character>
```
### 2.9 Separators
```
<separator> -> one of
( ) { } , ; " .
<separator> ::=
( | ) | { | } | , | ; | " |.
```
### 2.10 Operators
```
<operator> ->
<operator> ::=
<arithmetic operator> | <string concatenation operator>
| <relational operator> | <logical operator>
| <assignment operator>
<arithmetic operator> -> one of
+ - * /
<arithmetic operator> ::=
+ | - | * | /
<string concatenation operator> -> one of
> < == <>
<string concatenation operator> ::=
<<
<logical operator> ->
<relational operator> ::=
> | < | == | <>
<logical operator> ::=
.AND. | .OR.
<assignment operator> ->
<assignment operator> ::=
=
```
## 3. The PLATYPUS Syntatic Specification
## 3. The PLATYPUS Syntactic Specification
### 3.1 PLATYPUS Program
```
<program> ->
<program> ::=
PLATYPUS {<opt_statements>} SEOF
<statements> ->
<statements> ::=
<statement> | <statements> <statement>
```
### 3.2 Statements
```
<statement> ->
<statement> ::=
<assignment statement>
| <selection statement>
| <iteration statement>
@ -151,59 +156,59 @@
```
### 3.3 Assignment Statement
```
<assignment statement> ->
<assignment expression>
<assignment statement> ::=
<assignment expression> ;
<assignment expression> ->
AVID = <arithmetic expression>
| SVID = <string expression>
<assignment expression> ::=
<arithmetic variable identifier> = <arithmetic expression>
| <string variable identifier> = <string expression>
```
#### 3.2.2 Selection Statement (`if` statement)
```
<selection statement> ->
IF (<conditional expression>) THEN <statements>
<selection statement> ::=
IF (<conditional expression>) THEN <opt_statements>
ELSE {<opt_statements>};
```
#### 3.2.3 Iteration Statement (the loop statement)
```
<iteration statement> ->
<TBC>
<iteration statement> ::=
USING (<assignment expression> , <conditional expression>, <assignment expression>) REPEAT { <opt_statements> };
```
#### 3.2.4 Input Statement
```
<input statement> ->
<input statement> ::=
INPUT (<variable list>);
<variable list> ->
<variable list> ::=
<variable identifier> | <variable list>,<variable identifier>
```
#### 3.2.5 Output Statement
```
<output statement> ->
<TBC>
<output statement> ::=
OUTPUT(<opt_variable list> | <opt_string literal>);
```
### 3.3 Expressions
#### 3.3.1 Arithmetic Expressions
```
<arithmetic expression> ->
<arithmetic expression> ::=
<unary arithmetic expression>
| <additive arithmetic expression>
<unary arithmetic expression> ->
<unary arithmetic expression> ::=
- <primary arithmetic expression>
| + <primary arithmetic expression
<additive arithmetic expression> ->
<additive arithmetic expression> ::=
<additive arithmetic expression> + <multiplicative arithmetic expression>
| <additive arithmetic expression> - <multiplicative arithmetic expression>
| <multiplicative arithmetic expression>
<multiplicative arithmetic expression> ->
<multiplicative arithmetic expression> ::=
<multiplicative arithmetic expression> * <primary arithmetic expression>
| <multiplicative arithmetic expression> / <primary arithmetic expression>
| <primary arithmetic expression>
<primary arithmetic expression> ->
<primary arithmetic expression> ::=
<variable identifier>
| <floating-point literal>
| <integer literal>
@ -211,42 +216,42 @@
```
#### 3.3.2 String Expression
```
<string expression> ->
<string expression> ::=
<primary string expression>
| <string expression> << <primary string expression>
<primary string expression> ->
<primary string expression> ::=
<string variable identifier>
| <string literal>
```
#### 3.3.3 Conditional Expression
```
<conditional expression> ->
<logical OR expression>
// 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
<conditional expression> ::=
<logical OR expression>
<logical OR expression> ->
<TBC>
<logical OR expression> ::=
<logical AND expression>
| <logical OR expression> .OR. <logical AND expression>
<logical AND expression> ->
<TBC>
<logical AND expression> ::=
<relational expression>
| <logical AND expression> .AND. <relational expression>
// END BNF from C specification
```
#### 3.3.4 Relational Expression
```
<relational expression> ->
<primary a_relational expression> == <primary a_relational expression>
| <primary a_relational expression> <= <primary a_relational expression>
| <primary a_relational expression> > <primary a_relational expression>
| <primary a_relational expression> < <primary a_relational expression>
| <primary s_relational expression> == <primary s_relational expression>
| <primary s_relational expression> <= <primary s_relational expression>
| <primary s_relational expression> > <primary s_relational expression>
| <primary s_relational expression> < <primary s_relational expression>
<relational expression> ::=
<primary a_relational expression> <relational operator> <primary a_relational expression>
| <primary s_relational expression> <relational operator> <primary s_relational expression>
<primary a_relational expression> ->
<primary a_relational expression> ::=
<floating-point literal>
| <integer literal>
| <variable identifier>
<primary s_relational expression> ->
<TBC>
<primary s_relational expression> ::=
<string literal>
| <string variable identifier>
```

28
buffer/buffer.sln Normal file
View File

@ -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