Semantics¶
block_comment
¶
This module contains the representation of a block or multi-line comment in an ASP document.
document_parser
¶
This module contains the DocumentParser class, which is responsible for parsing ASP documents.
It extracts relevant information from the Tree-sitter parse tree and populates the Document object with statements, predicates, comments, and other elements.
line_comment
¶
This module contains the LineComment class, which represents a single line comment in an ASP document.
predicate
¶
This module contains the Predicate class, which holds information about a specific ASP predicate.
Predicate
dataclass
¶
A predicate in an ASP document.
arity: int
instance-attribute
¶
The arity of the predicate.
documentation: PredicateDocumentation | None = None
class-attribute
instance-attribute
¶
The documentation of the predicate.
identifier: str
instance-attribute
¶
The identifier of the predicate.
is_input: bool = False
class-attribute
instance-attribute
¶
If it is an input (Not defined by any rule).
show_status: ShowStatus = ShowStatus.DEFAULT
class-attribute
instance-attribute
¶
The show status of the predicate.
signature: str
property
¶
Return the signature of the predicate.
The signature of a predicate is a string of the form identifier/arity
.
Returns:
Type | Description |
---|---|
str
|
The signature of the predicate. |
__str__() -> str
¶
Return the string representation of the predicate.
If the predicate has documentation, return the representation from the documentation. Otherwise, return the default representation.
The default representation is of the form identifier(A, B, C)
where A
, B
, and C
are
the first three uppercase letters of the alphabet.
Returns:
Type | Description |
---|---|
str
|
The string representation of the predicate. |
from_node(node: Node) -> Predicate
staticmethod
¶
Create a predicate from a node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Node
|
The node representing the predicate. |
required |
Returns:
Type | Description |
---|---|
Predicate
|
The created predicate. |
update_show_status(status: ShowStatus) -> None
¶
Update the show status of the predicate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status
|
ShowStatus
|
The new show status. |
required |
predicate_documentation
¶
This module contains the 'PredicateDocumentation', which represents the documentation for a predicate.
PredicateDocumentation
dataclass
¶
Documentation for a predicate.
Example
%*#some_predicate(A,B,C). description
parameters¶
- A : this is A
- B : this is B
- C : this is C *%
description: str
instance-attribute
¶
The description of the predicate.
node: Node | None = None
class-attribute
instance-attribute
¶
The node representing the predicate.
parameter_descriptions: dict[str, str] = field(default_factory=dict)
class-attribute
instance-attribute
¶
The descriptions of the parameters of the predicate.
signature: str
instance-attribute
¶
The signature of the predicate.
from_block_comment(comment: BlockComment) -> PredicateDocumentation | None
staticmethod
¶
Create a predicate documentation from a comment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
comment
|
BlockComment
|
The block comment. |
required |
Returns:
Type | Description |
---|---|
PredicateDocumentation | None
|
The predicate documentation or None if the comment is not a predicate documentation. |
statement
¶
This module contains the Statement class, which represents a statement in an ASP program.
Statement
dataclass
¶
A statement in an ASP program.
needed_predicates: list[Tuple[Predicate, bool]]
instance-attribute
¶
The predicates needed by the statement.
provided_predicates: list[Tuple[Predicate, bool]]
instance-attribute
¶
The predicates provided by the statement.
row: int
instance-attribute
¶
The row in the source file where the statement is located.
text: str
instance-attribute
¶
The text of the statement.
add_needed(predicate: Predicate, negation: bool = False)
¶
Add a predicate this statement needs.
add_provided(predicate: Predicate, negation: bool = False)
¶
Add a predicate this statement provides.
from_node(node: Node) -> Statement
staticmethod
¶
Create a statement from a node. Args: node: The node representing the statement. Returns: The created statement.