# parser

[JS](..) ⟩ [concept](../../browser/concepts) ⟩ parser

{% hint style="success" %}
A _<mark style="color:purple;">**parser**</mark>_ is a <mark style="color:yellow;">**program**</mark> that&#x20;

* <mark style="color:yellow;">**reads a piece of text**</mark> and <mark style="color:yellow;">**produces a**</mark> [**data structure**](../../appendix/data) that reflects the structure of the program contained in that text.&#x20;
* if the text <mark style="color:yellow;">**does**</mark>**&#x20;**<mark style="color:red;">**not**</mark>**&#x20;**<mark style="color:yellow;">**form a**</mark>**&#x20;**<mark style="color:red;">**valid**</mark>**&#x20;**<mark style="color:yellow;">**program**</mark>, the parser should <mark style="color:yellow;">**point out the**</mark>**&#x20;**<mark style="color:red;">**error**</mark>.
{% endhint %}

{% tabs %}
{% tab title="💈範例" %}
* [lang](../proj/lang "mention")
{% endtab %}

{% tab title="📗 參考" %}
* [ ] Eloquent JS ⟩ [Project: A Programming Language](https://eloquentjavascript.net/12_language.html) ⟩ [Parsing](https://eloquentjavascript.net/12_language.html#h_cpTTNxAWkQ)
{% endtab %}
{% endtabs %}
