Jump to content


Dave-ee Jones

Member Since 19 Jan 2013
Offline Last Active Nov 17 2017 02:35 AM
-----

Topics I've Started

Shark - A site browser for CC

01 November 2017 - 04:45 AM

Shark
By Dave-ee Jones



What's Shark?
Shark is a web browser made for CC.
It uses similar methods to a normal browser, however there are a few differences.

Shark Language
No, I will not pretend to be a shark-talking version of Dory.

Shark has it's own language for pages. When you access an external site all the pages will be written in SL. A file that contains SL is called an 'SLS', or Shark Language Sheet. A line of SL is called a 'SLL', or Shark Language Line. Shark Language is quite similar to HTML and (fairly) easy to write and understand.

Shark Language is executed line by line, just like Lua.

Sharkles
URLs are replaced with Sharkles. Sharkles look similar to URLs but their format is a little different. Here's an example of a Sharkle:
local://home/

You may notice that instead of 'http://' it has 'local://'. This part of the Sharkle is known as the 'hostname' (or, more simply, 'id' or 'host'). It tells Shark where to look for the page you are looking for.
'local' and 'localhost' tell Shark to look for pages on your local machine.

External Sites
You can also tell Shark to use a computer ID instead. For example:
2://example/

The above code tells Shark to ask the computer that has the ID 2 for the index page of the site 'example'. Sounds like a mouthful, but it's actually very simple.

Shark also uses a variation of host resolving, and it does so with a file that contains a table. This file is known as the HRF, or Host Resolution File. In this file you can specify what hostnames should go to what computer ID. Here's an example:
{
["jack"] = 2,
["boss"] = 0,
["house"] = 1
}

Using the above table, if I type the following into the Sharkle, Shark can convert this to a computer ID so it can talk to the computer and grab details of the site, like so:
house://example/
--# CONVERTS TO
1://example/

Error Handling
Shark has it's own error codes to deal with Sharkle errors. If it can't find a site, page or host it will let you know by taking you to the error page with relevant information.

It also logs all errors - even if it crashes Shark.

Sites
You can create your own sites, using Shark's own language. Refer to the wiki for more information.

History
Everytime you visit a site it is logged to the history file with the local MC time (useful, I know).





Download and Install


For downloads, look to the Github!


Install instructions are incredibly simple and can be found in the README in the VERSION 1 folder.



MORE INFORMATION AND DETAILS CAN BE FOUND ON THE SHARK GITHUB.


load() file in current environment?

24 October 2017 - 09:52 PM

Hoi!

This question might seem really complicated in the title, but it's not. Sorry, I couldn't find the words to describe this problem.

So, I've got a file that needs to be run in another file's context. E.g.

File 1 declares this variable and loads File 2's contents and runs them.
local LOCALS = {}
local file2 = loadfile(file2)
file2()

File 2 references an index in that variable:
if LOCALS["test"] == "this is a test" then
  print("True!")
else
  print("False!")
end

But it just comes up with this error:
string:1: attempt to index ? (a nil value)

Obviously because it doesn't recognise the 'LOCALS' table. I don't want to make everything global, so how can I run File2 as if it was part of File1's code (without putting that code in File1) so that it does recognise File1's variables?

I would assume this has been answered before because it seems like a pretty obvious question in some cases..Unless not?

Anyway, any help would be appreciated! :)

Deleting whitespace at start of string but not at end

13 October 2017 - 05:21 AM

Hoi!

So, I've got my programming language parser working pretty mint but then realised that it's removing the whitespace on the end of a line. So if I've got a snippet that looks like this:
<color[red,white]>
<write>
  hey!
  what's up?
</write>
</color>

And I have a space write after 'hey!' on the same line (e.g. 'hey! ') then it will remove the space after 'hey!', which is what I don't want because I want 'what's up?' to appear a space after 'hey!', if you catch my drift.

Here's my current whitespace-removing-technique:
_line:match("^%s*(.-)%s*$")

It removes the whitespace line-by-line.

Any help is appreciated. I'm assuming it's just an alteration to the current 'string:match(..)' I have, but since I'm not familiar with the character codes I cannot figure it out myself (maybe remove '(.-)%s*$' at the end?).

The Progress of Shark (and co.)

06 October 2017 - 12:46 AM

Hoi!

I'm working on a programming language for a browser I'm making. It's...interesting...made more of parsing than anything else, really. Very hard, but almost..captivating.

The language will seem quite familiar with a bit of a twist for better argument handling (well, for Lua anyway).
Here's a quick example:
<color['blue','lightBlue']>
  <print['3','3']>
	OI, RED!
	<color['red','orange']>
	   WHAT?
	</color>
	Oh, nothing.
  </print>
</color>
Guess what's it's based off :P
The arguments for 'color' is pretty self explanatory, but the 'print' command's arguments are the starting X and Y position of the text. Also, the text has a CONTINUING X position, but obviously not Y otherwise it would overwrite the old text in that same spot (if you were to have multiple lines).

It's pretty cool, could be really powerful for UI creation (having <button>, <checkbox> etc.). Things like <center> or <column> may be a bit harder, though, but it's definitely worth a shot.

It's currently working quite well. My parsing program (called 'Shark' at the moment) runs that snippet of code up there, outputting this:

Quote

OI, RED! (pretend there's a light blue background on this text)
WHAT? (pretend there's an orange background on this text)
Oh, nothing. (pretend there's a light blue background on this text)
Notice how you can have tags inside <print>'s and <write>'s.

The main reason I'm creating this 'Shark Language' (.sls files - standing for Shark Language Sheet) is for a browser I'm working on (similar to Thunderbird/Firewolf but obviously not as great). It'll be used for websites/pages.

Anyway, just felt like sharing what I'm working on and how it's going, because it's my first time creating a language parsing program and it's pretty exciting. :D

VM Error: Array index out of bounds

05 October 2017 - 05:30 AM

Hoi!

Yes, I know we've seen this error before.
Yes, I know this is probably going to be super obvious and I'm probably going to realise it as soon as I post this.

But anyway, the line is line 90 where it says:
n_ARG_START = _LINE:find("[")

n_ARG_START is called earlier to make it local (it's inside an if statement).
_LINE looks like this:
_LINE = "<color['blue']>"
which is passed to the function the if statement is under, so it's local as well. For some reason it thinks it's out of index even though there is clearly a '[' there, and it's not an array..

I've tested to make sure it is actually that line by putting print functions before and after it, and yes it is that line.

Any ideas? I'm happy to post more code if needed, but there shouldn't be anything else affecting it.