Skip to content

Commit 2e655dd

Browse files
committed
Update README
1 parent 49afc5f commit 2e655dd

File tree

2 files changed

+87
-32
lines changed

2 files changed

+87
-32
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ trim_trailing_whitespace = true
1212
insert_final_newline = false
1313

1414
[*.md]
15+
indent_size = 2
1516
trim_trailing_whitespace = false
1617

1718
[Makefile]

README.md

Lines changed: 86 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# mini-javascript
22

3-
A mini JavaScript parser using Lex & Yacc. This parser is not production ready version. So it does not support full syntax of JavaScript and might have potential syntax issue.
3+
A mini JavaScript parser using Lex & Yacc. This parser is not production ready version. So it might have potential syntax issue.
44

5-
## Supported Keywords
5+
## What is mini-JavaScript?
66

7-
It supports most used keywords in JavaScript.
7+
It's not full featured, but it is a light version of JavaScript. It supports most used keywords in original JavaScript.
8+
9+
### Supported Keywords
10+
11+
Here is some major keywords the lexer can recognize.
812

913
| category | keywords |
10-
|---------------------------|------------------------------------------------------------------|
14+
| ------------------------- | ---------------------------------------------------------------- |
1115
| variable declaration | `var`, `let`, `const` |
1216
| function declaration | `function`, `=>` |
1317
| loop statements | `for`, `while`, `do` |
@@ -19,66 +23,116 @@ It supports most used keywords in JavaScript.
1923

2024
You can find the entire keywords in [this file](./mini-javascript.l).
2125

22-
## Supported Syntax
26+
### Supported Syntax
2327

2428
see [this yacc file](./mini-javascript.y).
2529

26-
## Parse Result
30+
### Parse Result
2731

2832
When the parser task ends, it prints debug messages and parse tree as the result.
2933

30-
### Here is the sample output
34+
**Here is the sample output**
3135

32-
test.js:
33-
```js
34-
"use strict";
35-
var a = 1;
36-
const b = 123;
37-
let c;
38-
const str = "Hello"
39-
const template_str = `hello`;
36+
<details>
37+
<summary><b>test.js (click to show / hide source</b>)</summary>
38+
<p>
4039

41-
function add() {
42-
return
43-
}
44-
```
40+
```js
41+
"use strict";
42+
var a = 1;
43+
const b = 123;
44+
let c;
45+
const str = "Hello"
46+
const template_str = `hello`;
47+
48+
function add() {
49+
return
50+
}
51+
```
4552

46-
output:
53+
</p>
54+
</details>
55+
<br>
56+
57+
**output**
4758

4859
![parse output](./docs/screenshots/parse_output.png)
4960

50-
## Prerequisites
61+
## Getting Started
62+
63+
This project does not provide compiled version of binary. So you should manually compile the parser to work on your system. The following steps describe how to compile the parser.
64+
65+
### Prerequisites
66+
67+
Before getting started, a few tools must be installed on your system.
5168

5269
- flex
5370
- bison
5471
- make
5572
- gcc
5673

57-
## Setup
74+
<details>
75+
<summary><b>macOS Installation</b></summary>
76+
<p>
77+
78+
```sh
79+
# Install bison and flex
80+
brew install bison flex
81+
82+
# Install gcc and make
83+
xcode-select --install
84+
```
85+
86+
</p>
87+
</details>
88+
89+
### Installation
90+
91+
1. Clone this repository
5892

5993
```sh
60-
# compile all sources
61-
$ make
94+
git clone https://github.com/Jaewoook/mini-javascript.git
95+
```
96+
97+
2. Run make command
98+
99+
```sh
100+
make
101+
```
102+
103+
3. Done!
62104

63-
# or you can compile lexer separately
64-
$ ./lex.sh
105+
also, lex and yacc standalone compile script is available.
65106

66-
# NOTE: if you can't run .sh file, run this command first
67-
$ chmod +x *.sh
107+
```sh
108+
# compile lex standalone
109+
./lex.sh
110+
111+
# compile yacc standalone
112+
./yacc.sh
68113
```
69114

70-
## Usage
115+
> :warning: **Note: if you can't run .sh file, run following command:**
116+
> > **`chmod +x *.sh`**
117+
118+
### Usage
71119

72120
```sh
73-
$ ./javascript [FILE]
121+
./javascript [FILE]
74122
```
75123

76-
## Test
124+
### Test
125+
126+
You can test the parser by executing following script. The test script automatically runs all `.js` files in the sample directory.
77127

78128
```sh
79-
$ ./test.sh
129+
./test.sh
80130
```
81131

132+
## Contribution
133+
134+
You can contribute this project
135+
82136
## Author
83137

84138
- [Jaewook Ahn](https://github.com/Jaewoook)

0 commit comments

Comments
 (0)