Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

[WIP] Docs on scopes #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
335 changes: 335 additions & 0 deletions book/04-behind-atom/sections/xx-grammar-naming-convention.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,335 @@
=== Grammar Naming Convention

==== comment

===== line

* double-slash
* double-dash
* number-sign
* percentage
* character

`// comment` — `comment.line.double-slash`

===== block

* documentation

`/* ... */` — `comment.block`

`/** ... */` — `comment.block.documentation`:
```js
/**
* Adds two numbers
* @param {Number} a
* @param {Number} b
* @return {Number} sum
*/
```

==== constant

===== numeric

Represent numbers

`42`, `1.3f`, `0x4AB1U` — `constant.numeric`

===== character

* escape

`<` — `constant.character`

`\n`, `\031` — `constant.character.escape`

===== language

Special constants provided by the language

`true`, `false`, `null`, `YES`, `NO` — `constant.language`

===== other

`#22a4d7` — `constant.other.rgb-value`

==== entity

Refers to a larger part of the document

===== name
* function
* type
* tag
* section
* other
- inherited-class
- attribute-name

`myFunction` — `entity.name.function`:

```javascript
function myFunction() {}
```

`MyClass` — `entity.name.type.class`:

```python
class MyClass:
def f(self):
return 'hello world'
```

`html` — `entity.name.tag`:

```html
<html></html>
```

`Animal` — `entity.other.inherited-class`:

```coffee
class Horse extends Animal
move: ->
alert "Galloping..."
```

`lang` — `entity.other.attribute-name`:

```html
<html lang="en-US"></html>
```

==== invalid

===== illegal

`123identifier` — `invalid.illegal`

===== deprecated

Using an API function which is deprecated

==== keyword

===== control

Related to flow control

`continue`, `while`, `return` — `keyword.control`

===== operator

`+`, `+=`, `and`, `<`, `delete` — `keyword.operator`

==== storage

Declarations

===== type

Type of something

`function` — `storage.type.function`, `var` — `storage.type`:

```javascript
function addTen(x) {
var ten = 10;
return x + ten;
}
```

`int`, `char` — `storage.type`, `struct` — `storage.type.struct`:

```c
struct PERSON {
int age;
char name[25];
};
```

===== modifier
e.g. static, final, abstract, etc.

`public` — `storage.modifier.public`:

```cpp
class Rectangle {
int width, height;
public:
void set_values (int, int);
int area (void);
};
```

==== markup

* underline
* bold
* heading
* italic
* list
- numbered
- unnumbered
* quote
* raw — code listings

`https://atom.io` — `markup.underline.link`

`**Bold**` — `markup.bold`

`### Header` — `markup.heading.heading-3`

`*Italics*` — `markup.heading.italic`

`1. item` — `list.numbered`

`* item` — `list.unnumbered`

`> quote` — `markup.quote`

==== meta

Markup larger parts of the document. `meta` scope does not get a visual style.

`<html>` — `meta.tag`:

```html
<html></html>
```

==== string

===== quoted

`'string'` — `string.quoted.single`

`"string"` — `string.quoted.double`

`$'shell'`, `%s{...}` — `string.quoted.other`

===== unquoted
`string` — `string.unquoted`

===== interpolated

Strings which are “evaluated”

`$(pwd)`

===== regexp

`/ab+c/` — `string.regexp`:

```js
var re = /ab+c/;
```

==== support

Things provided by a framework or library

===== function

`sqrt` — `support.function`:

```js
Math.sqrt(9);
```

===== class

`Math` — `support.function`:

```js
Math.sqrt(9);
```

===== type

Types provided by the framework/library. For languages derived from C, which has typedef and struct.

`size_t` — `support.type`:

```c
size_t size = sizeof(numbers);
```

`uint32_t` — `support.type`:

```c
uint32_t a = value;
```

===== constant

Magic values

===== variable

`NSApp` — `support.variable`

==== variable

===== parameter

`p1`, `p2` — `variable.parameter`:

```javascript
function myFunction(p1, p2) {}
```

===== language

Reserved language variables

`this`, `super`, `self` — `variable.language`

===== other

`$some_variable` — `variable.other`

==== punctuation

===== definition

`//` — `punctuation.definition.comment`:

```c
// comment
```

`<`, `</`, `>` — `punctuation.definition.tag`:

```html
<html></html>
```

`"` — `punctuation.definition.string`:

```js
"string"
```

`(`, `)` — `punctuation.definition.parameters`:

```javascript
function myFunction(p1, p2) {}
```

===== separator

`:` — `punctuation.separator.key-value`:

```json
{
"key": "value"
}
```

`,` — `punctuation.separator.parameters`:

```javascript
function myFunction(p1, p2) {}
```