Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
18 June, 2013, 08:51:21 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 ... 6 7 [8] 9 10 11   Go Down
  Print  
Author Topic: Antelope (formerly "OPIA") - A Polymorphic z80 language -  (Read 5564 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
shkaboinka
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 27 October, 2012, 10:26:56
Date Registered: 15 July, 2011, 15:14:52
Location: Spokane, WA
Posts: 83

Topic starter
Total Post Ratings: +9

View Profile WWW
« Reply #105 on: 10 May, 2012, 03:28:16 »
0

By byte- and uint-prefixed strings, do you mean that number would be the length of the string?

Correct:
"banana" // .db "banana",0
r"banana" // .db "banana"
b"banana" // .db 6,"banana"
i"banana" // .db 6,0,"banana" ;z80 is "Little-Endian"
« Last Edit: 27 May, 2012, 03:12:22 by shkaboinka » Logged
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Total Post Ratings: +43

View Profile
« Reply #106 on: 10 May, 2012, 03:39:19 »
0

Alright, that's what I thought. Everything seems good to me!
Logged
shkaboinka
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 27 October, 2012, 10:26:56
Date Registered: 15 July, 2011, 15:14:52
Location: Spokane, WA
Posts: 83

Topic starter
Total Post Ratings: +9

View Profile WWW
« Reply #107 on: 26 May, 2012, 06:10:24 »
+1

Ok, I've basically finalized all the (more than very trivial) language issues ... I am just going to repost:

Some final notes before I begin in (May or June?). THESE ARE DECIDED (tentatively):

The new numeric datatypes are byte, sbyte, int, and uint.

String literals can take on different forms:
::: "null terminated string"
::: b"byte-prefixed string"
::: i"int-prefixed string"
::: r"raw string"

Numeric literals are of type "int" by default. Type-casts can be used to be explicit: (byte)5;
Hexadecimal and Binary literals are prefixes with 0x and 0b, respectively, and default to type "byte" or "uint" types according to the number of digits used (so as to reflect a literal bit representation).

Dereferencing is now on the right-side:
::: *[]byte pa;    (*pa)[idx];
::: []*byte ap;    *(ap[idx]); // or just *ap[idx]

Constant (immutable) variables are defined with "const" in addition to the datatype.
Constant expressions (pasted in like macros) are defined with "const" alone.
It is illegal to mix "const" or "volatile" with the ":=" operator.

There are standard-, BASIC-, and iterator-style for-loops:
::: for(init; condition; update)
::: for(var: start, end, inc) (inc is optional)
::: for(var: array); for(var: someYieldyCofunc)

The inferred type of an array literal works as follows:
::: []T{...} = A static array of the given values
::: &[]T{...} = Pointer to the given static array
::: new [n]T = Pointer to a new (uninitialized) array allocation
::: new []T{...} = Pointer to a new array allocation (values copied from static array)

Arrays with the (first) dimension omitted ([]T or [,n]T) are pointers.
Arrays of the form [ , ,...] are rectangular (stored in one static allocation).
Arrays of the form [][][]... are jagged (the "inner" arrays are stored as pointers).
Arr[3..6] is a shorthand for the tuple expression (Arr[3], Arr[4], Arr[5]).
Tuples will remain "auto-unpacked", and no tuple-variables allowed.

Method receivers ("this") are ALWAYS (intrinsic) pointers.

Methods may be defined within structs, just as in Java/C# (compact/familiar).

There will be an "x@value" syntax for embedding variables within array literals.

Addressing goes on the LHS and applies to the whole RHS (e.g. &a[n] is &(a[n])).

Entities may not be defined within each other (e.g. no structs within structs, etc.).

Expressions cannot contain statements (declarations, assignments, calls, var++/var--).

Anonymous functions may may not refer to (non- static/const) external local variables.

All code is precomputed as much as possible (without unrolling loops or recursive calls).

The $ operator Requires something to be interpreted, including loops and recursive calls.

Bridge methods will be inserted for multiple "inheritance" of anonymous fields, as needed.

Control-flow constructs will indeed require parenthesis (avoids parsing conflicts with literals).

No "static" members of anything (but static local vars and static initialization blocks are allowed).

Entites Have Global Accessibility If They Are Capitalized, and namespace accessibility otherwise.

Look-Up-Tables (rather than Jump Tables) will be used with switches and if-else chains as possible.

Methods can only be defined for "identifier" types (structs, primitives, etc., but not funcs, arrays, etc.).

Namespaces may be nested ("Outer.Inner" syntax), and there will be a "using Namespace" mechanism.

Self-Modifying code will be used with cofuncs and switch-variables (Will consider an option to disable it).

Explicit variable addresses can be nominal (@"address") or refer to another variable (@x or @arr[n].foo).

No exception-handling or "try-catch" mechanism (use multiple return values or create an "Exit()" instead).

Type-casts will be represented traditionally (e.g. "(byte)(a+b)").

"Extra" Parenthesis are not allowed within datatypes ("func(...)" requires them, but []*T are *[]T are unambiguous).

Function pointers without any return values may point to functions with return values (e.g. func(byte) pointing to func(byte):byte).

Values will be passed/returned in registers such that any two functions with the same pattern of arguments will use the same registers for them.

Default arguments (and struct members) must come last, and will be embedded in functions so they can be pointed-to as their reduced versions.

An anonymous (nameless) struct/interface/cofunc/func within a namespace will take on the name of the namespace (e.g. "List myList" rather than "ListNameSpace.ListStruct myList"). This also gives namespace values ("List.staticValue") the feel of Java/C#'s static class members.
« Last Edit: 27 May, 2012, 03:11:22 by shkaboinka » Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 08:49:37
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50600


Total Post Ratings: +2634

View Profile WWW
« Reply #108 on: 26 May, 2012, 06:20:26 »
0

I didn't check everything out, but is for(init; condition; update) kinda like the start value, then a boolean condition (eg A == 50) then the operation to do if it is (and exiting the loop)?

When stuff is finalized about the language itself, it would be great if you made some document to include with OPIA release that gave syntax examples of the language. (If you ever have a site about the language doc, animated screenshots + program examples would definitively be cool too.
« Last Edit: 26 May, 2012, 06:22:11 by DJ_O » Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
shkaboinka
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 27 October, 2012, 10:26:56
Date Registered: 15 July, 2011, 15:14:52
Location: Spokane, WA
Posts: 83

Topic starter
Total Post Ratings: +9

View Profile WWW
« Reply #109 on: 26 May, 2012, 22:46:57 »
0

I plan on re-documenting the language once it is done or underway. I do want it to be a concise reference, but I will probably give better (more realistic) examples. The compiler will only be a command-line interface, so there will not be anything visual to show for. However, this will allow it to be integrated into whatever other program (like how different things link into Notepad++, etc.). I will probably make a visual editor; but this way the core language/compiler (and all of it's inner modules) stay modular / pluggable.
Logged
shkaboinka
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 27 October, 2012, 10:26:56
Date Registered: 15 July, 2011, 15:14:52
Location: Spokane, WA
Posts: 83

Topic starter
Total Post Ratings: +9

View Profile WWW
« Reply #110 on: 17 June, 2012, 07:35:14 »
0

I am putting together the Grammar for OPIA, as can be seen in the link below. The compiler will have a portion of syntax-tree-building code corresponding to each rule. In the past, I've made different "versions" of similar rules so that they can work properly in their respective contexts (e.g. variable declarations follow a preset form, but have different restrictions in global, local, and object-member contexts). HOWEVER, my plan this time is to leave the rules more broad (e.g. use the same rule for "lists" of values as function arguments, array values, and variable declarations), but then inspect the contents of the resulting syntax structures to make sure that they are consistent with the context (e.g. variable declarations can contain a "list" of "assignments", but assignments are not allowed within other expressions; Function declarations take a list of variable declarations for arguments, but function pointers take a list of JUST datatypes; etc.). This will also allow complex portions of code to be parsed correctly, even when placed in a context which would otherwise not now what to do with it (which means better error messages). For this reason, I am starting the rules in a very general sense by using "E" values as a placeholder until I narrow everything down.

PLEASE LOOK AT THE GRAMMAR IF YOU CAN: Feedback will be GREATLY appreciated as I work on them, and will help ensure that OPIA's compiler is designed well (and sooner). Here are some new links, along with the link to the grammar:

Intro: http://tinyurl.com/z80opia
Overview: http://tinyurl.com/z80opiaO
Grammar: http://tinyurl.com/z80opiaG
Logged
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Total Post Ratings: +43

View Profile
« Reply #111 on: 17 June, 2012, 18:21:16 »
0

Are you using something like ANTLR, or are you making a custom parser?
Logged
Matrefeytontias
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 22:04:38
Date Registered: 14 October, 2011, 18:48:49
Location: Alone in the Park
Posts: 889


Total Post Ratings: +185

View Profile
« Reply #112 on: 17 June, 2012, 18:33:13 »
0

Do you have the compiler working ? Can you post an example of code and its executable ?
Logged

/\   ><   [-   |_|   _\~   [-   /?

Spoiler for Nerdiness:



Spoiler for Shameful self-advertising:
/image/37571.png[/img]
If at a certain moment you think that I'm awesome, give an internet (>^_^)>
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Total Post Ratings: +43

View Profile
« Reply #113 on: 17 June, 2012, 18:34:10 »
0

He's only on the grammar right now, so no, the compiler is not currently working.
Logged
shkaboinka
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 27 October, 2012, 10:26:56
Date Registered: 15 July, 2011, 15:14:52
Location: Spokane, WA
Posts: 83

Topic starter
Total Post Ratings: +9

View Profile WWW
« Reply #114 on: 18 June, 2012, 00:11:06 »
0

Everything will be custom-written. In the past, I've kinda cowboy'd it and written classes for function-, class-, etc.- entities and worked down from there. However, this time I am making a clear grammar first, and even going as far as listing what kinds of classes will be needed to represent each. Compiler tools are great, but it is entirely practical, legit, and rewarding to actually make the compiler yourself. I will likely do that from start to finish, though I MIGHT consider something for optimizing intermediate ("3 instruction") code.

Once I have all the grammar rules down (along with additional semantic rules and associated classes), coding it will be a snap -- most rules will translate directly to code (though similar ones might use the same code with a branch in it).
Logged
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Total Post Ratings: +43

View Profile
« Reply #115 on: 18 June, 2012, 00:18:24 »
0

Yeah, that's what I'm doing with my compiler. I was using ANTLR, but I wasn't satisfied with its error reporting for the C# port, so I decided to write everything myself. I love the freedom of being able to customize everything. My lexer is done, and I'm working on the parser right now. My only problem is I don't have an exact syntax for it yet lol.

I took a quick look at your grammar before, and it looks good so far. I'll be able to take a better look at it later, though.
Logged
shkaboinka
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 27 October, 2012, 10:26:56
Date Registered: 15 July, 2011, 15:14:52
Location: Spokane, WA
Posts: 83

Topic starter
Total Post Ratings: +9

View Profile WWW
« Reply #116 on: 18 June, 2012, 00:28:31 »
0

Ooh... Can I have a look at it sometime? At least eventually, I'd love to swap code. I have not yet come across somebody actively coding a compiler, and I'd like to compare approaches / techniques. All I have in place right now though is the Tokenizing and Preprocessing; though I am thinking about redoing some of that as well for modularization reasons.
Logged
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Total Post Ratings: +43

View Profile
« Reply #117 on: 18 June, 2012, 00:36:11 »
0

Sure! But yes, now wouldn't exactly be a good time for me either. My code isn't exactly the neatest as of right now. My language doesn't need a preprocessor, but the way I have everything set up, I'd like to think implementing one wouldn't be too hard. Plus my lexer isn't 100% done; it's more like 97%. I just need to add support for decimals / floats and hex.
Logged
shkaboinka
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 27 October, 2012, 10:26:56
Date Registered: 15 July, 2011, 15:14:52
Location: Spokane, WA
Posts: 83

Topic starter
Total Post Ratings: +9

View Profile WWW
« Reply #118 on: 18 June, 2012, 10:12:31 »
0

UPDATE: I basically have all the structural classes (for the syntax tree) figured out now! Cheesy Take a look!
Logged
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Total Post Ratings: +43

View Profile
« Reply #119 on: 18 June, 2012, 18:26:45 »
0

Nice! That's similar to what I'm doing, except I only have statements and expressions. I have a method I created for extracting token patterns that I found is pretty useful, at least for namespaces. Yours is looking good, though! Smiley
Logged
Pages: 1 ... 6 7 [8] 9 10 11   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.298 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.