Repository navigation
Duck 2.0
Greg Tourville edited this page Sep 24, 2015
·
7 revisions
<program> ::= <stmtlist>
<stmtlist> ::= <stmt> <stmtlist>
::= <epsilon>
<identifier-list> ::= <identifier> , <identifier-list>
::= <identifier>
<stmt> ::= import <identifier-list> <endl>
::= include <string>
::= <expr> <endl>
::= <endl>
::= <assignment> <endl>
::= <self-assignment> <endl>
::= <function-def> <endl>
::= <if> <endl>
::= <for-loop> <endl>
::= <for-each> <endl>
::= <while-loop> <endl>
::= <do-while> <endl>
::= <let-block> <endl>
::= <try-block> <endl>
::= <class> <endl>
::= static <assignment>
::= static <function-def>
::= return <endl>
::= return <expr> <endl>
::= break <endl>
::= continue <endl>
::= throw <expr> <endl>
<assignment> ::= <l-value> = <condition>
<self-assignment> ::= <l-value> += <arithmetic>
::= <l-value> -= <arithmetic>
::= <l-value> *= <arithmetic>
::= <l-value> /= <arithmetic>
::= <l-value> ++
::= <l-value> --
<function-def> ::= func <function-decl>
<function-decl> ::= <identifier> <parameters> <endl> <stmtlist> end
::= <string> <parameters> <endl> <stmtlist> end
<class> ::= class <identifier> <opt-extends> <parameters> <endl> <stmtlist> end
<parameters> ::= ( )
::= ( <param-decl> )
::= <epsilon>
<param-decl> ::= <identifier>
::= <identifier> , <param-decl>
<opt-extends> ::= : <identifier-list>
::= <epsilon>
<if> ::= if <condition> then <endl> <stmtlist> <elseif>
<elseif> ::= else <endl> <stmtlist> endif
::= else <if>
::= endif
<for-loop> ::= for <identifier> = <arithmetic> to <arithmetic> <step>
<step> ::= step <arithmetic> do <endl> <stmtlist> loop
::= do <endl> <stmtlist> loop
<for-each> ::= for <identifier> in <expr> do <endl> <stmtlist> loop
<while-loop> ::= while <condition> do <endl> <stmtlist> loop
<do-while> ::= do <endl> <stmtlist> loop while <condition>
<let-block> ::= let <bindings> begin <endl> <stmtlist> end
<bindings> ::= <identifier> = <expr> , <bindings>
::= <identifier> = <expr>
<try-block> ::= try <endl> <stmtlist> <catch-block>
<catch-block> ::= catch <l-value> <endl> <stmtlist> done
::= done
<l-value> ::= <identifier>
::= ( <l-value> )
::= <reference> . <identifier>
::= <reference> [ <expr> ]
<expr> ::= <condition>
<condition> ::= <condition> and <logic>
::= <condition> or <logic>
::= <logic>
<logic> ::= not <comparison>
::= <comparison>
<comparison> ::= <comparison> == <arithmetic>
::= <comparison> != <arithmetic>
::= <comparison> \< <arithmetic>
::= <comparison> > <arithmetic>
::= <comparison> \<= <arithmetic>
::= <comparison> >= <arithmetic>
::= <final> is <reference>
::= <final> is not <reference>
::= <arithmetic>
<arithmetic> ::= <arithmetic> + <term>
::= <arithmetic> - <term>
::= <term>
<term> ::= <term> * <factor>
::= <term> / <factor>
::= <term> mod <factor>
::= <factor>
<factor> ::= - <factor>
::= ! <factor>
::= * <factor>
::= <final>
<final> ::= ( <expr> )
::= <boolean>
::= <object>
::= <reference>
::= new <reference>
::= <integer>
::= <float>
::= <string>
<reference> ::= <l-value>
::= this
::= <reference> ( )
::= <reference> ( <arguments> )
<arguments> ::= <arguments>, <expr>
::= <expr>
<object> ::= [ ]
::= [ <array-init> ]
::= [ <dictionary-init> ]
<array-init> ::= <array-init> , <expr>
::= <expr>
<dictionary-init> ::= <dictionary-init> , <identifier> : <expr>
::= <identifier> : <expr>
<boolean> ::= true
::= false
Edits: Add local and global keywords. Modify use of static. Add require(s) keyword.
Language Changes
- include function for module building
- import multiple libraries
- self-assignment operators: ++, --, +=, -=, *=, /=
- syntax: changed function->func, new endif keyword
- added for-each loops
- added step parameters in for loops
- added do/while loops
- added let expressions for local variable scope
- added exceptions
- added try / catch / done for exception handling
- added throw keyword
- void return is now allowed
- functions can have string identifiers (explained later)
- added classes as a native feature
- removed bitwise operators
- added
modas a builtin operator - added
isandis notconditionals for checking class type - added
newandthiskeywords - replaced dictionary syntax with array syntax
- support for operator overloading
Operator Overloading Functions with string identifiers can be used for operator overloading.
The keywords are:
"++""--""+""-""*""/""!""mod"".""()""[]""bool""toString""serialize""unserialize""len"
- exception type
- handle = file.open(file, mode)
- handle = file.openw(file)
- handle = file.openr(file)
- handle.read()
- handle.write()
- handle.read_binary()
- handle.write_binary()
- Serialize(object, mode) ; binary or string
- LoadSerial(text, mode)
- len(string)
- string[a] accessing
- string.substr(a, b, c)
- connect
- server
- etc.
- TCP, UDP, HTTP, FTP, HTTPS
- SSL, TSL
- Make window
- Forms
- etc.
- Make page, display page, manipulate page
- For JavaScript built-in runtime
- Make server pages and forms
- Crossover with graphical user interface
- BigNum, BigInteger
- Matrix
- Vector
- Quaternion
- DES
- RSA
- SHA
- AES
- MD5
- and
- or
- xor
- complement
- shift
Existing:
- Improvements
- Operator overloading
- User defined types / Custom types
- Creating instanced objects
- Memory management core
- Special C macros for library writing
- Bindings
- Build system for import and require
- Potentially using dynamic linking, or build options

Duck Programming Language