Updated tokenizer.py. Added lineanalyzer.py

This commit is contained in:
2019-02-06 20:06:50 +01:00
parent 47e3272458
commit 21aa6f0b12
3 changed files with 478 additions and 145 deletions

View File

@@ -1,110 +1,3 @@
; GTK - The GIMP Toolkit
; Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
;
; This library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public
; License as published by the Free Software Foundation; either
; version 2 of the License, or (at your option) any later version.
;
; This library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with this library. If not, see <http://www.gnu.org/licenses/>.
;
; Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
; file for a list of people on the GTK+ Team. See the ChangeLog
; files for a list of changes. These files are distributed with
; GTK+ at ftp://ftp.gtk.org/pub/gtk/.
struc GtkWindowPrivate
endstruc
struc GtkWindowClass
endstruc
struc GtkWindowGeometryInfo
endstruc
struc GtkWindowGroup
endstruc
struc GtkWindowGroupClass
endstruc
struc GtkWindowGroupPrivate
endstruc
/**
; GtkWindowClass:
; @parent_class: The parent class.
; @set_focus: Sets child as the focus widget for the window.
; @activate_focus: Activates the current focused widget within the window.
; @activate_default: Activates the default widget for the window.
; @keys_changed: Signal gets emitted when the set of accelerators or
; mnemonics that are associated with window changes.
; @enable_debugging: Class handler for the #GtkWindow::enable-debugging
; keybinding signal. Since: 3.14
/*< public >*/
; G_SIGNAL_ACTION signals for keybindings
/*< private >*/
; Padding for future expansion
/**
; GtkWindowType:
; @GTK_WINDOW_TOPLEVEL: A regular window, such as a dialog.
; @GTK_WINDOW_POPUP: A special window such as a tooltip.
;
; A #GtkWindow can be one of these types. Most things youd consider a
; “window” should have type #GTK_WINDOW_TOPLEVEL; windows with this type
; are managed by the window manager and have a frame by default (call
; gtk_window_set_decorated() to toggle the frame). Windows with type
; #GTK_WINDOW_POPUP are ignored by the window manager; window manager
; keybindings wont work on them, the window manager wont decorate the
; window with a frame, many GTK+ features that rely on the window
; manager will not work (e.g. resize grips and
; maximization/minimization). #GTK_WINDOW_POPUP is used to implement
; widgets such as #GtkMenu or tooltips that you normally dont think of
; as windows per se. Nearly all windows should be #GTK_WINDOW_TOPLEVEL.
; In particular, do not use #GTK_WINDOW_POPUP just to turn off
; the window borders; use gtk_window_set_decorated() for that.
GTK_WINDOW_TOPLEVEL EQU 0
GTK_WINDOW_POPUP EQU 1
/**
; GtkWindowPosition:
; @GTK_WIN_POS_NONE: No influence is made on placement.
; @GTK_WIN_POS_CENTER: Windows should be placed in the center of the screen.
; @GTK_WIN_POS_MOUSE: Windows should be placed at the current mouse position.
; @GTK_WIN_POS_CENTER_ALWAYS: Keep window centered as it changes size, etc.
; @GTK_WIN_POS_CENTER_ON_PARENT: Center the window on its transient
; parent (see gtk_window_set_transient_for()).
;
; Window placement can be influenced using this enumeration. Note that
; using #GTK_WIN_POS_CENTER_ALWAYS is almost always a bad idea.
; It wont necessarily work well with all window managers or on all windowing systems.
GTK_WIN_POS_NONE EQU 0
GTK_WIN_POS_CENTER EQU 1
GTK_WIN_POS_MOUSE EQU 2
GTK_WIN_POS_CENTER_ALWAYS EQU 3
GTK_WIN_POS_CENTER_ON_PARENT EQU 4
@@ -118,29 +11,419 @@ GTK_WIN_POS_CENTER_ON_PARENT EQU 4
; If window is set modal, input will be grabbed when show and released when hide
; Set initial default size of the window (does not constrain user
; resize operations)
; Ignore this unless you are writing a GUI builder
; Window grips
TOKEN_ENDIF #endif ; __GTK_WINDOW_H__

28
lineanalyzer.py Normal file
View File

@@ -0,0 +1,28 @@
'''
Contains class LINEANALYSER
'''
from contextlib import ContextDecorator
from itertools import count
class ANALYZEOBJECT:
_passes = count(0)
_analyzed = []
def __exit__(self, *exc):
return False
def __init__(self):
self.passes = 0
self.analyzeline = []
self.analyzed = []
class ANALYZER(ANALYZEOBJECT):
_ids = count(0)
_passes = count(0)
def __init__(self):
self.id = next(self._ids)
self.tupline = []
self.tupfile = []
self.passes = next(self._passes)

View File

@@ -16,33 +16,47 @@ class TOKENIZEOBJECT:
self.analyzeline = []
self.analyzed = []
class Decorators(ContextDecorator):
@classmethod
def typedef_struct(ContextDecorator):
class typedef_struct(ContextDecorator):
def __enter__(self):
TOKENIZER._analyzed.append('TOKEN_TYPEDEF_STRUCT')
return
return self
@classmethod
def typedef_enum(ContextDecorator):
def __exit__(self, *exc):
return False
class typedef_enum(ContextDecorator):
def __enter__(self):
TOKENIZER._analyzed.append('TOKEN_TYPEDEF_ENUM')
return
return self
@classmethod
def enum(ContextDecorator):
def __exit__(self, *exc):
return False
class enum(ContextDecorator):
def __enter__(self):
TOKENIZER._analyzed.append('TOKEN_ENUM')
return
return self
@classmethod
def tagname(ContextDecorator):
def __exit__(self, *exc):
return False
class tagname(ContextDecorator):
def __enter__(self):
TOKENIZER._analyzed.append('TOKEN_TAG_NAME')
return
return self
@classmethod
def alias(ContextDecorator):
def __exit__(self, *exc):
return False
class alias(ContextDecorator):
def __enter__(self):
TOKENIZER._analyzed.append('TOKEN_ALIAS')
return
return self
def __exit__(self, *exc):
return False
@Decorators.typedef_struct
@typedef_struct()
def TD_struct(self, tsl):
'''
Takes a Typedef Struct 'list' and appends all items (i) in that list to _analyzed.
@@ -51,7 +65,15 @@ class TOKENIZEOBJECT:
self._analyzed.append(i)
return
@Decorators.tagname
@typedef_enum()
def TD_enum(self, e):
'''
Takes a Typedef enum member and appends it to _analyzed.
'''
self._analyzed.append(e)
return
@tagname()
def TD_tagname(self, tn):
'''
Takes a Typedef tagname and appends it to _analyzed.