Skip to content

Commit

Permalink
Classify Keywords into several kinds
Browse files Browse the repository at this point in the history
Since Keyword is covering too much, it should be classified
to statements, expressions, and types.

Closes coala#12
  • Loading branch information
seeeturtle committed Oct 28, 2018
1 parent 938b141 commit 9b74cc1
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 7 deletions.
341 changes: 341 additions & 0 deletions data/Keyword/_all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,341 @@
# CPlusPlus
- pk: alignas
name: 'alignas'
type: 'statement'
- pk: alignof
name: 'alignof'
type: 'expression'
- pk: and
name: 'and'
type: 'expression'
- pk: and_eq
name: 'and_eq'
type: 'expression'
- pk: asm
name: 'asm'
type: 'statement'
- pk: auto
name: 'auto'
type: 'statement'
- pk: bitand
name: 'bitand'
type: 'expression'
- pk: bitor
name: 'bitor'
type: 'expression'
- pk: bool
name: 'bool'
type: 'type'
- pk: break
name: 'break'
type: 'statement'
- pk: case
name: 'case'
type: 'statement'
- pk: catch
name: 'catch'
type: 'statement'
- pk: char
name: 'char'
type: 'type'
- pk: char16_t
name: 'char16_t'
type: 'type'
- pk: char32_t
name: 'char32_t'
type: 'type'
- pk: class
name: 'class'
type: 'statement'
- pk: compl
name: 'compl'
type: 'expression'
- pk: concept
name: 'concept'
type: 'statement'
- pk: const
name: 'const'
type: 'statement'
- pk: constexpr
name: 'constexpr'
type: 'statement'
- pk: const_cast
name: 'const_cast'
type: 'expression'
- pk: continue
name: 'continue'
type: 'statement'
- pk: decltype
name: 'decltype'
type: 'statement'
- pk: default
name: 'default'
type: 'statement'
- pk: delete
name: 'delete'
type: 'expression'
- pk: do
name: 'do'
type: 'statement'
- pk: double
name: 'double'
type: 'type'
- pk: dynamic_cast
name: 'dynamic_cast'
type: 'expression'
- pk: else
name: 'else'
type: 'statement'
- pk: enum
name: 'enum'
type: 'statement'
- pk: explicit
name: 'explicit'
type: 'statement'
- pk: export
name: 'export'
type: 'statement'
- pk: extern
name: 'extern'
type: 'statement'
- pk: false
name: 'false'
type: 'expression'
- pk: float
name: 'float'
type: 'type'
- pk: for
name: 'for'
type: 'statement'
- pk: friend
name: 'friend'
type: 'statement'
- pk: goto
name: 'goto'
type: 'statement'
- pk: if
name: 'if'
type: 'statement'
- pk: inline
name: 'inline'
type: 'statement'
- pk: int
name: 'int'
type: 'type'
- pk: long
name: 'long'
type: 'type'
- pk: mutable
name: 'mutable'
type: 'statement'
- pk: namespace
name: 'namespace'
type: 'statement'
- pk: new
name: 'new'
type: 'expression'
- pk: noexcept
name: 'noexcept'
type: 'expression'
- pk: not
name: 'not'
type: 'expression'
- pk: not_eq
name: 'not_eq'
type: 'expression'
- pk: nullptr
name: 'nullptr'
type: 'expression'
- pk: operator
name: 'operator'
type: 'statement'
- pk: or
name: 'or'
type: 'expression'
- pk: or_eq
name: 'or_eq'
type: 'expression'
- pk: private
name: 'private'
type: 'statement'
- pk: protected
name: 'protected'
type: 'statement'
- pk: public
name: 'public'
type: 'statement'
- pk: register
name: 'register'
type: 'statement'
- pk: reinterpret_cast
name: 'reinterpret_cast'
type: 'expression'
- pk: requires
name: 'requires'
type: 'statement'
- pk: return
name: 'return'
type: 'statement'
- pk: short
name: 'short'
type: 'type'
- pk: signed
name: 'signed'
type: 'type'
- pk: sizeof
name: 'sizeof'
type: 'expression'
- pk: static
name: 'static'
type: 'statement'
- pk: static_assert
name: 'static_assert'
type: 'statement'
- pk: static_cast
name: 'static_cast'
type: 'expression'
- pk: struct
name: 'struct'
type: 'type'
- pk: switch
name: 'switch'
type: 'statement'
- pk: template
name: 'template'
type: 'statement'
- pk: this
name: 'this'
type: 'expression'
- pk: thread_local
name: 'thread_local'
type: 'statement'
- pk: throw
name: 'throw'
type: 'statement'
- pk: true
name: 'true'
type: 'expression'
- pk: try
name: 'try'
type: 'statement'
- pk: typedef
name: 'typedef'
type: 'statement'
- pk: typeid
name: 'typeid'
type: 'expression'
- pk: typename
name: 'typename'
type: 'statement'
- pk: union
name: 'union'
type: 'type'
- pk: unsigned
name: 'unsigned'
type: 'type'
- pk: using
name: 'using'
type: 'statement'
- pk: virtual
name: 'virtual'
type: 'statement'
- pk: void
name: 'void'
name: 'void'
type: 'statement'
- pk: volatile
name: 'volatile'
type: 'statement'
- pk: wchar_t
name: 'wchar_t'
name: 'wchar_t'
type: 'type'
- pk: while
name: 'while'
name: 'while'
type: 'statement'
- pk: xor
name: 'xor'
type: 'expression'
- pk: xor_eq
name: 'xor_eq'
type: 'expression'
- pk: '#include'
name: '#include'
type: 'statement'
- pk: '#define'
name: '#define'
type: 'statement'
- pk: '#undef'
name: '#undef'
type: 'statement'
- pk: '#ifdef'
name: '#ifdef'
type: 'statement'
- pk: '#ifndef'
name: '#ifndef'
type: 'statement'
- pk: '#if'
name: '#if'
type: 'statement'
- pk: '#endif'
name: '#endif'
type: 'statement'
- pk: '#else'
name: '#else'
type: 'statement'
- pk: '#elif'
name: '#elif'
type: 'statement'
- pk: '#line'
name: '#line'
type: 'statement'
- pk: '#pragma'
name: '#pragma'
type: 'statement'
# TinyBasic
- pk: PRINT
name: 'PRINT'
type: 'statement'
- pk: IF
name: 'IF'
type: 'statement'
- pk: THEN
name: 'THEN'
type: 'statement'
- pk: GOTO
name: 'GOTO'
type: 'statement'
- pk: INPUT
name: 'INPUT'
type: 'statement'
- pk: LET
name: 'LET'
type: 'statement'
- pk: GOSUB
name: 'GOSUB'
type: 'statement'
- pk: RETURN
name: 'RETURN'
type: 'statement'
- pk: CLEAR
name: 'CLEAR'
type: 'statement'
- pk: LIST
name: 'LIST'
type: 'statement'
- pk: RUN
name: 'RUN'
type: 'statement'
- pk: END
name: 'END'
type: 'statement'
- pk: PR
name: 'PR'
type: 'statement'
- pk: RND
name: 'RND'
type: 'expression'
- pk: USR
name: 'USR'
type: 'statement'
3 changes: 2 additions & 1 deletion models/Keyword.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# pk: String
type: String
name: String
14 changes: 8 additions & 6 deletions templates/Language.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@
{{ m.show_delimiter_list(language.delimiters, delimiter_type_block) }}
</td>
</tr>
<tr>
<th>Keywords</th>
<td>
{{ m.show_list(language.keywords) }}
</td>
</tr>
{% for keyword in keywords %}
<tr>
<th>{{ keyword }} keywords</th>
<td>
{{ m.show_keywords_list(language.keywords, keyword) }}
</td>
</tr>
{% endfor %}
<table>
</body>
</html>
10 changes: 10 additions & 0 deletions templates/macros.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@
{% endfor %}
</ul>
{% endmacro %}

{% macro show_keywords_list(keywords, type) %}
<ul>
{% for item in keywords %}
{% if item.type == type %}
<li>{{ item | escape }}</li>
{% endif %}
{% endfor %}
</ul>
{% endmacro %}
2 changes: 2 additions & 0 deletions views/languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ path:
language: session.query(Language).all()
template: Language
context:
static:
keywords: ['statement', 'expression', 'type']
dynamic:
delimiter_type_comment: session.query(EnumDelimiterType).filter(EnumDelimiterType.name == 'comment').one()
delimiter_type_string: session.query(EnumDelimiterType).filter(EnumDelimiterType.name == 'string').one()
Expand Down

0 comments on commit 9b74cc1

Please sign in to comment.