summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-06-18 10:41:48 +0200
committerGeorg Brandl <georg@python.org>2011-06-18 10:41:48 +0200
commit6bc7a6422e2d716c81c17254fea032a26ff37544 (patch)
treee520684d99331844417b3eb174bd04355112ece5
parentb8ab0806c54074c60fd005cf07777f65e8f8dd2c (diff)
parent8e36360b21375872946eea2f09e10ec334eff262 (diff)
downloadpygments-6bc7a6422e2d716c81c17254fea032a26ff37544.tar.gz
Merge with https://bitbucket.org/tvansteenburgh/pygments-main
-rw-r--r--AUTHORS4
-rw-r--r--CHANGES8
-rw-r--r--pygments/lexers/_mapping.py12
-rw-r--r--pygments/lexers/agile.py5
-rw-r--r--pygments/lexers/compiled.py297
-rw-r--r--pygments/lexers/dotnet.py269
-rw-r--r--pygments/lexers/functional.py4
-rw-r--r--pygments/lexers/pypylog.py15
-rw-r--r--pygments/lexers/web.py32
-rw-r--r--tests/examplefiles/example.nim1010
-rw-r--r--tests/examplefiles/nemerle_sample.n85
-rw-r--r--tests/examplefiles/test.ec605
-rw-r--r--tests/examplefiles/test.eh315
13 files changed, 2629 insertions, 32 deletions
diff --git a/AUTHORS b/AUTHORS
index 4b85b07c..1487287c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -51,6 +51,7 @@ Other contributors, listed alphabetically, are:
* Simone Margaritelli -- Hybris lexer
* Kirk McDonald -- D lexer
* Stephen McKamey -- Duel/JBST lexer
+* Brian McKenna -- F# lexer
* Lukas Meuser -- BBCode formatter, Lua lexer
* Michael Mior -- Awk lexer
* Paulo Moura -- Logtalk lexer
@@ -62,6 +63,7 @@ Other contributors, listed alphabetically, are:
* Jon Parise -- Protocol buffers lexer
* Ronny Pfannschmidt -- BBCode lexer
* Benjamin Peterson -- Test suite refactoring
+* Dominik Picheta -- Nimrod lexer
* Justin Reidy -- MXML lexer
* Lubomir Rintel -- GoodData MAQL and CL lexers
* Andre Roberge -- Tango style
@@ -75,6 +77,7 @@ Other contributors, listed alphabetically, are:
* Joerg Sieker -- ABAP lexer
* Kirill Simonov -- YAML lexer
* Steve Spigarelli -- XQuery lexer
+* Jerome St-Louis -- eC lexer
* Tiberius Teng -- default style overhaul
* Jeremy Thurgood -- Erlang, Squid config lexers
* Erick Tryzelaar -- Felix lexer
@@ -83,5 +86,6 @@ Other contributors, listed alphabetically, are:
* Dietmar Winkler -- Modelica lexer
* Nils Winter -- Smalltalk lexer
* Davy Wybiral -- Clojure lexer
+* Alex Zimin -- Nemerle lexer
Many thanks for all contributions!
diff --git a/CHANGES b/CHANGES
index 5a996e16..77328c69 100644
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,14 @@ Version 1.5
* Awk
* Fancy (#633)
* PyPy Log
+ * eC
+ * Nimrod
+ * Nemerle
+ * F#
+
+- Fix Lua "class" highlighting: it does not have classes (#665).
+
+- Fix degenerate regex in Scala lexer (#671).
Version 1.4
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index 5302a8f2..84b01a7c 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -73,12 +73,14 @@ LEXERS = {
'DjangoLexer': ('pygments.lexers.templates', 'Django/Jinja', ('django', 'jinja'), (), ('application/x-django-templating', 'application/x-jinja')),
'DuelLexer': ('pygments.lexers.web', 'Duel', ('duel', 'Duel Engine', 'Duel View', 'JBST', 'jbst', 'JsonML+BST'), ('*.duel', '*.jbst'), ('text/x-duel', 'text/x-jbst')),
'DylanLexer': ('pygments.lexers.compiled', 'Dylan', ('dylan',), ('*.dylan', '*.dyl'), ('text/x-dylan',)),
+ 'ECLexer': ('pygments.lexers.compiled', 'eC', ('ec',), ('*.ec', '*.eh'), ('text/x-echdr', 'text/x-ecsrc')),
'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)),
'ErlangLexer': ('pygments.lexers.functional', 'Erlang', ('erlang',), ('*.erl', '*.hrl'), ('text/x-erlang',)),
'ErlangShellLexer': ('pygments.lexers.functional', 'Erlang erl session', ('erl',), ('*.erl-sh',), ('text/x-erl-shellsession',)),
'EvoqueHtmlLexer': ('pygments.lexers.templates', 'HTML+Evoque', ('html+evoque',), ('*.html',), ('text/html+evoque',)),
'EvoqueLexer': ('pygments.lexers.templates', 'Evoque', ('evoque',), ('*.evoque',), ('application/x-evoque',)),
'EvoqueXmlLexer': ('pygments.lexers.templates', 'XML+Evoque', ('xml+evoque',), ('*.xml',), ('application/xml+evoque',)),
+ 'FSharpLexer': ('pygments.lexers.dotnet', 'FSharp', ('fsharp',), ('*.fs', '*.fsi'), ('text/x-fsharp',)),
'FactorLexer': ('pygments.lexers.agile', 'Factor', ('factor',), ('*.factor',), ('text/x-factor',)),
'FancyLexer': ('pygments.lexers.agile', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)),
'FelixLexer': ('pygments.lexers.compiled', 'Felix', ('felix', 'flx'), ('*.flx', '*.flxh'), ('text/x-felix',)),
@@ -144,8 +146,10 @@ LEXERS = {
'MyghtyLexer': ('pygments.lexers.templates', 'Myghty', ('myghty',), ('*.myt', 'autodelegate'), ('application/x-myghty',)),
'MyghtyXmlLexer': ('pygments.lexers.templates', 'XML+Myghty', ('xml+myghty',), (), ('application/xml+myghty',)),
'NasmLexer': ('pygments.lexers.asm', 'NASM', ('nasm',), ('*.asm', '*.ASM'), ('text/x-nasm',)),
+ 'NemerleLexer': ('pygments.lexers.dotnet', 'Nemerle', ('nemerle',), ('*.n',), ('text/x-nemerle',)),
'NewspeakLexer': ('pygments.lexers.other', 'Newspeak', ('newspeak',), ('*.ns2',), ('text/x-newspeak',)),
'NginxConfLexer': ('pygments.lexers.text', 'Nginx configuration file', ('nginx',), (), ('text/x-nginx-conf',)),
+ 'NimrodLexer': ('pygments.lexers.compiled', 'Nimrod', ('nimrod', 'nim'), ('*.nim', '*.nimrod'), ('text/x-nimrod',)),
'NumPyLexer': ('pygments.lexers.math', 'NumPy', ('numpy',), (), ()),
'ObjdumpLexer': ('pygments.lexers.asm', 'objdump', ('objdump',), ('*.objdump',), ('text/x-objdump',)),
'ObjectiveCLexer': ('pygments.lexers.compiled', 'Objective-C', ('objective-c', 'objectivec', 'obj-c', 'objc'), ('*.m',), ('text/x-objective-c',)),
@@ -160,7 +164,7 @@ LEXERS = {
'PrologLexer': ('pygments.lexers.compiled', 'Prolog', ('prolog',), ('*.prolog', '*.pro', '*.pl'), ('text/x-prolog',)),
'PropertiesLexer': ('pygments.lexers.text', 'Properties', ('properties',), ('*.properties',), ('text/x-java-properties',)),
'ProtoBufLexer': ('pygments.lexers.other', 'Protocol Buffer', ('protobuf',), ('*.proto',), ()),
- 'PyPyLogLexer': ('pygments.lexers.pypylog', 'PyPy Log', ('pypylog', 'pypy'), ('*.pypylog',), ()),
+ 'PyPyLogLexer': ('pygments.lexers.pypylog', 'PyPy Log', ('pypylog', 'pypy'), ('*.pypylog',), ('application/x-pypylog',)),
'Python3Lexer': ('pygments.lexers.agile', 'Python 3', ('python3', 'py3'), (), ('text/x-python3', 'application/x-python3')),
'Python3TracebackLexer': ('pygments.lexers.agile', 'Python 3.0 Traceback', ('py3tb',), ('*.py3tb',), ('text/x-python3-traceback',)),
'PythonConsoleLexer': ('pygments.lexers.agile', 'Python console session', ('pycon',), (), ('text/x-python-doctest',)),
@@ -186,7 +190,7 @@ LEXERS = {
'SassLexer': ('pygments.lexers.web', 'Sass', ('sass', 'SASS'), ('*.sass',), ('text/x-sass',)),
'ScalaLexer': ('pygments.lexers.compiled', 'Scala', ('scala',), ('*.scala',), ('text/x-scala',)),
'ScamlLexer': ('pygments.lexers.web', 'Scaml', ('scaml', 'SCAML'), ('*.scaml',), ('text/x-scaml',)),
- 'SchemeLexer': ('pygments.lexers.functional', 'Scheme', ('scheme', 'scm'), ('*.scm',), ('text/x-scheme', 'application/x-scheme')),
+ 'SchemeLexer': ('pygments.lexers.functional', 'Scheme', ('scheme', 'scm'), ('*.scm', '*.ss', '*.rkt'), ('text/x-scheme', 'application/x-scheme')),
'ScssLexer': ('pygments.lexers.web', 'SCSS', ('scss',), ('*.scss',), ('text/x-scss',)),
'SmalltalkLexer': ('pygments.lexers.other', 'Smalltalk', ('smalltalk', 'squeak'), ('*.st',), ('text/x-smalltalk',)),
'SmartyLexer': ('pygments.lexers.templates', 'Smarty', ('smarty',), ('*.tpl',), ('application/x-smarty',)),
@@ -214,7 +218,7 @@ LEXERS = {
'XmlPhpLexer': ('pygments.lexers.templates', 'XML+PHP', ('xml+php',), (), ('application/xml+php',)),
'XmlSmartyLexer': ('pygments.lexers.templates', 'XML+Smarty', ('xml+smarty',), (), ('application/xml+smarty',)),
'XsltLexer': ('pygments.lexers.web', 'XSLT', ('xslt',), ('*.xsl', '*.xslt'), ('text/xml', 'application/xml', 'image/svg+xml', 'application/rss+xml', 'application/atom+xml', 'application/xsl+xml', 'application/xslt+xml')),
- 'YamlLexer': ('pygments.lexers.text', 'YAML', ('yaml',), ('*.yaml', '*.yml'), ('text/x-yaml',))
+ 'YamlLexer': ('pygments.lexers.text', 'YAML', ('yaml',), ('*.yaml', '*.yml'), ('text/x-yaml',)),
}
if __name__ == '__main__':
@@ -253,6 +257,6 @@ if __name__ == '__main__':
# write new file
f = open(__file__, 'w')
f.write(header)
- f.write('LEXERS = {\n %s\n}\n\n' % ',\n '.join(found_lexers))
+ f.write('LEXERS = {\n %s,\n}\n\n' % ',\n '.join(found_lexers))
f.write(footer)
f.close()
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index e7438158..1a1ddfe8 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -1044,7 +1044,6 @@ class LuaLexer(RegexLexer):
(r'(true|false|nil)\b', Keyword.Constant),
(r'(function)(\s+)', bygroups(Keyword, Text), 'funcname'),
- (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
(r'[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?', Name),
@@ -1059,10 +1058,6 @@ class LuaLexer(RegexLexer):
('\(', Punctuation, '#pop'),
],
- 'classname': [
- ('[A-Za-z_][A-Za-z0-9_]*', Name.Class, '#pop')
- ],
-
# if I understand correctly, every character is valid in a lua string,
# so this state is only for later corrections
'string': [
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index a51bd420..bb8327b9 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -22,11 +22,11 @@ from pygments.token import \
# backwards compatibility
from pygments.lexers.functional import OcamlLexer
-__all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'JavaLexer',
+__all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer', 'JavaLexer',
'ScalaLexer', 'DylanLexer', 'OcamlLexer', 'ObjectiveCLexer',
'FortranLexer', 'GLShaderLexer', 'PrologLexer', 'CythonLexer',
'ValaLexer', 'OocLexer', 'GoLexer', 'FelixLexer', 'AdaLexer',
- 'Modula2Lexer', 'BlitzMaxLexer']
+ 'Modula2Lexer', 'BlitzMaxLexer', 'NimrodLexer']
class CLexer(RegexLexer):
@@ -250,6 +250,156 @@ class CppLexer(RegexLexer):
}
+class ECLexer(RegexLexer):
+ """
+ For eC source code with preprocessor directives.
+
+ *New in Pygments 1.5.*
+ """
+ name = 'eC'
+ aliases = ['ec']
+ filenames = ['*.ec', '*.eh']
+ mimetypes = ['text/x-echdr', 'text/x-ecsrc']
+
+ #: optional Comment or Whitespace
+ _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
+
+ tokens = {
+ 'whitespace': [
+ # preprocessor directives: without whitespace
+ ('^#if\s+0', Comment.Preproc, 'if0'),
+ ('^#', Comment.Preproc, 'macro'),
+ # or with whitespace
+ ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
+ ('^' + _ws + '#', Comment.Preproc, 'macro'),
+ (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))', bygroups(Text, Name.Label)),
+ (r'\n', Text),
+ (r'\s+', Text),
+ (r'\\\n', Text), # line continuation
+ (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+ ],
+ 'statements': [
+ (r'L?"', String, 'string'),
+ (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
+ (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
+ (r'0[0-7]+[LlUu]*', Number.Oct),
+ (r'\d+[LlUu]*', Number.Integer),
+ (r'\*/', Error),
+ (r'[~!%^&*+=|?:<>/-]', Operator),
+ (r'[()\[\],.]', Punctuation),
+ (r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
+ (r'(auto|break|case|const|continue|default|do|else|enum|extern|'
+ r'for|goto|if|register|restricted|return|sizeof|static|struct|'
+ r'switch|typedef|union|volatile|virtual|while|class|private|public|'
+ r'property|import|delete|new|new0|renew|renew0|define|get|set|remote|dllexport|dllimport|stdcall|'
+ r'subclass|__on_register_module|namespace|using|typed_object|any_object|incref|register|watch|'
+ r'stopwatching|firewatchers|watchable|class_designer|class_fixed|class_no_expansion|isset|'
+ r'class_default_property|property_category|class_data|class_property|virtual|thisclass|'
+ r'dbtable|dbindex|database_open|dbfield)\b', Keyword),
+ (r'(int|long|float|short|double|char|unsigned|signed|void)\b',
+ Keyword.Type),
+ (r'(uint|uint16|uint32|uint64|bool|byte|unichar|int64)\b',
+ Keyword.Type),
+ (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
+ (r'(_{0,2}inline|naked|restrict|thread|typename)\b', Keyword.Reserved),
+ (r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
+ r'declspec|finally|int64|try|leave)\b', Keyword.Reserved),
+ (r'(true|false|null|value|this|NULL)\b', Name.Builtin),
+ ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+ ],
+ 'root': [
+ include('whitespace'),
+ # functions
+ (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
+ r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'(\s*\([^;]*?\))' # signature
+ r'(' + _ws + r')({)',
+ bygroups(using(this), Name.Function, using(this), using(this),
+ Punctuation),
+ 'function'),
+ # function declarations
+ (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
+ r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
+ r'(\s*\([^;]*?\))' # signature
+ r'(' + _ws + r')(;)',
+ bygroups(using(this), Name.Function, using(this), using(this),
+ Punctuation)),
+ ('', Text, 'statement'),
+ ],
+ 'classname': [
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
+ # template specification
+ (r'\s*(?=>)', Text, '#pop'),
+ ],
+ 'statement' : [
+ include('whitespace'),
+ include('statements'),
+ ('[{}]', Punctuation),
+ (';', Punctuation, '#pop'),
+ ],
+ 'function': [
+ include('whitespace'),
+ include('statements'),
+ (';', Punctuation),
+ ('{', Punctuation, '#push'),
+ ('}', Punctuation, '#pop'),
+ ],
+ 'string': [
+ (r'"', String, '#pop'),
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
+ (r'[^\\"\n]+', String), # all other characters
+ (r'\\\n', String), # line continuation
+ (r'\\', String), # stray backslash
+ ],
+ 'macro': [
+ (r'[^/\n]+', Comment.Preproc),
+ (r'/[*](.|\n)*?[*]/', Comment.Multiline),
+ (r'//.*?\n', Comment.Single, '#pop'),
+ (r'/', Comment.Preproc),
+ (r'(?<=\\)\n', Comment.Preproc),
+ (r'\n', Comment.Preproc, '#pop'),
+ ],
+ 'if0': [
+ (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
+ (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
+ (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
+ (r'.*?\n', Comment),
+ ]
+ }
+
+ stdlib_types = ['size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t',
+ 'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
+ 'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
+ 'wctrans_t', 'wint_t', 'wctype_t']
+ c99_types = ['_Bool', '_Complex', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
+ 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
+ 'int_least16_t', 'int_least32_t', 'int_least64_t',
+ 'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
+ 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
+ 'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
+ 'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t', 'uintmax_t']
+
+ def __init__(self, **options):
+ self.stdlibhighlighting = get_bool_opt(options,
+ 'stdlibhighlighting', True)
+ self.c99highlighting = get_bool_opt(options,
+ 'c99highlighting', True)
+ RegexLexer.__init__(self, **options)
+
+ def get_tokens_unprocessed(self, text):
+ for index, token, value in \
+ RegexLexer.get_tokens_unprocessed(self, text):
+ if token is Name:
+ if self.stdlibhighlighting and value in self.stdlib_types:
+ token = Keyword.Type
+ elif self.c99highlighting and value in self.c99_types:
+ token = Keyword.Type
+ yield index, token, value
+
+
class DLexer(RegexLexer):
"""
For D source.
@@ -986,7 +1136,7 @@ class ScalaLexer(RegexLexer):
(r'(true|false|null)\b', Keyword.Constant),
(r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
(r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
- (r'"""(?:.|\n)*?"""', String),
+ (r'""".*?"""', String),
(r'"(\\\\|\\"|[^"])*"', String),
(ur"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
# (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
@@ -2480,3 +2630,144 @@ class BlitzMaxLexer(RegexLexer):
(r'[^"]+', String.Double),
],
}
+
+
+class NimrodLexer(RegexLexer):
+ """
+ For `Nimrod <http://nimrod-code.org/>`_ source code.
+
+ *New in Pygments 1.5.*
+ """
+
+ name = 'Nimrod'
+ aliases = ['nimrod', 'nim']
+ filenames = ['*.nim', '*.nimrod']
+ mimetypes = ['text/x-nimrod']
+
+ flags = re.MULTILINE | re.IGNORECASE | re.UNICODE
+
+ def underscorize(words):
+ newWords = []
+ new = ""
+ for word in words:
+ for ch in word:
+ new += (ch + "_?")
+ newWords.append(new)
+ new = ""
+ return "|".join(newWords)
+
+ keywords = [
+ 'addr', 'and', 'as', 'asm', 'atomic', 'bind', 'block', 'break',
+ 'case', 'cast', 'const', 'continue', 'converter', 'discard',
+ 'distinct', 'div', 'elif', 'else', 'end', 'enum', 'except', 'finally',
+ 'for', 'generic', 'if', 'implies', 'in', 'yield',
+ 'is', 'isnot', 'iterator', 'lambda', 'let', 'macro', 'method',
+ 'mod', 'not', 'notin', 'object', 'of', 'or', 'out', 'proc',
+ 'ptr', 'raise', 'ref', 'return', 'shl', 'shr', 'template', 'try',
+ 'tuple', 'type' , 'when', 'while', 'with', 'without', 'xor'
+ ]
+
+ keywordsPseudo = [
+ 'nil', 'true', 'false'
+ ]
+
+ opWords = [
+ 'and', 'or', 'not', 'xor', 'shl', 'shr', 'div', 'mod', 'in',
+ 'notin', 'is', 'isnot'
+ ]
+
+ types = [
+ 'int', 'int8', 'int16', 'int32', 'int64', 'float', 'float32', 'float64',
+ 'bool', 'char', 'range', 'array', 'seq', 'set', 'string'
+ ]
+
+ tokens = {
+ 'root': [
+ (r'##.*$', String.Doc),
+ (r'#.*$', Comment),
+ (r'\*|=|>|<|\+|-|/|@|\$|~|&|%|\!|\?|\||\\|\[|\]', Operator),
+ (r'\.\.|\.|,|[\.|\.]|{\.|\.}|\(\.|\.\)|{|}|\(|\)|:|\^|`|;',
+ Punctuation),
+
+ # Strings
+ (r'(?:[\w]+)"', String, 'rdqs'),
+ (r'"""', String, 'tdqs'),
+ ('"', String, 'dqs'),
+
+ # Char
+ ("'", String.Char, 'chars'),
+
+ # Keywords
+ (r'(%s)\b' % underscorize(opWords), Operator.Word),
+ (r'(p_?r_?o_?c_?\s)(?![\(\[\]])', Keyword, 'funcname'),
+ (r'(%s)\b' % underscorize(keywords), Keyword),
+ (r'(%s)\b' % underscorize(['from', 'import', 'include']),
+ Keyword.Namespace),
+ (r'(v_?a_?r)\b', Keyword.Declaration),
+ (r'(%s)\b' % underscorize(types), Keyword.Type),
+ (r'(%s)\b' % underscorize(keywordsPseudo), Keyword.Pseudo),
+ # Identifiers
+ (r'\b((?![_\d])\w)(((?!_)\w)|(_(?!_)\w))*', Name),
+ # Numbers
+ (r'[0-9][0-9_]*(?=([eE.]|\'[fF](32|64)))',
+ Number.Float, ('float-suffix', 'float-number')),
+ (r'0[xX][a-fA-F0-9][a-fA-F0-9_]*', Number.Hex, 'int-suffix'),
+ (r'0[bB][01][01_]*', Number, 'int-suffix'),
+ (r'0o[0-7][0-7_]*', Number.Oct, 'int-suffix'),
+ (r'[0-9][0-9_]*', Number.Integer, 'int-suffix'),
+ # Whitespace
+ (r'\s+', Text),
+ (r'.+$', Error),
+ ],
+ 'chars': [
+ (r'\\([\\abcefnrtvl"\']|x[a-fA-F0-9]{2}|[0-9]{1,3})', String.Escape),
+ (r"'", String.Char, '#pop'),
+ (r".", String.Char)
+ ],
+ 'strings': [
+ (r'(?<!\$)\$(\d+|#|\w+)+', String.Interpol),
+ (r'[^\\\'"\$\n]+', String),
+ # quotes, dollars and backslashes must be parsed one at a time
+ (r'[\'"\\]', String),
+ # unhandled string formatting sign
+ (r'\$', String)
+ # newlines are an error (use "nl" state)
+ ],
+ 'dqs': [
+ (r'\\([\\abcefnrtvl"\']|\n|x[a-fA-F0-9]{2}|[0-9]{1,3})',
+ String.Escape),
+ (r'"', String, '#pop'),
+ include('strings')
+ ],
+ 'rdqs': [
+ (r'"(?!")', String, '#pop'),
+ (r'""', String.Escape),
+ include('strings')
+ ],
+ 'tdqs': [
+ (r'"""(?!")', String, '#pop'),
+ include('strings'),
+ include('nl')
+ ],
+ 'funcname': [
+ (r'((?![\d_])\w)(((?!_)\w)|(_(?!_)\w))*', Name.Function, '#pop'),
+ (r'`.+`', Name.Function, '#pop')
+ ],
+ 'nl': [
+ (r'\n', String)
+ ],
+ 'float-number': [
+ (r'\.(?!\.)[0-9_]*', Number.Float),
+ (r'[eE][+-]?[0-9][0-9_]*', Number.Float),
+ (r'', Text, '#pop')
+ ],
+ 'float-suffix': [
+ (r'\'[fF](32|64)', Number.Float),
+ (r'', Text, '#pop')
+ ],
+ 'int-suffix': [
+ (r'\'[iI](32|64)', Number.Integer.Long),
+ (r'\'[iI](8|16)', Number.Integer),
+ (r'', Text, '#pop')
+ ],
+ }
diff --git a/pygments/lexers/dotnet.py b/pygments/lexers/dotnet.py
index 48feeb85..7c13e8a4 100644
--- a/pygments/lexers/dotnet.py
+++ b/pygments/lexers/dotnet.py
@@ -10,7 +10,8 @@
"""
import re
-from pygments.lexer import RegexLexer, DelegatingLexer, bygroups, using, this
+from pygments.lexer import RegexLexer, DelegatingLexer, bygroups, include, \
+ using, this
from pygments.token import Punctuation, \
Text, Comment, Operator, Keyword, Name, String, Number, Literal, Other
from pygments.util import get_choice_opt
@@ -18,8 +19,8 @@ from pygments import unistring as uni
from pygments.lexers.web import XmlLexer
-__all__ = ['CSharpLexer', 'BooLexer', 'VbNetLexer', 'CSharpAspxLexer',
- 'VbNetAspxLexer']
+__all__ = ['CSharpLexer', 'NemerleLexer', 'BooLexer', 'VbNetLexer',
+ 'CSharpAspxLexer', 'VbNetAspxLexer', 'FSharpLexer']
def _escape(st):
@@ -138,6 +139,164 @@ class CSharpLexer(RegexLexer):
RegexLexer.__init__(self, **options)
+class NemerleLexer(RegexLexer):
+ """
+ For `Nemerle <http://nemerle.org>`_ source code.
+
+ Additional options accepted:
+
+ `unicodelevel`
+ Determines which Unicode characters this lexer allows for identifiers.
+ The possible values are:
+
+ * ``none`` -- only the ASCII letters and numbers are allowed. This
+ is the fastest selection.
+ * ``basic`` -- all Unicode characters from the specification except
+ category ``Lo`` are allowed.
+ * ``full`` -- all Unicode characters as specified in the C# specs
+ are allowed. Note that this means a considerable slowdown since the
+ ``Lo`` category has more than 40,000 characters in it!
+
+ The default value is ``basic``.
+
+ *New in Pygments 1.5.*
+ """
+
+ name = 'Nemerle'
+ aliases = ['nemerle']
+ filenames = ['*.n']
+ mimetypes = ['text/x-nemerle'] # inferred
+
+ flags = re.MULTILINE | re.DOTALL | re.UNICODE
+
+ # for the range of allowed unicode characters in identifiers,
+ # see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
+
+ levels = {
+ 'none': '@?[_a-zA-Z][a-zA-Z0-9_]*',
+ 'basic': ('@?[_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + ']' +
+ '[' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl +
+ uni.Nd + uni.Pc + uni.Cf + uni.Mn + uni.Mc + ']*'),
+ 'full': ('@?(?:_|[^' +
+ _escape(uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl')) + '])'
+ + '[^' + _escape(uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo',
+ 'Nl', 'Nd', 'Pc', 'Cf', 'Mn',
+ 'Mc')) + ']*'),
+ }
+
+ tokens = {}
+ token_variants = True
+
+ for levelname, cs_ident in levels.items():
+ tokens[levelname] = {
+ 'root': [
+ # method names
+ (r'^([ \t]*(?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type
+ r'(' + cs_ident + ')' # method name
+ r'(\s*)(\()', # signature start
+ bygroups(using(this), Name.Function, Text, Punctuation)),
+ (r'^\s*\[.*?\]', Name.Attribute),
+ (r'[^\S\n]+', Text),
+ (r'\\\n', Text), # line continuation
+ (r'//.*?\n', Comment.Single),
+ (r'/[*](.|\n)*?[*]/', Comment.Multiline),
+ (r'\n', Text),
+ (r'\$\s*"', String, 'splice-string'),
+ (r'\$\s*<#', String, 'splice-string2'),
+ (r'<#', String, 'recursive-string'),
+
+ (r'(<\[)\s*(' + cs_ident + ':)?', Keyword),
+ (r'\]\>', Keyword),
+
+ # quasiquotation only
+ (r'\$' + cs_ident, Name),
+ (r'(\$)(\()', bygroups(Name, Punctuation), 'splice-string-content'),
+
+ (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation),
+ (r'[{}]', Punctuation),
+ (r'@"(\\\\|\\"|[^"])*"', String),
+ (r'"(\\\\|\\"|[^"\n])*["\n]', String),
+ (r"'\\.'|'[^\\]'", String.Char),
+ (r"0[xX][0-9a-fA-F]+[Ll]?", Number),
+ (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFLdD]?", Number),
+ (r'#[ \t]*(if|endif|else|elif|define|undef|'
+ r'line|error|warning|region|endregion|pragma)\b.*?\n',
+ Comment.Preproc),
+ (r'\b(extern)(\s+)(alias)\b', bygroups(Keyword, Text,
+ Keyword)),
+ (r'(abstract|and|as|base|catch|def|delegate|'
+ r'enum|event|extern|false|finally|'
+ r'fun|implements|interface|internal|'
+ r'is|macro|match|matches|module|mutable|new|'
+ r'null|out|override|params|partial|private|'
+ r'protected|public|ref|sealed|static|'
+ r'syntax|this|throw|true|try|type|typeof|'
+ r'virtual|volatile|when|where|with|'
+ r'assert|assert2|async|break|checked|continue|do|else|'
+ r'ensures|for|foreach|if|late|lock|new|nolate|'
+ r'otherwise|regexp|repeat|requires|return|surroundwith|'
+ r'unchecked|unless|using|while|yield)\b', Keyword),
+ (r'(global)(::)', bygroups(Keyword, Punctuation)),
+ (r'(bool|byte|char|decimal|double|float|int|long|object|sbyte|'
+ r'short|string|uint|ulong|ushort|void|array|list)\b\??',
+ Keyword.Type),
+ (r'(:>?)\s*(' + cs_ident + r'\??)',
+ bygroups(Punctuation, Keyword.Type)),
+ (r'(class|struct|variant|module)(\s+)',
+ bygroups(Keyword, Text), 'class'),
+ (r'(namespace|using)(\s+)', bygroups(Keyword, Text),
+ 'namespace'),
+ (cs_ident, Name),
+ ],
+ 'class': [
+ (cs_ident, Name.Class, '#pop')
+ ],
+ 'namespace': [
+ (r'(?=\()', Text, '#pop'), # using (resource)
+ ('(' + cs_ident + r'|\.)+', Name.Namespace, '#pop')
+ ],
+ 'splice-string': [
+ (r'[^"$]', String),
+ (r'\$' + cs_ident, Name),
+ (r'(\$)(\()', bygroups(Name, Punctuation),
+ 'splice-string-content'),
+ (r'\\"', String),
+ (r'"', String, '#pop')
+ ],
+ 'splice-string2': [
+ (r'[^#<>$]', String),
+ (r'\$' + cs_ident, Name),
+ (r'(\$)(\()', bygroups(Name, Punctuation),
+ 'splice-string-content'),
+ (r'<#', String, '#push'),
+ (r'#>', String, '#pop')
+ ],
+ 'recursive-string': [
+ (r'[^#<>]', String),
+ (r'<#', String, '#push'),
+ (r'#>', String, '#pop')
+ ],
+ 'splice-string-content': [
+ (r'if|match', Keyword),
+ (r'[~!%^&*+=|\[\]:;,.<>/?-]', Punctuation),
+ (cs_ident, Name),
+ (r'\(', Punctuation, '#push'),
+ (r'\)', Punctuation, '#pop')
+ ]
+ }
+
+ def __init__(self, **options):
+ level = get_choice_opt(options, 'unicodelevel', self.tokens.keys(),
+ 'basic')
+ if level not in self._all_tokens:
+ # compile the regexes now
+ self._tokens = self.__class__.process_tokendef(level)
+ else:
+ self._tokens = self._all_tokens[level]
+
+ RegexLexer.__init__(self, **options)
+
+
class BooLexer(RegexLexer):
"""
For `Boo <http://boo.codehaus.org/>`_ source code.
@@ -365,3 +524,107 @@ class VbNetAspxLexer(DelegatingLexer):
return 0.2
elif re.search(r'script[^>]+language=["\']vb', text, re.I) is not None:
return 0.15
+
+
+# Very close to functional.OcamlLexer
+class FSharpLexer(RegexLexer):
+ """
+ For the F# language.
+
+ *New in Pygments 1.5.*
+ """
+
+ name = 'FSharp'
+ aliases = ['fsharp']
+ filenames = ['*.fs', '*.fsi']
+ mimetypes = ['text/x-fsharp']
+
+ keywords = [
+ 'abstract', 'and', 'as', 'assert', 'base', 'begin', 'class',
+ 'default', 'delegate', 'do', 'do!', 'done', 'downcast',
+ 'downto', 'elif', 'else', 'end', 'exception', 'extern',
+ 'false', 'finally', 'for', 'fun', 'function', 'global', 'if',
+ 'in', 'inherit', 'inline', 'interface', 'internal', 'lazy',
+ 'let', 'let!', 'match', 'member', 'module', 'mutable',
+ 'namespace', 'new', 'null', 'of', 'open', 'or', 'override',
+ 'private', 'public', 'rec', 'return', 'return!', 'sig',
+ 'static', 'struct', 'then', 'to', 'true', 'try', 'type',
+ 'upcast', 'use', 'use!', 'val', 'void', 'when', 'while',
+ 'with', 'yield', 'yield!'
+ ]
+ keyopts = [
+ '!=','#','&','&&','\(','\)','\*','\+',',','-',
+ '-\.','->','\.','\.\.',':','::',':=',':>',';',';;','<',
+ '<-','>','>]','\?','\?\?','\[','\[<','\[>','\[\|',
+ ']','_','`','{','\|','\|]','}','~','<@','=','@>'
+ ]
+
+ operators = r'[!$%&*+\./:<=>?@^|~-]'
+ word_operators = ['and', 'asr', 'land', 'lor', 'lsl', 'lxor', 'mod', 'not', 'or']
+ prefix_syms = r'[!?~]'
+ infix_syms = r'[=<>@^|&+\*/$%-]'
+ primitives = ['unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array',
+ 'byte', 'sbyte', 'int16', 'uint16', 'uint32', 'int64', 'uint64'
+ 'nativeint', 'unativeint', 'decimal', 'void', 'float32', 'single',
+ 'double']
+
+ tokens = {
+ 'escape-sequence': [
+ (r'\\[\\\"\'ntbr]', String.Escape),
+ (r'\\[0-9]{3}', String.Escape),
+ (r'\\x[0-9a-fA-F]{2}', String.Escape),
+ ],
+ 'root': [
+ (r'\s+', Text),
+ (r'false|true|\(\)|\[\]', Name.Builtin.Pseudo),
+ (r'\b([A-Z][A-Za-z0-9_\']*)(?=\s*\.)',
+ Name.Namespace, 'dotted'),
+ (r'\b([A-Z][A-Za-z0-9_\']*)', Name.Class),
+ (r'//.*?\n', Comment.Single),
+ (r'\(\*', Comment, 'comment'),
+ (r'\b(%s)\b' % '|'.join(keywords), Keyword),
+ (r'(%s)' % '|'.join(keyopts), Operator),
+ (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator),
+ (r'\b(%s)\b' % '|'.join(word_operators), Operator.Word),
+ (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type),
+
+ (r'#[ \t]*(if|endif|else|line|nowarn|light)\b.*?\n',
+ Comment.Preproc),
+
+ (r"[^\W\d][\w']*", Name),
+
+ (r'\d[\d_]*', Number.Integer),
+ (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
+ (r'0[oO][0-7][0-7_]*', Number.Oct),
+ (r'0[bB][01][01_]*', Number.Binary),
+ (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float),
+
+ (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'",
+ String.Char),
+ (r"'.'", String.Char),
+ (r"'", Keyword), # a stray quote is another syntax element
+
+ (r'"', String.Double, 'string'),
+
+ (r'[~?][a-z][\w\']*:', Name.Variable),
+ ],
+ 'comment': [
+ (r'[^(*)]+', Comment),
+ (r'\(\*', Comment, '#push'),
+ (r'\*\)', Comment, '#pop'),
+ (r'[(*)]', Comment),
+ ],
+ 'string': [
+ (r'[^\\"]+', String.Double),
+ include('escape-sequence'),
+ (r'\\\n', String.Double),
+ (r'"', String.Double, '#pop'),
+ ],
+ 'dotted': [
+ (r'\s+', Text),
+ (r'\.', Punctuation),
+ (r'[A-Z][A-Za-z0-9_\']*(?=\s*\.)', Name.Namespace),
+ (r'[A-Z][A-Za-z0-9_\']*', Name.Class, '#pop'),
+ (r'[a-z_][A-Za-z0-9_\']*', Name, '#pop'),
+ ],
+ }
diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py
index 85f4b624..94934cb1 100644
--- a/pygments/lexers/functional.py
+++ b/pygments/lexers/functional.py
@@ -36,7 +36,7 @@ class SchemeLexer(RegexLexer):
"""
name = 'Scheme'
aliases = ['scheme', 'scm']
- filenames = ['*.scm']
+ filenames = ['*.scm', '*.ss', '*.rkt']
mimetypes = ['text/x-scheme', 'application/x-scheme']
# list of known keywords and builtins taken form vim 6.4 scheme.vim
@@ -656,7 +656,7 @@ class ErlangLexer(RegexLexer):
'universaltime_to_localtime', 'unlink', 'unregister', 'whereis'
]
- operators = r'(\+|-|\*|/|<|>|=|==|/=|=:=|=/=|=<|>=|\+\+|--|<-|!)'
+ operators = r'(\+|-|\*|/|<|>|=|==|/=|=:=|=/=|=<|>=|\+\+|--|<-|!|\?)'
word_operators = [
'and', 'andalso', 'band', 'bnot', 'bor', 'bsl', 'bsr', 'bxor',
'div', 'not', 'or', 'orelse', 'rem', 'xor'
diff --git a/pygments/lexers/pypylog.py b/pygments/lexers/pypylog.py
index 85cb271c..f2363c5d 100644
--- a/pygments/lexers/pypylog.py
+++ b/pygments/lexers/pypylog.py
@@ -29,7 +29,7 @@ class PyPyLogLexer(RegexLexer):
(r"[ifp]\d+", Name),
(r"ptr\d+", Name),
- (r"(\()([\w_]+)(\))", bygroups(Punctuation, Name.Builtin, Punctuation)),
+ (r"(\()([\w_]+(?:\.[\w_]+)?)(\))", bygroups(Punctuation, Name.Builtin, Punctuation)),
(r"[\[\]=,()]", Punctuation),
(r"(\d+\.\d+|inf|-inf)", Number.Float),
(r"-?\d+", Number.Integer),
@@ -37,19 +37,22 @@ class PyPyLogLexer(RegexLexer):
(r"(None|descr|ConstClass|ConstPtr)", Name),
(r"<.*?>", Name.Builtin),
(r"(debug_merge_point|jump|finish)", Name.Class),
- (r"(int_add_ovf|int_add|int_sub_ovf|int_sub|int_mul_ovf|int_mul|int_or|"
- r"int_ge|int_gt|int_lt|int_is_zero|int_is_true|"
+ (r"(int_add_ovf|int_add|int_sub_ovf|int_sub|int_mul_ovf|int_mul|int_rshift|int_and|int_or|int_xor|"
+ r"int_eq|int_ne|int_ge|int_gt|int_le|int_lt|int_is_zero|int_is_true|"
r"uint_floordiv|"
+ r"uint_ge|uint_lt|"
r"float_add|float_sub|float_mul|float_truediv|"
r"float_eq|float_ne|float_gt|"
r"ptr_eq|"
r"force_token|"
r"call_may_force|call_assembler|call|"
- r"new_with_vtable|new_array|"
+ r"new_with_vtable|new_array|newstr|newunicode|new|"
r"arraylen_gc|"
- r"getarrayitem_gc|setarrayitem_gc|getarrayitem_raw|setarrayitem_raw|"
+ r"getarrayitem_gc_pure|getarrayitem_gc|setarrayitem_gc|getarrayitem_raw|setarrayitem_raw|"
r"getfield_gc_pure|getfield_gc|getfield_raw|setfield_gc|setfield_raw|"
- r"guard_true|guard_false|guard_value|guard_isnull|guard_nonnull_class|guard_class|guard_no_overflow|guard_not_forced|guard_no_exception)", Name.Builtin),
+ r"strgetitem|strsetitem|strlen|copystrcontent|"
+ r"unicodegetitem|unicodesetitem|unicodelen|"
+ r"guard_true|guard_false|guard_value|guard_isnull|guard_nonnull_class|guard_nonnull|guard_class|guard_no_overflow|guard_not_forced|guard_no_exception|guard_not_invalidated)", Name.Builtin),
include("extra-stuff"),
],
"jit-backend-counts": [
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index 11bc2175..9523a362 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -1986,6 +1986,12 @@ class XQueryLexer(ExtendedRegexLexer):
flags = re.DOTALL | re.MULTILINE | re.UNICODE
+ def punctuation_root_callback(lexer, match, ctx):
+ yield match.start(), Punctuation, match.group(1)
+ # transition to root always - don't pop off stack
+ ctx.stack = ['root']
+ ctx.pos = match.end()
+
def operator_root_callback(lexer, match, ctx):
yield match.start(), Operator, match.group(1)
# transition to root always - don't pop off stack
@@ -2167,6 +2173,11 @@ class XQueryLexer(ExtendedRegexLexer):
ctx.stack = ['root']#.append('root')
ctx.pos = match.end()
+ def pushstate_operator_attribute_callback(lexer, match, ctx):
+ yield match.start(), Name.Attribute, match.group(1)
+ ctx.stack.append('operator')
+ ctx.pos = match.end()
+
def pushstate_operator_callback(lexer, match, ctx):
yield match.start(), Keyword, match.group(1)
yield match.start(), Text, match.group(2)
@@ -2192,19 +2203,22 @@ class XQueryLexer(ExtendedRegexLexer):
(r'(\{)', pushstate_root_callback),
(r'then|else|external|at|div|except', Keyword, 'root'),
+ (r'order by', Keyword, 'root'),
(r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'),
(r'and|or', Operator.Word, 'root'),
(r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)',
Operator.Word, 'root'),
(r'return|satisfies|to|union|where|preserve\s+strip',
Keyword, 'root'),
- (r'(::|;|>=|>>|>|\[|<=|<<|<|-|\*|!=|\+|//|/|\||:=|,|=)',
+ (r'(>=|>>|>|<=|<<|<|-|\*|!=|\+|\||:=|=)',
operator_root_callback),
+ (r'(::|;|\[|//|/|,)',
+ punctuation_root_callback),
(r'(castable|cast)(\s+)(as)',
bygroups(Keyword, Text, Keyword), 'singletype'),
- (r'(instance)(\s+)(of)|(treat)(\s+)(as)',
- bygroups(Keyword, Text, Keyword), 'itemtype'),
- (r'(case)|(as)', Keyword, 'itemtype'),
+ (r'(instance)(\s+)(of)', bygroups(Keyword, Text, Keyword), 'itemtype'),
+ (r'(treat)(\s+)(as)', bygroups(Keyword, Text, Keyword), 'itemtype'),
+ (r'case|as', Keyword, 'itemtype'),
(r'(\))(\s*)(as)',
bygroups(Punctuation, Text, Keyword), 'itemtype'),
(r'\$', Name.Variable, 'varname'),
@@ -2290,8 +2304,8 @@ class XQueryLexer(ExtendedRegexLexer):
bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'),
(r'(castable|cast)(\s+)(as)',
bygroups(Keyword, Text, Keyword), 'singletype'),
- (r'(instance)(\s+)(of)|(treat)(\s+)(as)',
- bygroups(Keyword, Text, Keyword)),
+ (r'(treat)(\s+)(as)', bygroups(Keyword, Text, Keyword)),
+ (r'(instance)(\s+)(of)', bygroups(Keyword, Text, Keyword)),
(r'case|as', Keyword, 'itemtype'),
(r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
(ncname + r'(:\*)', Keyword.Type, 'operator'),
@@ -2557,9 +2571,9 @@ class XQueryLexer(ExtendedRegexLexer):
(r'(catch)(\s*)(\()(\$)',
bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'),
- (r'@' + qname, Name.Attribute),
- (r'@\*', Name.Attribute),
- (r'@' + ncname, Name.Attribute),
+ (r'(@' + qname + ')', pushstate_operator_attribute_callback),
+ (r'(@\*)', pushstate_operator_attribute_callback),
+ (r'(@' + ncname + ')', pushstate_operator_attribute_callback),
(r'//|/|\+|-|;|,|\(|\)', Punctuation),
diff --git a/tests/examplefiles/example.nim b/tests/examplefiles/example.nim
new file mode 100644
index 00000000..319da016
--- /dev/null
+++ b/tests/examplefiles/example.nim
@@ -0,0 +1,1010 @@
+import glib2, gtk2, gdk2, gtksourceview, dialogs, os, pango, osproc, strutils
+import pegs, streams
+import settings, types, cfg, search
+
+{.push callConv:cdecl.}
+
+const
+ NimrodProjectExt = ".nimprj"
+
+var win: types.MainWin
+win.Tabs = @[]
+
+search.win = addr(win)
+
+var lastSession: seq[string] = @[]
+
+var confParseFail = False # This gets set to true
+ # When there is an error parsing the config
+
+# Load the settings
+try:
+ win.settings = cfg.load(lastSession)
+except ECFGParse:
+ # TODO: Make the dialog show the exception
+ confParseFail = True
+ win.settings = cfg.defaultSettings()
+except EIO:
+ win.settings = cfg.defaultSettings()
+
+proc getProjectTab(): int =
+ for i in 0..high(win.tabs):
+ if win.tabs[i].filename.endswith(NimrodProjectExt): return i
+
+proc saveTab(tabNr: int, startpath: string) =
+ if tabNr < 0: return
+ if win.Tabs[tabNr].saved: return
+ var path = ""
+ if win.Tabs[tabNr].filename == "":
+ path = ChooseFileToSave(win.w, startpath)
+ # dialogs.nim STOCK_OPEN instead of STOCK_SAVE
+ else:
+ path = win.Tabs[tabNr].filename
+
+ if path != "":
+ var buffer = PTextBuffer(win.Tabs[tabNr].buffer)
+ # Get the text from the TextView
+ var startIter: TTextIter
+ buffer.getStartIter(addr(startIter))
+
+ var endIter: TTextIter
+ buffer.getEndIter(addr(endIter))
+
+ var text = buffer.getText(addr(startIter), addr(endIter), False)
+ # Save it to a file
+ var f: TFile
+ if open(f, path, fmWrite):
+ f.write(text)
+ f.close()
+
+ win.tempStuff.lastSaveDir = splitFile(path).dir
+
+ # Change the tab name and .Tabs.filename etc.
+ win.Tabs[tabNr].filename = path
+ win.Tabs[tabNr].saved = True
+ var name = extractFilename(path)
+
+ var cTab = win.Tabs[tabNr]
+ cTab.label.setText(name)
+ else:
+ error(win.w, "Unable to write to file")
+
+proc saveAllTabs() =
+ for i in 0..high(win.tabs):
+ saveTab(i, os.splitFile(win.tabs[i].filename).dir)
+
+# GTK Events
+# -- w(PWindow)
+proc destroy(widget: PWidget, data: pgpointer) {.cdecl.} =
+ # gather some settings
+ win.settings.VPanedPos = PPaned(win.sourceViewTabs.getParent()).getPosition()
+ win.settings.winWidth = win.w.allocation.width
+ win.settings.winHeight = win.w.allocation.height
+
+ # save the settings
+ win.save()
+ # then quit
+ main_quit()
+
+proc delete_event(widget: PWidget, event: PEvent, user_data: pgpointer): bool =
+ var quit = True
+ for i in low(win.Tabs)..len(win.Tabs)-1:
+ if not win.Tabs[i].saved:
+ var askSave = dialogNewWithButtons("", win.w, 0,
+ STOCK_SAVE, RESPONSE_ACCEPT, STOCK_CANCEL,
+ RESPONSE_CANCEL,
+ "Close without saving", RESPONSE_REJECT, nil)
+ askSave.setTransientFor(win.w)
+ # TODO: Make this dialog look better
+ var label = labelNew(win.Tabs[i].filename &
+ " is unsaved, would you like to save it ?")
+ PBox(askSave.vbox).pack_start(label, False, False, 0)
+ label.show()
+
+ var resp = askSave.run()
+ gtk2.destroy(PWidget(askSave))
+ case resp
+ of RESPONSE_ACCEPT:
+ saveTab(i, os.splitFile(win.tabs[i].filename).dir)
+ quit = True
+ of RESPONSE_CANCEL:
+ quit = False
+ break
+ of RESPONSE_REJECT:
+ quit = True
+ else:
+ quit = False
+ break
+
+ # If False is returned the window will close
+ return not quit
+
+proc windowState_Changed(widget: PWidget, event: PEventWindowState,
+ user_data: pgpointer) =
+ win.settings.winMaximized = (event.newWindowState and
+ WINDOW_STATE_MAXIMIZED) != 0
+
+# -- SourceView(PSourceView) & SourceBuffer
+proc updateStatusBar(buffer: PTextBuffer){.cdecl.} =
+ # Incase this event gets fired before
+ # bottomBar is initialized
+ if win.bottomBar != nil and not win.tempStuff.stopSBUpdates:
+ var iter: TTextIter
+
+ win.bottomBar.pop(0)
+ buffer.getIterAtMark(addr(iter), buffer.getInsert())
+ var row = getLine(addr(iter)) + 1
+ var col = getLineOffset(addr(iter))
+ discard win.bottomBar.push(0, "Line: " & $row & " Column: " & $col)
+
+proc cursorMoved(buffer: PTextBuffer, location: PTextIter,
+ mark: PTextMark, user_data: pgpointer){.cdecl.} =
+ updateStatusBar(buffer)
+
+proc onCloseTab(btn: PButton, user_data: PWidget) =
+ if win.sourceViewTabs.getNPages() > 1:
+ var tab = win.sourceViewTabs.pageNum(user_data)
+ win.sourceViewTabs.removePage(tab)
+
+ win.Tabs.delete(tab)
+
+proc onSwitchTab(notebook: PNotebook, page: PNotebookPage, pageNum: guint,
+ user_data: pgpointer) =
+ if win.Tabs.len()-1 >= pageNum:
+ win.w.setTitle("Aporia IDE - " & win.Tabs[pageNum].filename)
+
+proc createTabLabel(name: string, t_child: PWidget): tuple[box: PWidget,
+ label: PLabel] =
+ var box = hboxNew(False, 0)
+ var label = labelNew(name)
+ var closebtn = buttonNew()
+ closeBtn.setLabel(nil)
+ var iconSize = iconSizeFromName("tabIconSize")
+ if iconSize == 0:
+ iconSize = iconSizeRegister("tabIconSize", 10, 10)
+ var image = imageNewFromStock(STOCK_CLOSE, iconSize)
+ discard gSignalConnect(closebtn, "clicked", G_Callback(onCloseTab), t_child)
+ closebtn.setImage(image)
+ gtk2.setRelief(closebtn, RELIEF_NONE)
+ box.packStart(label, True, True, 0)
+ box.packEnd(closebtn, False, False, 0)
+ box.showAll()
+ return (box, label)
+
+proc changed(buffer: PTextBuffer, user_data: pgpointer) =
+ # Update the 'Line & Column'
+ #updateStatusBar(buffer)
+
+ # Change the tabs state to 'unsaved'
+ # and add '*' to the Tab Name
+ var current = win.SourceViewTabs.getCurrentPage()
+ var name = ""
+ if win.Tabs[current].filename == "":
+ win.Tabs[current].saved = False
+ name = "Untitled *"
+ else:
+ win.Tabs[current].saved = False
+ name = extractFilename(win.Tabs[current].filename) & " *"
+
+ var cTab = win.Tabs[current]
+ cTab.label.setText(name)
+
+# Other(Helper) functions
+
+proc initSourceView(SourceView: var PWidget, scrollWindow: var PScrolledWindow,
+ buffer: var PSourceBuffer) =
+ # This gets called by addTab
+ # Each tabs creates a new SourceView
+ # SourceScrolledWindow(ScrolledWindow)
+ scrollWindow = scrolledWindowNew(nil, nil)
+ scrollWindow.setPolicy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ scrollWindow.show()
+
+ # SourceView(gtkSourceView)
+ SourceView = sourceViewNew(buffer)
+ PSourceView(SourceView).setInsertSpacesInsteadOfTabs(True)
+ PSourceView(SourceView).setIndentWidth(win.settings.indentWidth)
+ PSourceView(SourceView).setShowLineNumbers(win.settings.showLineNumbers)
+ PSourceView(SourceView).setHighlightCurrentLine(
+ win.settings.highlightCurrentLine)
+ PSourceView(SourceView).setShowRightMargin(win.settings.rightMargin)
+ PSourceView(SourceView).setAutoIndent(win.settings.autoIndent)
+
+ var font = font_description_from_string(win.settings.font)
+ SourceView.modifyFont(font)
+
+ scrollWindow.add(SourceView)
+ SourceView.show()
+
+ buffer.setHighlightMatchingBrackets(
+ win.settings.highlightMatchingBrackets)
+
+ # UGLY workaround for yet another compiler bug:
+ discard gsignalConnect(buffer, "mark-set",
+ GCallback(aporia.cursorMoved), nil)
+ discard gsignalConnect(buffer, "changed", GCallback(aporia.changed), nil)
+
+ # -- Set the syntax highlighter scheme
+ buffer.setScheme(win.scheme)
+
+proc addTab(name, filename: string) =
+ ## Adds a tab, if filename is not "" reads the file. And sets
+ ## the tabs SourceViews text to that files contents.
+ assert(win.nimLang != nil)
+ var buffer: PSourceBuffer = sourceBufferNew(win.nimLang)
+
+ if filename != nil and filename != "":
+ var lang = win.langMan.guessLanguage(filename, nil)
+ if lang != nil:
+ buffer.setLanguage(lang)
+ else:
+ buffer.setHighlightSyntax(False)
+
+ var nam = name
+ if nam == "": nam = "Untitled"
+ if filename == "": nam.add(" *")
+ elif filename != "" and name == "":
+ # Disable the undo/redo manager.
+ buffer.begin_not_undoable_action()
+
+ # Load the file.
+ var file: string = readFile(filename)
+ if file != nil:
+ buffer.set_text(file, len(file))
+
+ # Enable the undo/redo manager.
+ buffer.end_not_undoable_action()
+
+ # Get the name.ext of the filename, for the tabs title
+ nam = extractFilename(filename)
+
+ # Init the sourceview
+ var sourceView: PWidget
+ var scrollWindow: PScrolledWindow
+ initSourceView(sourceView, scrollWindow, buffer)
+
+ var (TabLabel, labelText) = createTabLabel(nam, scrollWindow)
+ # Add a tab
+ discard win.SourceViewTabs.appendPage(scrollWindow, TabLabel)
+
+ var nTab: Tab
+ nTab.buffer = buffer
+ nTab.sourceView = sourceView
+ nTab.label = labelText
+ nTab.saved = (filename != "")
+ nTab.filename = filename
+ win.Tabs.add(nTab)
+
+ PTextView(SourceView).setBuffer(nTab.buffer)
+
+# GTK Events Contd.
+# -- TopMenu & TopBar
+
+proc newFile(menuItem: PMenuItem, user_data: pgpointer) =
+ addTab("", "")
+ win.sourceViewTabs.setCurrentPage(win.Tabs.len()-1)
+
+proc openFile(menuItem: PMenuItem, user_data: pgpointer) =
+ var startpath = ""
+ var currPage = win.SourceViewTabs.getCurrentPage()
+ if currPage <% win.tabs.len:
+ startpath = os.splitFile(win.tabs[currPage].filename).dir
+
+ if startpath.len == 0:
+ # Use lastSavePath as the startpath
+ startpath = win.tempStuff.lastSaveDir
+ if startpath.len == 0:
+ startpath = os.getHomeDir()
+
+ var files = ChooseFilesToOpen(win.w, startpath)
+ if files.len() > 0:
+ for f in items(files):
+ try:
+ addTab("", f)
+ except EIO:
+ error(win.w, "Unable to read from file")
+ # Switch to the newly created tab
+ win.sourceViewTabs.setCurrentPage(win.Tabs.len()-1)
+
+proc saveFile_Activate(menuItem: PMenuItem, user_data: pgpointer) =
+ var current = win.SourceViewTabs.getCurrentPage()
+ saveTab(current, os.splitFile(win.tabs[current].filename).dir)
+
+proc saveFileAs_Activate(menuItem: PMenuItem, user_data: pgpointer) =
+ var current = win.SourceViewTabs.getCurrentPage()
+ var (filename, saved) = (win.Tabs[current].filename, win.Tabs[current].saved)
+
+ win.Tabs[current].saved = False
+ win.Tabs[current].filename = ""
+ saveTab(current, os.splitFile(filename).dir)
+ # If the user cancels the save file dialog. Restore the previous filename
+ # and saved state
+ if win.Tabs[current].filename == "":
+ win.Tabs[current].filename = filename
+ win.Tabs[current].saved = saved
+
+proc undo(menuItem: PMenuItem, user_data: pgpointer) =
+ var current = win.SourceViewTabs.getCurrentPage()
+ if win.Tabs[current].buffer.canUndo():
+ win.Tabs[current].buffer.undo()
+
+proc redo(menuItem: PMenuItem, user_data: pgpointer) =
+ var current = win.SourceViewTabs.getCurrentPage()
+ if win.Tabs[current].buffer.canRedo():
+ win.Tabs[current].buffer.redo()
+
+proc find_Activate(menuItem: PMenuItem, user_data: pgpointer) =
+ # Get the selected text, and set the findEntry to it.
+ var currentTab = win.SourceViewTabs.getCurrentPage()
+ var insertIter: TTextIter
+ win.Tabs[currentTab].buffer.getIterAtMark(addr(insertIter),
+ win.Tabs[currentTab].buffer.getInsert())
+ var insertOffset = addr(insertIter).getOffset()
+
+ var selectIter: TTextIter
+ win.Tabs[currentTab].buffer.getIterAtMark(addr(selectIter),
+ win.Tabs[currentTab].buffer.getSelectionBound())
+ var selectOffset = addr(selectIter).getOffset()
+
+ if insertOffset != selectOffset:
+ var text = win.Tabs[currentTab].buffer.getText(addr(insertIter),
+ addr(selectIter), false)
+ win.findEntry.setText(text)
+
+ win.findBar.show()
+ win.findEntry.grabFocus()
+ win.replaceEntry.hide()
+ win.replaceLabel.hide()
+ win.replaceBtn.hide()
+ win.replaceAllBtn.hide()
+
+proc replace_Activate(menuitem: PMenuItem, user_data: pgpointer) =
+ win.findBar.show()
+ win.findEntry.grabFocus()
+ win.replaceEntry.show()
+ win.replaceLabel.show()
+ win.replaceBtn.show()
+ win.replaceAllBtn.show()
+
+proc settings_Activate(menuitem: PMenuItem, user_data: pgpointer) =
+ settings.showSettings(win)
+
+proc viewBottomPanel_Toggled(menuitem: PCheckMenuItem, user_data: pgpointer) =
+ win.settings.bottomPanelVisible = menuitem.itemGetActive()
+ if win.settings.bottomPanelVisible:
+ win.bottomPanelTabs.show()
+ else:
+ win.bottomPanelTabs.hide()
+
+var
+ pegLineError = peg"{[^(]*} '(' {\d+} ', ' \d+ ') Error:' \s* {.*}"
+ pegLineWarning = peg"{[^(]*} '(' {\d+} ', ' \d+ ') ' ('Warning:'/'Hint:') \s* {.*}"
+ pegOtherError = peg"'Error:' \s* {.*}"
+ pegSuccess = peg"'Hint: operation successful'.*"
+
+proc addText(textView: PTextView, text: string, colorTag: PTextTag = nil) =
+ if text != nil:
+ var iter: TTextIter
+ textView.getBuffer().getEndIter(addr(iter))
+
+ if colorTag == nil:
+ textView.getBuffer().insert(addr(iter), text, len(text))
+ else:
+ textView.getBuffer().insertWithTags(addr(iter), text, len(text), colorTag,
+ nil)
+
+proc createColor(textView: PTextView, name, color: string): PTextTag =
+ var tagTable = textView.getBuffer().getTagTable()
+ result = tagTable.tableLookup(name)
+ if result == nil:
+ result = textView.getBuffer().createTag(name, "foreground", color, nil)
+
+when not defined(os.findExe):
+ proc findExe(exe: string): string =
+ ## returns "" if the exe cannot be found
+ result = addFileExt(exe, os.exeExt)
+ if ExistsFile(result): return
+ var path = os.getEnv("PATH")
+ for candidate in split(path, pathSep):
+ var x = candidate / result
+ if ExistsFile(x): return x
+ result = ""
+
+proc GetCmd(cmd, filename: string): string =
+ var f = quoteIfContainsWhite(filename)
+ if cmd =~ peg"\s* '$' y'findExe' '(' {[^)]+} ')' {.*}":
+ var exe = quoteIfContainsWhite(findExe(matches[0]))
+ if exe.len == 0: exe = matches[0]
+ result = exe & " " & matches[1] % f
+ else:
+ result = cmd % f
+
+proc showBottomPanel() =
+ if not win.settings.bottomPanelVisible:
+ win.bottomPanelTabs.show()
+ win.settings.bottomPanelVisible = true
+ PCheckMenuItem(win.viewBottomPanelMenuItem).itemSetActive(true)
+ # Scroll to the end of the TextView
+ # This is stupid, it works sometimes... it's random
+ var endIter: TTextIter
+ win.outputTextView.getBuffer().getEndIter(addr(endIter))
+ discard win.outputTextView.scrollToIter(
+ addr(endIter), 0.25, False, 0.0, 0.0)
+
+proc compileRun(currentTab: int, shouldRun: bool) =
+ if win.Tabs[currentTab].filename.len == 0: return
+ # Clear the outputTextView
+ win.outputTextView.getBuffer().setText("", 0)
+
+ var outp = osProc.execProcess(GetCmd(win.settings.nimrodCmd,
+ win.Tabs[currentTab].filename))
+ # Colors
+ var normalTag = createColor(win.outputTextView, "normalTag", "#3d3d3d")
+ var errorTag = createColor(win.outputTextView, "errorTag", "red")
+ var warningTag = createColor(win.outputTextView, "warningTag", "darkorange")
+ var successTag = createColor(win.outputTextView, "successTag", "darkgreen")
+ for x in outp.splitLines():
+ if x =~ pegLineError / pegOtherError:
+ win.outputTextView.addText("\n" & x, errorTag)
+ elif x=~ pegSuccess:
+ win.outputTextView.addText("\n" & x, successTag)
+
+ # Launch the process
+ if shouldRun:
+ var filename = changeFileExt(win.Tabs[currentTab].filename, os.ExeExt)
+ var output = "\n" & osProc.execProcess(filename)
+ win.outputTextView.addText(output)
+ elif x =~ pegLineWarning:
+ win.outputTextView.addText("\n" & x, warningTag)
+ else:
+ win.outputTextView.addText("\n" & x, normalTag)
+ showBottomPanel()
+
+proc CompileCurrent_Activate(menuitem: PMenuItem, user_data: pgpointer) =
+ saveFile_Activate(nil, nil)
+ compileRun(win.SourceViewTabs.getCurrentPage(), false)
+
+proc CompileRunCurrent_Activate(menuitem: PMenuItem, user_data: pgpointer) =
+ saveFile_Activate(nil, nil)
+ compileRun(win.SourceViewTabs.getCurrentPage(), true)
+
+proc CompileProject_Activate(menuitem: PMenuItem, user_data: pgpointer) =
+ saveAllTabs()
+ compileRun(getProjectTab(), false)
+
+proc CompileRunProject_Activate(menuitem: PMenuItem, user_data: pgpointer) =
+ saveAllTabs()
+ compileRun(getProjectTab(), true)
+
+proc RunCustomCommand(cmd: string) =
+ saveFile_Activate(nil, nil)
+ var currentTab = win.SourceViewTabs.getCurrentPage()
+ if win.Tabs[currentTab].filename.len == 0 or cmd.len == 0: return
+ # Clear the outputTextView
+ win.outputTextView.getBuffer().setText("", 0)
+ var outp = osProc.execProcess(GetCmd(cmd, win.Tabs[currentTab].filename))
+ var normalTag = createColor(win.outputTextView, "normalTag", "#3d3d3d")
+ for x in outp.splitLines():
+ win.outputTextView.addText("\n" & x, normalTag)
+ showBottomPanel()
+
+proc RunCustomCommand1(menuitem: PMenuItem, user_data: pgpointer) =
+ RunCustomCommand(win.settings.customCmd1)
+
+proc RunCustomCommand2(menuitem: PMenuItem, user_data: pgpointer) =
+ RunCustomCommand(win.settings.customCmd2)
+
+proc RunCustomCommand3(menuitem: PMenuItem, user_data: pgpointer) =
+ RunCustomCommand(win.settings.customCmd3)
+
+# -- FindBar
+
+proc nextBtn_Clicked(button: PButton, user_data: pgpointer) = findText(True)
+proc prevBtn_Clicked(button: PButton, user_data: pgpointer) = findText(False)
+
+proc replaceBtn_Clicked(button: PButton, user_data: pgpointer) =
+ var currentTab = win.SourceViewTabs.getCurrentPage()
+ var start, theEnd: TTextIter
+ if not win.Tabs[currentTab].buffer.getSelectionBounds(
+ addr(start), addr(theEnd)):
+ # If no text is selected, try finding a match.
+ findText(True)
+ if not win.Tabs[currentTab].buffer.getSelectionBounds(
+ addr(start), addr(theEnd)):
+ # No match
+ return
+
+ # Remove the text
+ win.Tabs[currentTab].buffer.delete(addr(start), addr(theEnd))
+ # Insert the replacement
+ var text = getText(win.replaceEntry)
+ win.Tabs[currentTab].buffer.insert(addr(start), text, len(text))
+
+proc replaceAllBtn_Clicked(button: PButton, user_data: pgpointer) =
+ var find = getText(win.findEntry)
+ var replace = getText(win.replaceEntry)
+ discard replaceAll(find, replace)
+
+proc closeBtn_Clicked(button: PButton, user_data: pgpointer) =
+ win.findBar.hide()
+
+proc caseSens_Changed(radiomenuitem: PRadioMenuitem, user_data: pgpointer) =
+ win.settings.search = "casesens"
+proc caseInSens_Changed(radiomenuitem: PRadioMenuitem, user_data: pgpointer) =
+ win.settings.search = "caseinsens"
+proc style_Changed(radiomenuitem: PRadioMenuitem, user_data: pgpointer) =
+ win.settings.search = "style"
+proc regex_Changed(radiomenuitem: PRadioMenuitem, user_data: pgpointer) =
+ win.settings.search = "regex"
+proc peg_Changed(radiomenuitem: PRadioMenuitem, user_data: pgpointer) =
+ win.settings.search = "peg"
+
+proc extraBtn_Clicked(button: PButton, user_data: pgpointer) =
+ var extraMenu = menuNew()
+ var group: PGSList
+
+ var caseSensMenuItem = radio_menu_item_new(group, "Case sensitive")
+ extraMenu.append(caseSensMenuItem)
+ discard signal_connect(caseSensMenuItem, "toggled",
+ SIGNAL_FUNC(caseSens_Changed), nil)
+ caseSensMenuItem.show()
+ group = caseSensMenuItem.ItemGetGroup()
+
+ var caseInSensMenuItem = radio_menu_item_new(group, "Case insensitive")
+ extraMenu.append(caseInSensMenuItem)
+ discard signal_connect(caseInSensMenuItem, "toggled",
+ SIGNAL_FUNC(caseInSens_Changed), nil)
+ caseInSensMenuItem.show()
+ group = caseInSensMenuItem.ItemGetGroup()
+
+ var styleMenuItem = radio_menu_item_new(group, "Style insensitive")
+ extraMenu.append(styleMenuItem)
+ discard signal_connect(styleMenuItem, "toggled",
+ SIGNAL_FUNC(style_Changed), nil)
+ styleMenuItem.show()
+ group = styleMenuItem.ItemGetGroup()
+
+ var regexMenuItem = radio_menu_item_new(group, "Regex")
+ extraMenu.append(regexMenuItem)
+ discard signal_connect(regexMenuItem, "toggled",
+ SIGNAL_FUNC(regex_Changed), nil)
+ regexMenuItem.show()
+ group = regexMenuItem.ItemGetGroup()
+
+ var pegMenuItem = radio_menu_item_new(group, "Pegs")
+ extraMenu.append(pegMenuItem)
+ discard signal_connect(pegMenuItem, "toggled",
+ SIGNAL_FUNC(peg_Changed), nil)
+ pegMenuItem.show()
+
+ # Make the correct radio button active
+ case win.settings.search
+ of "casesens":
+ PCheckMenuItem(caseSensMenuItem).ItemSetActive(True)
+ of "caseinsens":
+ PCheckMenuItem(caseInSensMenuItem).ItemSetActive(True)
+ of "style":
+ PCheckMenuItem(styleMenuItem).ItemSetActive(True)
+ of "regex":
+ PCheckMenuItem(regexMenuItem).ItemSetActive(True)
+ of "peg":
+ PCheckMenuItem(pegMenuItem).ItemSetActive(True)
+
+ extraMenu.popup(nil, nil, nil, nil, 0, get_current_event_time())
+
+# GUI Initialization
+
+proc createAccelMenuItem(toolsMenu: PMenu, accGroup: PAccelGroup,
+ label: string, acc: gint,
+ action: proc (i: PMenuItem, p: pgpointer)) =
+ var result = menu_item_new(label)
+ result.addAccelerator("activate", accGroup, acc, 0, ACCEL_VISIBLE)
+ ToolsMenu.append(result)
+ show(result)
+ discard signal_connect(result, "activate", SIGNAL_FUNC(action), nil)
+
+proc createSeparator(menu: PMenu) =
+ var sep = separator_menu_item_new()
+ menu.append(sep)
+ sep.show()
+
+proc initTopMenu(MainBox: PBox) =
+ # Create a accelerator group, used for shortcuts
+ # like CTRL + S in SaveMenuItem
+ var accGroup = accel_group_new()
+ add_accel_group(win.w, accGroup)
+
+ # TopMenu(MenuBar)
+ var TopMenu = menuBarNew()
+
+ # FileMenu
+ var FileMenu = menuNew()
+
+ var NewMenuItem = menu_item_new("New") # New
+ FileMenu.append(NewMenuItem)
+ show(NewMenuItem)
+ discard signal_connect(NewMenuItem, "activate",
+ SIGNAL_FUNC(newFile), nil)
+
+ createSeparator(FileMenu)
+
+ var OpenMenuItem = menu_item_new("Open...") # Open...
+ # CTRL + O
+ OpenMenuItem.add_accelerator("activate", accGroup,
+ KEY_o, CONTROL_MASK, ACCEL_VISIBLE)
+ FileMenu.append(OpenMenuItem)
+ show(OpenMenuItem)
+ discard signal_connect(OpenMenuItem, "activate",
+ SIGNAL_FUNC(aporia.openFile), nil)
+
+ var SaveMenuItem = menu_item_new("Save") # Save
+ # CTRL + S
+ SaveMenuItem.add_accelerator("activate", accGroup,
+ KEY_s, CONTROL_MASK, ACCEL_VISIBLE)
+ FileMenu.append(SaveMenuItem)
+ show(SaveMenuItem)
+ discard signal_connect(SaveMenuItem, "activate",
+ SIGNAL_FUNC(saveFile_activate), nil)
+
+ var SaveAsMenuItem = menu_item_new("Save As...") # Save as...
+
+ SaveAsMenuItem.add_accelerator("activate", accGroup,
+ KEY_s, CONTROL_MASK or gdk2.SHIFT_MASK, ACCEL_VISIBLE)
+ FileMenu.append(SaveAsMenuItem)
+ show(SaveAsMenuItem)
+ discard signal_connect(SaveAsMenuItem, "activate",
+ SIGNAL_FUNC(saveFileAs_Activate), nil)
+
+ var FileMenuItem = menuItemNewWithMnemonic("_File")
+
+ FileMenuItem.setSubMenu(FileMenu)
+ FileMenuItem.show()
+ TopMenu.append(FileMenuItem)
+
+ # Edit menu
+ var EditMenu = menuNew()
+
+ var UndoMenuItem = menu_item_new("Undo") # Undo
+ EditMenu.append(UndoMenuItem)
+ show(UndoMenuItem)
+ discard signal_connect(UndoMenuItem, "activate",
+ SIGNAL_FUNC(aporia.undo), nil)
+
+ var RedoMenuItem = menu_item_new("Redo") # Undo
+ EditMenu.append(RedoMenuItem)
+ show(RedoMenuItem)
+ discard signal_connect(RedoMenuItem, "activate",
+ SIGNAL_FUNC(aporia.redo), nil)
+
+ createSeparator(EditMenu)
+
+ var FindMenuItem = menu_item_new("Find") # Find
+ FindMenuItem.add_accelerator("activate", accGroup,
+ KEY_f, CONTROL_MASK, ACCEL_VISIBLE)
+ EditMenu.append(FindMenuItem)
+ show(FindMenuItem)
+ discard signal_connect(FindMenuItem, "activate",
+ SIGNAL_FUNC(aporia.find_Activate), nil)
+
+ var ReplaceMenuItem = menu_item_new("Replace") # Replace
+ ReplaceMenuItem.add_accelerator("activate", accGroup,
+ KEY_h, CONTROL_MASK, ACCEL_VISIBLE)
+ EditMenu.append(ReplaceMenuItem)
+ show(ReplaceMenuItem)
+ discard signal_connect(ReplaceMenuItem, "activate",
+ SIGNAL_FUNC(aporia.replace_Activate), nil)
+
+ createSeparator(EditMenu)
+
+ var SettingsMenuItem = menu_item_new("Settings...") # Settings
+ EditMenu.append(SettingsMenuItem)
+ show(SettingsMenuItem)
+ discard signal_connect(SettingsMenuItem, "activate",
+ SIGNAL_FUNC(aporia.Settings_Activate), nil)
+
+ var EditMenuItem = menuItemNewWithMnemonic("_Edit")
+
+ EditMenuItem.setSubMenu(EditMenu)
+ EditMenuItem.show()
+ TopMenu.append(EditMenuItem)
+
+ # View menu
+ var ViewMenu = menuNew()
+
+ win.viewBottomPanelMenuItem = check_menu_item_new("Bottom Panel")
+ PCheckMenuItem(win.viewBottomPanelMenuItem).itemSetActive(
+ win.settings.bottomPanelVisible)
+ win.viewBottomPanelMenuItem.add_accelerator("activate", accGroup,
+ KEY_f9, CONTROL_MASK, ACCEL_VISIBLE)
+ ViewMenu.append(win.viewBottomPanelMenuItem)
+ show(win.viewBottomPanelMenuItem)
+ discard signal_connect(win.viewBottomPanelMenuItem, "toggled",
+ SIGNAL_FUNC(aporia.viewBottomPanel_Toggled), nil)
+
+ var ViewMenuItem = menuItemNewWithMnemonic("_View")
+
+ ViewMenuItem.setSubMenu(ViewMenu)
+ ViewMenuItem.show()
+ TopMenu.append(ViewMenuItem)
+
+
+ # Tools menu
+ var ToolsMenu = menuNew()
+
+ createAccelMenuItem(ToolsMenu, accGroup, "Compile current file",
+ KEY_F4, aporia.CompileCurrent_Activate)
+ createAccelMenuItem(ToolsMenu, accGroup, "Compile & run current file",
+ KEY_F5, aporia.CompileRunCurrent_Activate)
+ createSeparator(ToolsMenu)
+ createAccelMenuItem(ToolsMenu, accGroup, "Compile project",
+ KEY_F8, aporia.CompileProject_Activate)
+ createAccelMenuItem(ToolsMenu, accGroup, "Compile & run project",
+ KEY_F9, aporia.CompileRunProject_Activate)
+ createSeparator(ToolsMenu)
+ createAccelMenuItem(ToolsMenu, accGroup, "Run custom command 1",
+ KEY_F1, aporia.RunCustomCommand1)
+ createAccelMenuItem(ToolsMenu, accGroup, "Run custom command 2",
+ KEY_F2, aporia.RunCustomCommand2)
+ createAccelMenuItem(ToolsMenu, accGroup, "Run custom command 3",
+ KEY_F3, aporia.RunCustomCommand3)
+
+ var ToolsMenuItem = menuItemNewWithMnemonic("_Tools")
+
+ ToolsMenuItem.setSubMenu(ToolsMenu)
+ ToolsMenuItem.show()
+ TopMenu.append(ToolsMenuItem)
+
+ # Help menu
+ MainBox.packStart(TopMenu, False, False, 0)
+ TopMenu.show()
+
+proc initToolBar(MainBox: PBox) =
+ # TopBar(ToolBar)
+ var TopBar = toolbarNew()
+ TopBar.setStyle(TOOLBAR_ICONS)
+
+ var NewFileItem = TopBar.insertStock(STOCK_NEW, "New File",
+ "New File", SIGNAL_FUNC(aporia.newFile), nil, 0)
+ TopBar.appendSpace()
+ var OpenItem = TopBar.insertStock(STOCK_OPEN, "Open",
+ "Open", SIGNAL_FUNC(aporia.openFile), nil, -1)
+ var SaveItem = TopBar.insertStock(STOCK_SAVE, "Save",
+ "Save", SIGNAL_FUNC(saveFile_Activate), nil, -1)
+ TopBar.appendSpace()
+ var UndoItem = TopBar.insertStock(STOCK_UNDO, "Undo",
+ "Undo", SIGNAL_FUNC(aporia.undo), nil, -1)
+ var RedoItem = TopBar.insertStock(STOCK_REDO, "Redo",
+ "Redo", SIGNAL_FUNC(aporia.redo), nil, -1)
+
+ MainBox.packStart(TopBar, False, False, 0)
+ TopBar.show()
+
+proc initSourceViewTabs() =
+ win.SourceViewTabs = notebookNew()
+ #win.sourceViewTabs.dragDestSet(DEST_DEFAULT_DROP, nil, 0, ACTION_MOVE)
+ discard win.SourceViewTabs.signalConnect(
+ "switch-page", SIGNAL_FUNC(onSwitchTab), nil)
+ #discard win.SourceViewTabs.signalConnect(
+ # "drag-drop", SIGNAL_FUNC(svTabs_DragDrop), nil)
+ #discard win.SourceViewTabs.signalConnect(
+ # "drag-data-received", SIGNAL_FUNC(svTabs_DragDataRecv), nil)
+ #discard win.SourceViewTabs.signalConnect(
+ # "drag-motion", SIGNAL_FUNC(svTabs_DragMotion), nil)
+ win.SourceViewTabs.set_scrollable(True)
+
+ win.SourceViewTabs.show()
+ if lastSession.len != 0:
+ for i in 0 .. len(lastSession)-1:
+ var splitUp = lastSession[i].split('|')
+ var (filename, offset) = (splitUp[0], splitUp[1])
+ addTab("", filename)
+
+ var iter: TTextIter
+ win.Tabs[i].buffer.getIterAtOffset(addr(iter), offset.parseInt())
+ win.Tabs[i].buffer.moveMarkByName("insert", addr(iter))
+ win.Tabs[i].buffer.moveMarkByName("selection_bound", addr(iter))
+
+ # TODO: Fix this..... :(
+ discard PTextView(win.Tabs[i].sourceView).
+ scrollToIter(addr(iter), 0.25, true, 0.0, 0.0)
+ else:
+ addTab("", "")
+
+ # This doesn't work :\
+ win.Tabs[0].sourceView.grabFocus()
+
+
+proc initBottomTabs() =
+ win.bottomPanelTabs = notebookNew()
+ if win.settings.bottomPanelVisible:
+ win.bottomPanelTabs.show()
+
+ # output tab
+ var tabLabel = labelNew("Output")
+ var outputTab = vboxNew(False, 0)
+ discard win.bottomPanelTabs.appendPage(outputTab, tabLabel)
+ # Compiler tabs, gtktextview
+ var outputScrolledWindow = scrolledwindowNew(nil, nil)
+ outputScrolledWindow.setPolicy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ outputTab.packStart(outputScrolledWindow, true, true, 0)
+ outputScrolledWindow.show()
+
+ win.outputTextView = textviewNew()
+ outputScrolledWindow.add(win.outputTextView)
+ win.outputTextView.show()
+
+ outputTab.show()
+
+proc initTAndBP(MainBox: PBox) =
+ # This init's the HPaned, which splits the sourceViewTabs
+ # and the BottomPanelTabs
+ initSourceViewTabs()
+ initBottomTabs()
+
+ var TAndBPVPaned = vpanedNew()
+ tandbpVPaned.pack1(win.sourceViewTabs, resize=True, shrink=False)
+ tandbpVPaned.pack2(win.bottomPanelTabs, resize=False, shrink=False)
+ MainBox.packStart(TAndBPVPaned, True, True, 0)
+ tandbpVPaned.setPosition(win.settings.VPanedPos)
+ TAndBPVPaned.show()
+
+proc initFindBar(MainBox: PBox) =
+ # Create a fixed container
+ win.findBar = HBoxNew(False, 0)
+ win.findBar.setSpacing(4)
+
+ # Add a Label 'Find'
+ var findLabel = labelNew("Find:")
+ win.findBar.packStart(findLabel, False, False, 0)
+ findLabel.show()
+
+ # Add a (find) text entry
+ win.findEntry = entryNew()
+ win.findBar.packStart(win.findEntry, False, False, 0)
+ discard win.findEntry.signalConnect("activate", SIGNAL_FUNC(
+ aporia.nextBtn_Clicked), nil)
+ win.findEntry.show()
+ var rq: TRequisition
+ win.findEntry.sizeRequest(addr(rq))
+
+ # Make the (find) text entry longer
+ win.findEntry.set_size_request(190, rq.height)
+
+ # Add a Label 'Replace'
+ # - This Is only shown, when the 'Search & Replace'(CTRL + H) is shown
+ win.replaceLabel = labelNew("Replace:")
+ win.findBar.packStart(win.replaceLabel, False, False, 0)
+ #replaceLabel.show()
+
+ # Add a (replace) text entry
+ # - This Is only shown, when the 'Search & Replace'(CTRL + H) is shown
+ win.replaceEntry = entryNew()
+ win.findBar.packStart(win.replaceEntry, False, False, 0)
+ #win.replaceEntry.show()
+ var rq1: TRequisition
+ win.replaceEntry.sizeRequest(addr(rq1))
+
+ # Make the (replace) text entry longer
+ win.replaceEntry.set_size_request(100, rq1.height)
+
+ # Find next button
+ var nextBtn = buttonNew("Next")
+ win.findBar.packStart(nextBtn, false, false, 0)
+ discard nextBtn.signalConnect("clicked",
+ SIGNAL_FUNC(aporia.nextBtn_Clicked), nil)
+ nextBtn.show()
+ var nxtBtnRq: TRequisition
+ nextBtn.sizeRequest(addr(nxtBtnRq))
+
+ # Find previous button
+ var prevBtn = buttonNew("Previous")
+ win.findBar.packStart(prevBtn, false, false, 0)
+ discard prevBtn.signalConnect("clicked",
+ SIGNAL_FUNC(aporia.prevBtn_Clicked), nil)
+ prevBtn.show()
+
+ # Replace button
+ # - This Is only shown, when the 'Search & Replace'(CTRL + H) is shown
+ win.replaceBtn = buttonNew("Replace")
+ win.findBar.packStart(win.replaceBtn, false, false, 0)
+ discard win.replaceBtn.signalConnect("clicked",
+ SIGNAL_FUNC(aporia.replaceBtn_Clicked), nil)
+ #replaceBtn.show()
+
+ # Replace all button
+ # - this Is only shown, when the 'Search & Replace'(CTRL + H) is shown
+ win.replaceAllBtn = buttonNew("Replace All")
+ win.findBar.packStart(win.replaceAllBtn, false, false, 0)
+ discard win.replaceAllBtn.signalConnect("clicked",
+ SIGNAL_FUNC(aporia.replaceAllBtn_Clicked), nil)
+ #replaceAllBtn.show()
+
+ # Right side ...
+
+ # Close button - With a close stock image
+ var closeBtn = buttonNew()
+ var closeImage = imageNewFromStock(STOCK_CLOSE, ICON_SIZE_SMALL_TOOLBAR)
+ var closeBox = hboxNew(False, 0)
+ closeBtn.add(closeBox)
+ closeBox.show()
+ closeBox.add(closeImage)
+ closeImage.show()
+ discard closeBtn.signalConnect("clicked",
+ SIGNAL_FUNC(aporia.closeBtn_Clicked), nil)
+ win.findBar.packEnd(closeBtn, False, False, 2)
+ closeBtn.show()
+
+ # Extra button - When clicked shows a menu with options like 'Use regex'
+ var extraBtn = buttonNew()
+ var extraImage = imageNewFromStock(STOCK_PROPERTIES, ICON_SIZE_SMALL_TOOLBAR)
+
+ var extraBox = hboxNew(False, 0)
+ extraBtn.add(extraBox)
+ extraBox.show()
+ extraBox.add(extraImage)
+ extraImage.show()
+ discard extraBtn.signalConnect("clicked",
+ SIGNAL_FUNC(aporia.extraBtn_Clicked), nil)
+ win.findBar.packEnd(extraBtn, False, False, 0)
+ extraBtn.show()
+
+ MainBox.packStart(win.findBar, False, False, 0)
+ win.findBar.show()
+
+proc initStatusBar(MainBox: PBox) =
+ win.bottomBar = statusbarNew()
+ MainBox.packStart(win.bottomBar, False, False, 0)
+ win.bottomBar.show()
+
+ discard win.bottomBar.push(0, "Line: 0 Column: 0")
+
+proc initControls() =
+ # Load up the language style
+ win.langMan = languageManagerGetDefault()
+ var langpaths: array[0..1, cstring] =
+ [cstring(os.getApplicationDir() / langSpecs), nil]
+ win.langMan.setSearchPath(addr(langpaths))
+ var nimLang = win.langMan.getLanguage("nimrod")
+ win.nimLang = nimLang
+
+ # Load the scheme
+ var schemeMan = schemeManagerGetDefault()
+ var schemepaths: array[0..1, cstring] =
+ [cstring(os.getApplicationDir() / styles), nil]
+ schemeMan.setSearchPath(addr(schemepaths))
+ win.scheme = schemeMan.getScheme(win.settings.colorSchemeID)
+
+ # Window
+ win.w = windowNew(gtk2.WINDOW_TOPLEVEL)
+ win.w.setDefaultSize(win.settings.winWidth, win.settings.winHeight)
+ win.w.setTitle("Aporia IDE")
+ if win.settings.winMaximized: win.w.maximize()
+
+ win.w.show() # The window has to be shown before
+ # setting the position of the VPaned so that
+ # it gets set correctly, when the window is maximized.
+
+ discard win.w.signalConnect("destroy", SIGNAL_FUNC(aporia.destroy), nil)
+ discard win.w.signalConnect("delete_event",
+ SIGNAL_FUNC(aporia.delete_event), nil)
+ discard win.w.signalConnect("window-state-event",
+ SIGNAL_FUNC(aporia.windowState_Changed), nil)
+
+ # MainBox (vbox)
+ var MainBox = vboxNew(False, 0)
+ win.w.add(MainBox)
+
+ initTopMenu(MainBox)
+ initToolBar(MainBox)
+ initTAndBP(MainBox)
+ initFindBar(MainBox)
+ initStatusBar(MainBox)
+
+ MainBox.show()
+ if confParseFail:
+ dialogs.warning(win.w, "Error parsing config file, using default settings.")
+
+nimrod_init()
+initControls()
+main()
+
diff --git a/tests/examplefiles/nemerle_sample.n b/tests/examplefiles/nemerle_sample.n
new file mode 100644
index 00000000..2c05033a
--- /dev/null
+++ b/tests/examplefiles/nemerle_sample.n
@@ -0,0 +1,85 @@
+using System;
+
+namespace Demo.Ns
+{
+ /// sample class
+ public class ClassSample : Base
+ {
+ /* sample multiline comment */
+#region region sample
+ fieldSample : int;
+#endregion
+
+ public virtual someMethod(str : string) : list[double]
+ {
+ def x = "simple string";
+ def x = $"simple $splice string $(spliceMethod())";
+ def x = <#
+ recursive <# string #> sample
+ #>;
+ def x = $<#
+ recursive $splice <# string #> sample
+ #>;
+
+ def localFunc(arg)
+ {
+ arg + 1;
+ }
+
+ match (localFunc(2))
+ {
+ | 3 => "ok";
+ | _ => "fail";
+ }
+
+ using (x = SomeObject())
+ {
+ foreach (item in someCollection)
+ {
+ def i = try
+ {
+ int.Parse(item)
+ }
+ catch
+ {
+ | _ is FormatException => 0;
+ }
+ when (i > 0xff)
+ unless (i < 555L)
+ WriteLine(i);
+
+ }
+ }
+ protected override overrideSample() : void
+ {}
+
+ private privateSample() : void
+ {}
+
+ public abstract abstractSample() : void
+ {}
+ }
+
+ }
+
+ module ModuleSample
+ {
+ }
+
+ variant RgbColor {
+ | Red
+ | Yellow
+ | Green
+ | Different {
+ red : float;
+ green : float;
+ blue : float;
+ }
+ }
+
+ macro sampleMacro(expr)
+ syntax ("write", expr)
+ {
+ <[ WriteLine($expr) ]>
+ }
+}
diff --git a/tests/examplefiles/test.ec b/tests/examplefiles/test.ec
new file mode 100644
index 00000000..37868b52
--- /dev/null
+++ b/tests/examplefiles/test.ec
@@ -0,0 +1,605 @@
+namespace gui;
+
+import "Window"
+
+public struct AnchorValue
+{
+ AnchorValueType type;
+
+ union
+ {
+ int distance;
+ float percent;
+ };
+ property int
+ {
+ set { distance = value; type = offset; }
+ get { return distance; }
+ }
+ property double
+ {
+ set { percent = (float) value; type = relative; }
+ get { return (double) percent; }
+ }
+
+ char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
+ {
+ if(type == offset)
+ {
+ sprintf(stringOutput, "%d", distance);
+ }
+ else if(type == relative)
+ {
+ int c;
+ int last = 0;
+ sprintf(stringOutput, "%f", percent);
+ c = strlen(stringOutput)-1;
+ for( ; c >= 0; c--)
+ {
+ if(stringOutput[c] != '0')
+ last = Max(last, c);
+ if(stringOutput[c] == '.')
+ {
+ if(last == c)
+ {
+ stringOutput[c+1] = '0';
+ stringOutput[c+2] = 0;
+ }
+ else
+ stringOutput[last+1] = 0;
+ break;
+ }
+ }
+ }
+ if(needClass) *needClass = false;
+ return stringOutput;
+ }
+
+ bool OnGetDataFromString(char * stringOutput)
+ {
+ char * end;
+ if(strchr(stringOutput, '.'))
+ {
+ float percent = (float)strtod(stringOutput, &end);
+
+ if(end != stringOutput)
+ {
+ this.percent = percent;
+ type = relative;
+ return true;
+ }
+ }
+ else if(stringOutput[0])
+ {
+ int distance = strtol(stringOutput, &end, 0);
+ if(end != stringOutput)
+ {
+ this.distance = distance;
+ type = offset;
+ return true;
+ }
+ }
+ else
+ {
+ distance = 0;
+ type = 0;
+ }
+ return false;
+ }
+};
+
+public struct MiddleAnchorValue
+{
+ AnchorValueType type;
+
+ union
+ {
+ int distance;
+ float percent;
+ };
+ property int
+ {
+ set { distance = value; type = none; }
+ get { return distance; }
+ }
+ property double
+ {
+ set { percent = (float) value; type = middleRelative; }
+ get { return (double) percent; }
+ }
+
+ char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
+ {
+ if(type == middleRelative)
+ {
+ int c;
+ int last = 0;
+ sprintf(stringOutput, "%f", percent);
+ c = strlen(stringOutput)-1;
+ for( ; c >= 0; c--)
+ {
+ if(stringOutput[c] != '0')
+ last = Max(last, c);
+ if(stringOutput[c] == '.')
+ {
+ if(last == c)
+ {
+ stringOutput[c+1] = '0';
+ stringOutput[c+2] = 0;
+ }
+ else
+ stringOutput[last+1] = 0;
+ break;
+ }
+ }
+ }
+ else if(type == none && distance)
+ {
+ sprintf(stringOutput, "%d", distance);
+ }
+ if(needClass) *needClass = false;
+ return stringOutput;
+ }
+
+ bool OnGetDataFromString(char * stringOutput)
+ {
+ if(strchr(stringOutput, '.'))
+ {
+ percent = (float)strtod(stringOutput, null);
+ type = middleRelative;
+ }
+ else
+ {
+ distance = strtol(stringOutput, null, 0);
+ type = none;
+ }
+ return true;
+ }
+};
+
+public enum AnchorValueType { none, offset, relative, middleRelative, cascade, vTiled, hTiled };
+
+public struct Anchor
+{
+ union { AnchorValue left; MiddleAnchorValue horz; };
+ union { AnchorValue top; MiddleAnchorValue vert; };
+ AnchorValue right, bottom;
+
+ char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
+ {
+ char tempString[256];
+ char * anchorValue;
+ bool subNeedClass;
+
+ tempString[0] = '\0';
+ anchorValue = left.OnGetString(tempString, null, &subNeedClass);
+ if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "left = "); strcat(stringOutput, anchorValue); }
+
+ //if(((!left.type && !right.type) && horz.distance) || horz.type == middleRelative)
+ if(!right.type && ((!left.type && horz.distance) || horz.type == middleRelative))
+ {
+ tempString[0] = '\0';
+ anchorValue = horz.OnGetString(tempString, null, &subNeedClass);
+ if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "horz = "); strcat(stringOutput, anchorValue); }
+ }
+
+ tempString[0] = '\0';
+ anchorValue = top.OnGetString(tempString, null, &subNeedClass);
+ if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "top = "); strcat(stringOutput, anchorValue); }
+
+ tempString[0] = '\0';
+ anchorValue = right.OnGetString(tempString, null, &subNeedClass);
+ if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "right = "); strcat(stringOutput, anchorValue); }
+
+ // if(((!top.type && !bottom.type) && vert.distance) || vert.type == middleRelative)
+ if(!bottom.type && ((!top.type && vert.distance) || vert.type == middleRelative))
+ {
+ tempString[0] = '\0';
+ anchorValue = vert.OnGetString(tempString, null, &subNeedClass);
+ if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "vert = "); strcat(stringOutput, anchorValue); }
+ }
+
+ tempString[0] = '\0';
+ anchorValue = bottom.OnGetString(tempString, null, &subNeedClass);
+ if(anchorValue[0]) { if(stringOutput[0]) strcat(stringOutput, ", "); strcat(stringOutput, "bottom = "); strcat(stringOutput, anchorValue); }
+
+ return stringOutput;
+ }
+
+ bool OnGetDataFromString(char * string)
+ {
+ this = Anchor {};
+ return class::OnGetDataFromString(string);
+ }
+
+ bool OnSaveEdit(DropBox dropBox, void * object)
+ {
+ return dropBox.Save();
+ }
+
+ Window OnEdit(Window listBox, Window master, int x, int y, int w, int h, Window control)
+ {
+ char * string = "";
+ AnchorDropBox comboBox
+ {
+ editText = true;
+ parent = listBox;
+ master = master;
+ position = Point { x, y };
+ //clientSize = Size { h = h };
+ //size.w = w;
+ size = { w, h };
+ anchorValue = this;
+ control = control;
+ borderStyle = 0;
+ };
+
+ comboBox.Create();
+
+ {
+ char tempString[MAX_F_STRING] = "";
+ bool needClass = false;
+ char * result = OnGetString(tempString, null, &needClass);
+ if(result) string = result;
+ }
+ comboBox.contents = string;
+ return comboBox;
+ }
+};
+
+private class AnchorButton : Button
+{
+ toggle = true, bevel = false;
+
+ void OnRedraw(Surface surface)
+ {
+ int cw = clientSize.w;
+ int ch = clientSize.h;
+
+ surface.SetForeground(black);
+ if(checked)
+ {
+ surface.SetBackground(Color { 85,85,85 });
+ surface.Area(0,0, cw-1, ch-1);
+ }
+ else
+ surface.LineStipple(0xAAAA);
+
+ surface.Rectangle(0,0,cw-1,ch-1);
+
+ if(active)
+ {
+ surface.LineStipple(0xAAAA);
+ surface.Rectangle(2,2,cw-3,ch-3);
+ }
+ }
+
+ bool AnchorEditor::NotifyClicked(Button button, int x, int y, Modifiers mods)
+ {
+ AnchorDropBox anchorDropBox = (AnchorDropBox)master;
+ Anchor anchor = anchorDropBox.anchorValue;
+ Window control = anchorDropBox.control;
+ DataBox dropMaster = (DataBox)anchorDropBox.master;
+ int id = button.id;
+
+ switch(id)
+ {
+ case 0: anchor.left.type = button.checked ? offset : none; break;
+ case 1: anchor.top.type = button.checked ? offset : none; break;
+ case 2: anchor.right.type = button.checked ? offset : none; break;
+ case 3: anchor.bottom.type = button.checked ? offset : none; break;
+ }
+
+ if(anchor.horz.type == middleRelative && (id == 0 || id == 2))
+ {
+ anchorDropBox.relButtons[0].checked = false;
+ anchorDropBox.relButtons[2].checked = false;
+ }
+ if(anchor.vert.type == middleRelative && (id == 1 || id == 3))
+ {
+ anchorDropBox.relButtons[1].checked = false;
+ anchorDropBox.relButtons[3].checked = false;
+ }
+ anchorDropBox.relButtons[id].checked = false;
+
+ //anchor.horz.type = none;
+ //anchor.vert.type = none;
+
+ {
+ int vpw, vph;
+ int x,y,w,h;
+ Window parent = control.parent;
+
+ // Fix Anchor
+ x = control.position.x;
+ y = control.position.y;
+ w = control.size.w;
+ h = control.size.h;
+
+ vpw = parent.clientSize.w;
+ vph = parent.clientSize.h;
+ if(control.nonClient)
+ {
+ vpw = parent.size.w;
+ vph = parent.size.h;
+ }
+ else if(((BorderBits)control.borderStyle).fixed)
+ {
+ if(!control.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
+ if(!control.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
+ }
+
+ if(anchor.left.type == offset) anchor.left.distance = x;
+ else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
+ if(anchor.top.type == offset) anchor.top.distance = y;
+ else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
+ if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
+ //else if(anchor.right.type == relative) anchor.right.percent = (float) (x + w) / vpw;
+ else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
+ if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
+ //else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (y + h) / vph;
+ else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
+
+ if(!anchor.left.type && !anchor.right.type)
+ {
+ anchor.horz.distance = (x + w / 2) - (vpw / 2);
+ //anchor.horz.type = anchor.horz.distance ? offset : 0;
+ }
+ else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
+ if(!anchor.top.type && !anchor.bottom.type)
+ {
+ anchor.vert.distance = (y + h / 2) - (vph / 2);
+ //anchor.vert.type = anchor.vert.distance ? offset : 0;
+ }
+ else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
+ }
+
+ {
+ char tempString[1024] = "";
+ bool needClass = false;
+ char * string = anchor.OnGetString(tempString, null, &needClass);
+ anchorDropBox.contents = string;
+ }
+
+ dropMaster.SetData(&anchor, false);
+ anchorDropBox.anchorValue = anchor;
+ return true;
+ }
+}
+
+private class AnchorRelButton : Button
+{
+ toggle = true;
+ bevel = false;
+ text = "%";
+ //bevelOver = true;
+
+ void OnRedraw(Surface surface)
+ {
+ int cw = clientSize.w;
+ int ch = clientSize.h;
+
+ if(checked)
+ {
+ surface.SetForeground(black);
+ }
+ else
+ {
+ surface.SetForeground(Color{170,170,170});
+ }
+ surface.WriteText(5,2, "%", 1);
+
+ if(active)
+ {
+ surface.LineStipple(0xAAAA);
+ surface.Rectangle(3,3,cw-4,ch-4);
+ }
+ }
+
+ bool AnchorEditor::NotifyClicked(Button button, int x, int y, Modifiers mods)
+ {
+ AnchorDropBox anchorDropBox = (AnchorDropBox)master;
+ Anchor anchor = anchorDropBox.anchorValue;
+ Window control = anchorDropBox.control;
+ DataBox dropMaster = (DataBox)anchorDropBox.master;
+ int id = button.id;
+
+ if((id == 0 || id == 2) && ((!anchor.left.type && !anchor.right.type) || anchor.left.type == middleRelative))
+ {
+ if(button.checked) anchor.horz.type = middleRelative; else anchor.horz.type = none;
+ anchorDropBox.relButtons[(id + 2)%4].checked = button.checked;
+ }
+ else if((id == 1 || id == 3) && ((!anchor.top.type && !anchor.bottom.type) || anchor.top.type == middleRelative))
+ {
+ if(button.checked) anchor.vert.type = middleRelative; else anchor.vert.type = none;
+ anchorDropBox.relButtons[(id + 2)%4].checked = button.checked;
+ }
+ else
+ {
+ switch(id)
+ {
+ case 0: anchor.left.type = button.checked ? relative : (anchor.left.type ? offset : none); break;
+ case 1: anchor.top.type = button.checked ? relative : (anchor.top.type ? offset : none); break;
+ case 2: anchor.right.type = button.checked ? relative : (anchor.right.type ? offset : none); break;
+ case 3: anchor.bottom.type = button.checked ? relative : (anchor.bottom.type ? offset : none); break;
+ }
+ anchorDropBox.buttons[id].checked = true;
+ if(anchor.horz.type == middleRelative) anchor.horz.type = none;
+ if(anchor.vert.type == middleRelative) anchor.vert.type = none;
+ }
+
+ {
+ int vpw, vph;
+ int x,y,w,h;
+ Window parent = control.parent;
+
+ // Fix Anchor
+ x = control.position.x;
+ y = control.position.y;
+ w = control.size.w;
+ h = control.size.h;
+
+ vpw = parent.clientSize.w;
+ vph = parent.clientSize.h;
+ if(control.nonClient)
+ {
+ vpw = parent.size.w;
+ vph = parent.size.h;
+ }
+ else if(((BorderBits)control.borderStyle).fixed)
+ {
+ if(!control.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
+ if(!control.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
+ }
+
+ if(anchor.left.type == offset) anchor.left.distance = x;
+ else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
+ if(anchor.top.type == offset) anchor.top.distance = y;
+ else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
+ if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
+ //else if(anchor.right.type == relative) anchor.right.percent = (float) (x + w) / vpw;
+ else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
+ if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
+ //else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (y + h) / vph;
+ else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
+
+ if(!anchor.left.type && !anchor.right.type)
+ {
+ anchor.horz.distance = (x + w / 2) - (vpw / 2);
+ //anchor.horz.type = anchor.horz.distance ? offset : none;
+ }
+ else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
+ if(!anchor.top.type && !anchor.bottom.type)
+ {
+ anchor.vert.distance = (y + h / 2) - (vph / 2);
+ //anchor.vert.type = anchor.vert.distance ? offset : none;
+ }
+ else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
+ }
+
+ {
+ char tempString[1024] = "";
+ bool needClass = false;
+ char * string = anchor.OnGetString(tempString, null, &needClass);
+ anchorDropBox.contents = string;
+ }
+
+ dropMaster.SetData(&anchor, false);
+ anchorDropBox.anchorValue = anchor;
+ return true;
+ }
+}
+
+private class AnchorEditor : Window
+{
+ interim = true;
+ borderStyle = deepContour;
+ size.h = 92;
+
+ bool OnKeyDown(Key key, unichar ch)
+ {
+ if(key == escape)
+ return master.OnKeyDown(key, ch);
+ return true;
+ }
+}
+
+private class AnchorDropBox : DropBox
+{
+ Anchor anchorValue;
+ Window control;
+ Button relButtons[4], buttons[4];
+
+ AnchorEditor anchorEditor
+ {
+ master = this;
+ autoCreate = false;
+ };
+
+ Window OnDropDown()
+ {
+ int c;
+ Button
+ {
+ anchorEditor,
+ anchor = Anchor { left = 28, top = 28, right = 28, bottom = 28 },
+ inactive = true, disabled = true
+ };
+ for(c = 0; c<4; c++)
+ {
+ Button button = buttons[c] = AnchorButton
+ {
+ anchorEditor, id = c,
+ size = Size { (c%2)?10:28, (c%2)?28:10 }
+ };
+ Button relButton = relButtons[c] = AnchorRelButton
+ {
+ anchorEditor, id = c;
+ };
+
+ switch(c)
+ {
+ case 0:
+ if(anchorValue.left.type && anchorValue.left.type != middleRelative) button.checked = true;
+ if(anchorValue.left.type == relative || anchorValue.horz.type == middleRelative) relButton.checked = true;
+
+ button.anchor = Anchor { left = 0 };
+ relButton.anchor = Anchor { left = 5, vert = 16 };
+ break;
+ case 1:
+ if(anchorValue.top.type && anchorValue.top.type != middleRelative) button.checked = true;
+ if(anchorValue.top.type == relative || anchorValue.vert.type == middleRelative) relButton.checked = true;
+
+ button.anchor = Anchor { top = 0 };
+ relButton.anchor = Anchor { top = 5, horz = 16 };
+ break;
+ case 2:
+ if(anchorValue.right.type && anchorValue.right.type != middleRelative) button.checked = true;
+ if(anchorValue.right.type == relative || anchorValue.horz.type == middleRelative) relButton.checked = true;
+
+ button.anchor = Anchor { right = 0 };
+ relButton.anchor = Anchor { right = 5, vert = 16 };
+ break;
+ case 3:
+ if(anchorValue.bottom.type && anchorValue.bottom.type != middleRelative) button.checked = true;
+ if(anchorValue.bottom.type == relative || anchorValue.vert.type == middleRelative) relButton.checked = true;
+
+ button.anchor = Anchor { bottom = 0 };
+ relButton.anchor = Anchor { bottom = 5, horz = 16 };
+ break;
+ }
+ }
+ anchorEditor.Create();
+ return anchorEditor;
+ }
+
+ void OnCloseDropDown(Window anchorEditor)
+ {
+ // TOFIX: Patch for update bug
+ master.Update(null);
+ anchorEditor.Destroy(0);
+ }
+
+ bool DataBox::NotifyTextEntry(AnchorDropBox dropBox, char * string, bool save)
+ {
+ Anchor anchor = dropBox.anchorValue;
+ Window control = dropBox.control;
+
+ if(save)
+ {
+ if(anchor.OnGetDataFromString(string))
+ {
+ SetData(&anchor, false);
+ dropBox.anchorValue = anchor;
+ }
+ }
+ else
+ {
+ char tempString[1024] = "";
+ bool needClass = false;
+ char * string = anchor.OnGetString(tempString, null, &needClass);
+ dropBox.contents = string;
+ }
+ return true;
+ }
+}
diff --git a/tests/examplefiles/test.eh b/tests/examplefiles/test.eh
new file mode 100644
index 00000000..1ed173fb
--- /dev/null
+++ b/tests/examplefiles/test.eh
@@ -0,0 +1,315 @@
+/* A Bison parser, made by GNU Bison 2.0. */
+
+/* Skeleton parser for Yacc-like parsing with Bison,
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ IDENTIFIER = 258,
+ CONSTANT = 259,
+ STRING_LITERAL = 260,
+ SIZEOF = 261,
+ PTR_OP = 262,
+ INC_OP = 263,
+ DEC_OP = 264,
+ LEFT_OP = 265,
+ RIGHT_OP = 266,
+ LE_OP = 267,
+ GE_OP = 268,
+ EQ_OP = 269,
+ NE_OP = 270,
+ AND_OP = 271,
+ OR_OP = 272,
+ MUL_ASSIGN = 273,
+ DIV_ASSIGN = 274,
+ MOD_ASSIGN = 275,
+ ADD_ASSIGN = 276,
+ SUB_ASSIGN = 277,
+ LEFT_ASSIGN = 278,
+ RIGHT_ASSIGN = 279,
+ AND_ASSIGN = 280,
+ XOR_ASSIGN = 281,
+ OR_ASSIGN = 282,
+ TYPE_NAME = 283,
+ TYPEDEF = 284,
+ EXTERN = 285,
+ STATIC = 286,
+ AUTO = 287,
+ REGISTER = 288,
+ CHAR = 289,
+ SHORT = 290,
+ INT = 291,
+ UINT = 292,
+ INT64 = 293,
+ LONG = 294,
+ SIGNED = 295,
+ UNSIGNED = 296,
+ FLOAT = 297,
+ DOUBLE = 298,
+ CONST = 299,
+ VOLATILE = 300,
+ VOID = 301,
+ VALIST = 302,
+ STRUCT = 303,
+ UNION = 304,
+ ENUM = 305,
+ ELLIPSIS = 306,
+ CASE = 307,
+ DEFAULT = 308,
+ IF = 309,
+ SWITCH = 310,
+ WHILE = 311,
+ DO = 312,
+ FOR = 313,
+ GOTO = 314,
+ CONTINUE = 315,
+ BREAK = 316,
+ RETURN = 317,
+ IFX = 318,
+ ELSE = 319,
+ CLASS = 320,
+ THISCLASS = 321,
+ CLASS_NAME = 322,
+ PROPERTY = 323,
+ SETPROP = 324,
+ GETPROP = 325,
+ NEWOP = 326,
+ RENEW = 327,
+ DELETE = 328,
+ EXT_DECL = 329,
+ EXT_STORAGE = 330,
+ IMPORT = 331,
+ DEFINE = 332,
+ VIRTUAL = 333,
+ EXT_ATTRIB = 334,
+ PUBLIC = 335,
+ PRIVATE = 336,
+ TYPED_OBJECT = 337,
+ ANY_OBJECT = 338,
+ _INCREF = 339,
+ EXTENSION = 340,
+ ASM = 341,
+ TYPEOF = 342,
+ WATCH = 343,
+ STOPWATCHING = 344,
+ FIREWATCHERS = 345,
+ WATCHABLE = 346,
+ CLASS_DESIGNER = 347,
+ CLASS_NO_EXPANSION = 348,
+ CLASS_FIXED = 349,
+ ISPROPSET = 350,
+ CLASS_DEFAULT_PROPERTY = 351,
+ PROPERTY_CATEGORY = 352,
+ CLASS_DATA = 353,
+ CLASS_PROPERTY = 354,
+ SUBCLASS = 355,
+ NAMESPACE = 356,
+ NEW0OP = 357,
+ RENEW0 = 358,
+ VAARG = 359,
+ DBTABLE = 360,
+ DBFIELD = 361,
+ DBINDEX = 362,
+ DATABASE_OPEN = 363
+ };
+#endif
+#define IDENTIFIER 258
+#define CONSTANT 259
+#define STRING_LITERAL 260
+#define SIZEOF 261
+#define PTR_OP 262
+#define INC_OP 263
+#define DEC_OP 264
+#define LEFT_OP 265
+#define RIGHT_OP 266
+#define LE_OP 267
+#define GE_OP 268
+#define EQ_OP 269
+#define NE_OP 270
+#define AND_OP 271
+#define OR_OP 272
+#define MUL_ASSIGN 273
+#define DIV_ASSIGN 274
+#define MOD_ASSIGN 275
+#define ADD_ASSIGN 276
+#define SUB_ASSIGN 277
+#define LEFT_ASSIGN 278
+#define RIGHT_ASSIGN 279
+#define AND_ASSIGN 280
+#define XOR_ASSIGN 281
+#define OR_ASSIGN 282
+#define TYPE_NAME 283
+#define TYPEDEF 284
+#define EXTERN 285
+#define STATIC 286
+#define AUTO 287
+#define REGISTER 288
+#define CHAR 289
+#define SHORT 290
+#define INT 291
+#define UINT 292
+#define INT64 293
+#define LONG 294
+#define SIGNED 295
+#define UNSIGNED 296
+#define FLOAT 297
+#define DOUBLE 298
+#define CONST 299
+#define VOLATILE 300
+#define VOID 301
+#define VALIST 302
+#define STRUCT 303
+#define UNION 304
+#define ENUM 305
+#define ELLIPSIS 306
+#define CASE 307
+#define DEFAULT 308
+#define IF 309
+#define SWITCH 310
+#define WHILE 311
+#define DO 312
+#define FOR 313
+#define GOTO 314
+#define CONTINUE 315
+#define BREAK 316
+#define RETURN 317
+#define IFX 318
+#define ELSE 319
+#define CLASS 320
+#define THISCLASS 321
+#define CLASS_NAME 322
+#define PROPERTY 323
+#define SETPROP 324
+#define GETPROP 325
+#define NEWOP 326
+#define RENEW 327
+#define DELETE 328
+#define EXT_DECL 329
+#define EXT_STORAGE 330
+#define IMPORT 331
+#define DEFINE 332
+#define VIRTUAL 333
+#define EXT_ATTRIB 334
+#define PUBLIC 335
+#define PRIVATE 336
+#define TYPED_OBJECT 337
+#define ANY_OBJECT 338
+#define _INCREF 339
+#define EXTENSION 340
+#define ASM 341
+#define TYPEOF 342
+#define WATCH 343
+#define STOPWATCHING 344
+#define FIREWATCHERS 345
+#define WATCHABLE 346
+#define CLASS_DESIGNER 347
+#define CLASS_NO_EXPANSION 348
+#define CLASS_FIXED 349
+#define ISPROPSET 350
+#define CLASS_DEFAULT_PROPERTY 351
+#define PROPERTY_CATEGORY 352
+#define CLASS_DATA 353
+#define CLASS_PROPERTY 354
+#define SUBCLASS 355
+#define NAMESPACE 356
+#define NEW0OP 357
+#define RENEW0 358
+#define VAARG 359
+#define DBTABLE 360
+#define DBFIELD 361
+#define DBINDEX 362
+#define DATABASE_OPEN 363
+
+
+
+
+#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#line 42 "grammar.y"
+typedef union YYSTYPE {
+ SpecifierType specifierType;
+ int i;
+ AccessMode declMode;
+ Identifier id;
+ Expression exp;
+ Specifier specifier;
+ OldList * list;
+ Enumerator enumerator;
+ Declarator declarator;
+ Pointer pointer;
+ Initializer initializer;
+ InitDeclarator initDeclarator;
+ TypeName typeName;
+ Declaration declaration;
+ Statement stmt;
+ FunctionDefinition function;
+ External external;
+ Context context;
+ AsmField asmField;
+
+ Instantiation instance;
+ MembersInit membersInit;
+ MemberInit memberInit;
+ ClassFunction classFunction;
+ ClassDefinition _class;
+ ClassDef classDef;
+ PropertyDef prop;
+ char * string;
+ Symbol symbol;
+ PropertyWatch propertyWatch;
+ TemplateParameter templateParameter;
+ TemplateArgument templateArgument;
+ TemplateDatatype templateDatatype;
+
+ DBTableEntry dbtableEntry;
+ DBIndexItem dbindexItem;
+ DBTableDef dbtableDef;
+} YYSTYPE;
+/* Line 1318 of yacc.c. */
+#line 293 "grammar.eh"
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+extern YYSTYPE yylval;
+
+#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
+typedef struct YYLTYPE
+{
+ int first_line;
+ int first_column;
+ int last_line;
+ int last_column;
+} YYLTYPE;
+# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+#endif
+
+extern YYLTYPE yylloc;
+
+