Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Add header into intellisence, fix parsing invalid operands
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeejoee committed Nov 20, 2017
1 parent 073ac66 commit ebab51f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions ifj2017/ide/assets/styles/UIStyles.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ QtObject {
typeColors[0] = "#00bff2"
typeColors[1] = "#ffe20d"
typeColors[2] = "white"
typeColors[3] = "orange"
}
}
}
6 changes: 6 additions & 0 deletions ifj2017/ide/code_analyzer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding=utf-8
import re
from typing import Optional

from PyQt5.QtCore import QObject, QVariant, pyqtProperty, pyqtSignal
from PyQt5.QtQml import QQmlEngine, QJSEngine

Expand Down Expand Up @@ -31,6 +32,11 @@ def code(self, v: str) -> None:
def completerModel(self) -> QVariant:
return QVariant(
[
dict(
identifier='.IFJcode17',
type=Expression.ExpressionTypes.Header
)
] if '.IFJcode17' not in self.code else [] + [
dict(
identifier=match,
type=Expression.ExpressionTypes.Types
Expand Down
1 change: 1 addition & 0 deletions ifj2017/ide/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ExpressionTypes(IntEnum):
Instruction = 0
Variable = 1
Types = 2
Header = 3

Q_ENUMS(ExpressionTypes)

Expand Down
10 changes: 6 additions & 4 deletions ifj2017/interpreter/operand.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ def __init__(self, value):

raise InvalidCodeException(InvalidCodeException.INVALID_OPERAND)


def _resolve_constant(self, constant_match):
# type: (Match) -> None
type_, value = constant_match.groups()
self.value = self.CONSTANT_MAPPING.get(type_.lower())(value)
if type_.lower() == self.CONSTANT_MAPPING_REVERSE.get(bool):
self.value = self.BOOL_LITERAL_MAPPING.get(value.lower())
try:
self.value = self.CONSTANT_MAPPING.get(type_.lower())(value)
if type_.lower() == self.CONSTANT_MAPPING_REVERSE.get(bool):
self.value = self.BOOL_LITERAL_MAPPING.get(value.lower())
except ValueError:
pass
if self.value is None:
raise InvalidCodeException(type_=InvalidCodeException.INVALID_OPERAND)
self.type = TypeOperand.CONSTANT
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
def setup():
core.setup(
name='IFJcode17-toolkit',
version='1.1.4',
version='1.1.6',
license='GNU GENERAL PUBLIC LICENSE Version 3',
description='Toolkit for IFJ17 language compiler (as project at FIT BUT in Brno) with '
'interactive debugger and automatic tests.',
Expand Down

0 comments on commit ebab51f

Please sign in to comment.