Commit 2d2dac61 authored by Alexander Shiryaev's avatar Alexander Shiryaev
Browse files

fpc/Borland Pascal 7 profile added

parent 514c9a84
......@@ -10,4 +10,4 @@ with syntax checking
ROPS is transliterated abbreviation
Alexander Shiryaev, 2010-2012
Alexander Shiryaev, 2010-2013
......@@ -8,4 +8,4 @@ with syntax checking
ROPS is transliterated abbreviation
Alexander Shiryaev, 2010-2012
Alexander Shiryaev, 2010-2013
# -*- coding: koi8-r -*-
# Alexander Shiryaev, 2010-2012
# Alexander Shiryaev, 2010-2013
import compiler, re, subprocess, os, sys, locale, tempfile, time, errno
import util, winenc
......@@ -351,6 +351,77 @@ def dcc32Compile (text, encodedText, encoding, fileName):
msg = u"'program ident;' or 'unit ident;' or 'library ident;' expected"
return (msg, None, None)
_pfpcLine = re.compile('^([^\(]+)\(([0-9]+),([0-9]+)\) ([^\n]+)\n')
# fileName may be None
def fpcCompile (text, encodedText, encoding, fileName):
assert type(text) is unicode
assert type(encodedText) is str
assert encoding != None
r = _pPas.match(text)
if r != None:
modName = r.group(1).encode('ascii')
baseName = modName + '.$$$'
if fileName == None:
fName = baseName
# inCurDir = True
else:
d = os.path.dirname(fileName)
if (d == '') or sameFile(os.getcwd(), d):
fName = baseName
# inCurDir = True
else:
fName = os.path.join(d, baseName)
# inCurDir = False
if not os.path.exists(fName):
try:
try:
util.writeFile( fName, encodedText.replace('\t', ' '), sync=False )
except Exception, e:
msg = tr('#File write error') + ': ' + exMsg(e)
return (msg, None, None)
try:
e, o = cmd(["fpc", fName])
except Exception, e:
msg = 'fpc: ' + exMsg(e)
return (msg, None, None)
msg = e + o.decode( encoding )
eLines = e.count('\n')
errs = []
warns = []
i = eLines
for l in o.split('\n'):
r = _pfpcLine.match(l + '\n')
if r and (r.group(1) == baseName):
line = int(r.group(2)) - 1
col = int(r.group(3)) - 1
pos = (line, col)
link = (i, pos)
m = r.group(4)
if m.startswith('Error:') or m.startswith('Fatal:'):
errs.append(link)
else:
warns.append(link)
i = i + 1
return (msg, errs, warns)
finally:
try:
os.remove(fName)
except:
pass
else:
msg = "%s: %s %s %s!" % (tr('#Error'), tr('#file'), fName.decode(locale.getpreferredencoding()), tr('#already exists'))
return (msg, None, None)
else:
msg = u"'program ident;' or 'unit ident;' or 'library ident;' expected"
return (msg, None, None)
_pgpcpLine = re.compile("^ *([0-9]+) +")
# fileName may be None
......@@ -1046,11 +1117,11 @@ def modZnEmpty (name):
def delphiEmpty (name):
if name == None:
text = u'unit ;\n\n(*\n\t\n*)\n\n{$OVERFLOWCHECKS ON}\n{$RANGECHECKS ON}\n\ninterface\n\n\n\nimplementation\n\n\n\nend.'
text = u'unit ;\n\n(*\n\t\n*)\n\n(* {$OVERFLOWCHECKS ON} *)\n{$RANGECHECKS ON}\n\ninterface\n\n\n\nimplementation\n\n\n\nend.'
line = 0
col = 5
else:
text = u'unit %s;\n\n(*\n\t\n*)\n\n{$OVERFLOWCHECKS ON}\n{$RANGECHECKS ON}\n\ninterface\n\n\n\nimplementation\n\n\n\nend (* %s *).' % (name, name)
text = u'unit %s;\n\n(*\n\t\n*)\n\n(* {$OVERFLOWCHECKS ON} *)\n{$RANGECHECKS ON}\n\ninterface\n\n\n\nimplementation\n\n\n\nend (* %s *).' % (name, name)
line = 3
col = 1
return (text, line, col)
......@@ -1157,6 +1228,16 @@ dcc32 = {
'lineSep': '\r\n', #
}
fpc = {
'name': 'fpc/Borland Pascal 7',
'lang': 'pascal', # gtksourceview
'extensions': ('pas',),
'compile': fpcCompile,
# 'preferredFileEncoding': winEncoding(),
'empty': delphiEmpty,
# 'lineSep': '\r\n', #
}
astrobe = {
'name': 'Astrobe/Oberon-07',
'lang': 'oberon', # gtksourceview
......@@ -1267,7 +1348,7 @@ pyCoco = {
profiles = (
oo2c, obc, astrobe, gpcp, zc, xcO2, xmO2, xcM2, xmM2, mocka, mikroPascal,
dcc32,
dcc32, fpc,
python, lua,
ocaml,
c, cxx,
......
......@@ -3,7 +3,7 @@ from distutils.core import setup
setup(
name = "ROPS",
packages = ["rops",],
version = "0.4",
version = "0.5",
platforms = ['POSIX', 'Windows'],
description = "Simple text editor",
author = "Alexander Shiryaev",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment