Skip to content

Commit 0a79542

Browse files
committed
Merge branch 'documentation'
2 parents 1d6538c + 498893f commit 0a79542

File tree

5 files changed

+41
-74
lines changed

5 files changed

+41
-74
lines changed

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Laço
22

3-
A better REPL for lua. This was mainly for luajit because the default
4-
interactive mode, ie. the REPL, was pretty bad. You couldn't move back
5-
and forth in the to edit, and no going through history. With laco you
6-
can actually do that, and I also believe that that regular lua can as
7-
well.
3+
A better REPL for lua. This was created mainly for luajit because the
4+
default interactive mode, better known as the REPL, was pretty bare
5+
bones. You can't move left or right in the current line if wanted to
6+
edit the line, and there is no history for repeating commands easily.
7+
With laco you can actually do that, and I also believe that that regular
8+
lua REPL can as well.
89

910
## Features
1011

@@ -20,20 +21,20 @@ well.
2021
```
2122

2223
* In memory history, so pressing up will go to the previous line.
24+
* Command mode (use `:help` to see the list of commands)
2325

2426
This is still in early development so there isn't much so far, but I
2527
think its enough to use a replacement (atleast for luajit users).
2628

2729
## Laço?
2830

29-
In Portuguese, laco mean loop and since Lua is a Portuguese name and a
31+
In Portuguese, laco mean loop. Since Lua is a Portuguese name, and a
3032
REPL is a read eval print loop, the name was born.
3133

3234
## Building
3335

34-
Since laco depends on [linenoise](https://github.com/antirez/linenoise#tested-with),
35-
I don't think this will work for Windows terminals, but nevertheless,
36-
here are the step on building.
36+
Since laco depends on [linenoise][1], I don't think this will work for
37+
Windows terminals, but nevertheless, here are the step on building.
3738

3839
**Denpendencies (not included):**
3940

@@ -43,7 +44,7 @@ here are the step on building.
4344
**Note**: This is for regular lua, to enable luajit you need to replace.
4445
`cmake ..` with `cmake -DLACO_USE_LUAJIT=on ..`. Also if you are using
4546
anything lua 5.2+, I'm not sure if this will work since I've only tested
46-
on luajit which is currently 5.1
47+
on luajit which is currently 5.1.
4748

4849
```bash
4950
git clone --recursive https://github.com/sourrust/laco.git
@@ -55,3 +56,5 @@ make
5556
```
5657

5758
The binary will be located in `build/bin` and it can be run from there.
59+
60+
[1]: https://github.com/antirez/linenoise#tested-with

src/commands.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
struct LacoState;
55

6+
/**
7+
* Gets passed ever line to see if it matches one of the REPL command. If it
8+
* does, that command will be executed.
9+
*/
610
void handle_command(struct LacoState* laco, char* line);
711

812
#endif /* LACO_COMMANDS_H */

src/flags.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
struct LacoState;
55

66
/**
7-
* Takes the arguments inside of LacoState and executed a flags
8-
* functionality
9-
*
10-
* param pointer to LacoState
7+
* Takes the arguments inside of LacoState and executed any of flags
8+
* functionality when the arguments match.
119
*/
1210
void laco_handle_flag(struct LacoState* laco);
1311

src/laco.h

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,66 +7,39 @@ struct lua_State;
77
typedef struct LacoState LacoState;
88

99
/**
10-
* Makes a new LacoState.
11-
*
12-
* param argument count
13-
* param arguments
14-
*
15-
* return a pointer to new LacoState.
10+
* Allocates and initializes a new state for the laco REPL.
1611
*/
1712
LacoState* laco_new_laco_state(int argc, const char** argv);
1813

1914
/**
20-
* Destroys the internal variable, but doesn't try to free the LacoState
21-
* pointer itself.
22-
*
23-
* param pointer to LacoState
24-
*
25-
* return 1 if pointer isn't NULL
15+
* Cleans up all allocted data internally along with the pointer to laco
16+
* state. If the pointer isn't NULL, the function returns 1.
2617
*/
2718
int laco_destroy_laco_state(LacoState* laco);
2819

2920
/**
30-
* Gets the lua state held with laco.
31-
*
32-
* param pointer to LacoState
33-
*
34-
* return a pointer to lua_State
21+
* Gets the lua state held within laco.
3522
*/
3623
struct lua_State* laco_get_laco_lua_state(LacoState* laco);
3724

3825
/**
39-
* Gets the laco version held with laco.
40-
*
41-
* param pointer to LacoState
42-
*
43-
* return a string of characters representing laco's version number
26+
* Gets the laco version held with laco. The format for the version is
27+
* `major.minor.patch`, essentually semver format.
4428
*/
4529
const char* laco_get_laco_version(LacoState* laco);
4630

4731
/**
48-
* Gets the arraying of arguments passed to laco.
49-
*
50-
* param pointer to LacoState
51-
*
52-
* return an array of characters string passes into laco
32+
* Gets the arraying of arguments passed to the laco executable.
5333
*/
5434
const char** laco_get_laco_args(LacoState* laco);
5535

5636
/**
57-
* Get the current status of the laco repl.
58-
*
59-
* param pointer to LacoState
60-
*
61-
* return the current status of laco
37+
* Gets the current status of the laco REPL.
6238
*/
6339
int laco_get_laco_status(LacoState* laco);
6440

6541
/**
66-
* Set the current status of laco.
67-
*
68-
* param pointer to LacoState
69-
* param status to be set
42+
* Sets the current status of the laco REPL.
7043
*/
7144
void laco_set_laco_status(LacoState* laco, int status);
7245

src/util.h

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,38 @@
44
struct LacoState;
55

66
/**
7-
* Load a line into the lua stack to be evaluated later
8-
*
9-
* param pointer to LacoState
10-
*
11-
* return -1 if there is no line input to load
7+
* Load a line into the lua stack to evaluated later. This function will
8+
* return -1 if there is no line input to load.
129
*/
1310
int laco_load_line(struct LacoState* laco);
1411

1512
/**
16-
* Called after laco_load_line, this evaluated the line as a function and
17-
* hands of the result for printing
18-
*
19-
* param pointer to LacoState
13+
* Called after laco_load_line, this will evalute the line as a function and
14+
* hands off the result for printing.
2015
*/
2116
void laco_handle_line(struct LacoState* laco);
2217

2318
/**
24-
* Kills the loop with exiting message if specified
25-
*
26-
* param pointer to LacoState
27-
* param exit with status
28-
* param error message
19+
* Kills the loop with exiting message if specified.
2920
*/
3021
void laco_kill(struct LacoState* laco, int status, const char* message);
3122

3223
/**
33-
* When there is a value on the lua stack, it will print out depending on
34-
* the type it is
35-
*
36-
* param pointer to LacoState
37-
*
38-
* return LUA_ERRSYNTAX if the value has some error
24+
* When there is a value on the lua stack, this will print out the current
25+
* type it is. When an error accures, laco_print_type will return
26+
* LUA_ERRSYNTAX.
3927
*/
4028
int laco_print_type(struct LacoState* laco);
4129

4230
/**
43-
* Prints out and pops off errors pushed into the lua stack
44-
*
45-
* param pointer to LacoState
46-
* param incoming lua stack status
31+
* Prints out and pops off errors pushed into the lua stack.
4732
*/
4833
void laco_report_error(struct LacoState* laco, int status);
4934

35+
/**
36+
* Checks if the test string matches any of the string in matches and
37+
* returns 1 if true, and 0 if false.
38+
*/
5039
int laco_is_match(const char** matches, const char* test_string);
5140

5241
#endif /* LACO_UTIL_H */

0 commit comments

Comments
 (0)