flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
sleepsleep 27 Jun 2013, 10:10
i think i want to join you,
build my own fasm linux shell too!! wow, interesting idea! |
|||
![]() |
|
typedef 27 Jun 2013, 11:36
Use hashes.
For example. Code: ; Hash function for Strings in JAVA. function hash, string_cmd { h = 0; for(c in string_cmd){ h = h * 31 + c; } return h; } ; Define a table of hashes to look up hashes: .cd dd 0x12345 .exec dd 0x6789A Then you get the string to the left of the first space and hash it. Walk the hash table (you can pre-sort your hash table also and use binary search for performance). The index the hash was found at is the index to a function table for that command. Any other strings after the space will be treated as parameters. So. Code: >> Enter command: cd "usr/bin" i = find_index(hash("cd")) if i >= 0 call_fn_by_index, i, substr(strstr("cd ")+1) ; get everything after 1st space else print "Command not found" endif |
|||
![]() |
|
revolution 27 Jun 2013, 11:45
Hashes don't allow partial matching. For unambiguous inputs you can use shortened entry if you do standard text scanning matches. Saves typing.
Hashes just confuse things and make source code more difficult to follow and/or understand IMO. Keep it simple, just do normal string comparisons. |
|||
![]() |
|
sleepsleep 27 Jun 2013, 13:08
i only want my shell to support maximum 5 or 7 chars command,
and i want my shell to function in 2 window, 1 command window 1 info window the screen will split into half, maybe 3 (3 is great number) press hold [space] + j will do window jump lots of ideas actually, press hold [space] + d will do directory listing maybe, logical short cut for logical tasks, aim is, short cut, as it introduces some sort of easier way (hopefully) and give users a sense that they got something new, and push them to explore a different way to control a system. |
|||
![]() |
|
cod3b453 27 Jun 2013, 17:10
You'll always have a "string"->code mapping the question is how complex you want your syntax to be. If you want the same level of power as bash et al. I'd recommend you look at using LALR(1) parsing; this is more complex but works well when you have a large grammar*. Instead of a simple <string,pointer> pair, you have a state machine that processes the command line - basically lots of lookup tables and switch statements that accept or reject the line.
*You can get tools that help in constructing rules and testing them such as GOLD (http://goldparser.org/); yacc and bison might have something similar ![]() |
|||
![]() |
|
gens 29 Jun 2013, 23:50
thx for the tips people
LALR looks interesting shell scripts are mostly just sequential logic thou, with a couple variables (dont have nothing to patch variables either) sleep, its not that hard to make a shell basically its setup the environment, bit of text processing then fork+exec things like split "screen" and such is just manipulating the console with escape characters (check ncurses) |
|||
![]() |
|
sleepsleep 30 Jun 2013, 03:35
thanks gens,
one idea just struck me, i dont want to ENTER in my shell, eg, cp /a1 /a2 during the spacebar,eg, # cp[spacebar] # options:-a -b -c -d -e -f [-a]:[spacebar] # options:-a -b -c -d -e -f [-a]:?-a[spacebar] // to know more about -a switch info ~ will dump the info in info window. # source : /a1[spacebar] # destination : /a2[spacebar] this works like a wizard shell, since [spacebar] is a must pressed key in classic shell, why not implement it wizard mode. |
|||
![]() |
|
gens 30 Jun 2013, 18:15
that would get annoying fast when you have hundreds of files
![]() but you can do it np, you'd just have to do it for every program maybe better just displaying a help box in the top right corner or something if you plan to do a linux shell, you'ld probably have to read (some) POSIX specs POSIX among other things specifies just that switches for standard UNIX programs (ls, cd, cp etc.) so its easy to know without help (also theres mc) bdw, most terminals support mouse clicking |
|||
![]() |
|
sleepsleep 01 Jul 2013, 00:05
maybe it would probably works as linux beginner wizard shell,
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.