Better error message, better highlighting

master
Yevgen Muntyan 2006-09-06 12:25:56 -05:00
parent 4ccd0dcd5f
commit d445431691
6 changed files with 119 additions and 80 deletions

View File

@ -53,7 +53,7 @@
/* Regex used to match "\%{...@start}". */
#define START_REF_REGEX "(?<!\\\\)(\\\\\\\\)*\\\\%\\{(.*?)@start\\}"
/* Priority of one-time idle that is installed after buffer is modified. */
/* Priority of one-time idle which is installed after buffer is modified. */
#define FIRST_UPDATE_PRIORITY G_PRIORITY_HIGH_IDLE
/* Maximal amount of time allowed to spent in this first idle. Should be
* small enough, since in worst case we block ui for this time after each keypress.

View File

@ -868,7 +868,7 @@ replace_by_id (const EggRegex *egg_regex,
if (subst == NULL)
g_set_error (&tmp_error,
PARSER_ERROR, PARSER_ERROR_WRONG_ID,
_("wrong id '%s' in regex '%s'"), id, regex);
_("Unknown id '%s' in regex '%s'"), id, regex);
if (tmp_error == NULL)
{
@ -1136,6 +1136,9 @@ expand_regex (ParserState *parser_state,
if (do_expand_vars)
{
tmp_regex = expand_regex_vars (parser_state, regex, len, error);
if (tmp_regex == NULL)
return NULL;
}
else
{

View File

@ -15,6 +15,10 @@
<style id="data-type" _name="Data Type" map-to="def:data-type"/>
<style id="printf" _name="printf conversion" map-to="def:character"/>
<style id="escaped-character" _name="Escaped Character" map-to="def:escape"/>
<style id="floating-point" _name="Float" map-to="def:floating-point"/>
<style id="decimal" _name="Decimal" map-to="def:decimal"/>
<style id="octal" _name="Octal" map-to="def:base-n-integer"/>
<style id="hexadecimal" _name="Hex" map-to="def:base-n-integer"/>
</styles>
<definitions>
@ -36,7 +40,7 @@
<define-regex id="escaped-character" extended="true">
\\( # leading backslash
[\\\"\'nrtfav\?e] | # escaped character
[0-7]{1,3} | # on, two, or three octal digits
[0-7]{1,3} | # one, two, or three octal digits
x[0-9A-Fa-f]{0,2} # 'x' followed by zero, one, or two hex digits
)
</define-regex>
@ -121,11 +125,40 @@
<match>'(\%{escaped-character}|.)'</match>
</context>
<!-- Numbers -->
<context ref="def:float"/>
<context ref="def:decimal"/>
<context ref="def:octal"/>
<context ref="def:hexadecimal"/>
<!-- http://www.lysator.liu.se/c/ANSI-C-grammar-l.html -->
<context id="float" style-ref="floating-point">
<match extended="true">
(?&lt;![\w\.])
((\.[0-9]+ | [0-9]+\.[0-9]*) ([Ee][+-]?[0-9]*)? |
([0-9]+[Ee][+-]?[0-9]*))
[fFlL]?
(?![\w\.])
</match>
</context>
<context id="hexadecimal" style-ref="hexadecimal">
<match extended="true">
(?&lt;![\w\.])
0[xX][a-fA-F0-9]+[uUlL]*
(?![\w\.])
</match>
</context>
<context id="octal" style-ref="octal">
<match extended="true">
(?&lt;![\w\.])
0[0-7]+[uUlL]*
(?![\w\.])
</match>
</context>
<context id="decimal" style-ref="decimal">
<match extended="true">
(?&lt;![\w\.])
[0-9]+[uUlL]*
(?![\w\.])
</match>
</context>
<!-- Keywords -->
<context id="keywords" style-ref="keyword">

View File

@ -26,25 +26,16 @@
<!-- $^ never matches. -->
<define-regex id="never-match">$^</define-regex>
<!-- FIXME: these four are broken (and should be removed, I think) -->
<define-regex id="decimal" extended="true" case-insensitive="true">
\b
<define-regex id="decimal" extended="true">
([1-9][0-9]* | 0)
(u (ll?)? | ll? u?)?
\b
</define-regex>
<define-regex id="octal" extended="true" case-insensitive="true">
\b
<define-regex id="octal" extended="true">
0 [0-7]+
(u (ll?)? | ll? u?)?
\b
</define-regex>
<define-regex id="hexadecimal" extended="true" case-insensitive="true">
\b
0x [0-9a-f]+
(u (ll?)? | ll? u?)?
\b
<define-regex id="hexadecimal" extended="true">
0 [xX] [0-9a-fA-F]+
</define-regex>
<!-- FIXME: these one is broke, and is it useful at all? -->
<define-regex id="float" extended="true" case-insensitive="true">
\b
([0-9]+ e [-+]? [0-9]+ |

View File

@ -6,69 +6,11 @@
<style id="math" _name="Math Mode"/>
<style id="include" _name="Include" map-to="def:keyword"/>
<style id="most-used-commands" _name="Command" map-to="def:keyword"/>
<style id="command" _name="Keyword" map-to="def:keyword"/>
<style id="command" _name="Command" map-to="def:keyword"/>
<style id="verbatim" _name="Verbatim" map-to="def:comment"/>
</styles>
<definitions>
<context id="latex">
<include>
<context id="comment" style-ref="comment">
<start>%</start>
<end>$</end>
<include>
<context ref="def:comment:*"/>
</include>
</context>
<context id="verbatim-comment" style-ref="comment">
<start>\\begin\{comment\}</start>
<end>\\end\{comment\}</end>
<include>
<context ref="def:comment:*"/>
</include>
</context>
<context id="math" style-ref="math">
<start>\$\$</start>
<end>\$\$</end>
</context>
<context id="inline-math" style-ref="inline-math">
<start>\$</start>
<end>\$</end>
</context>
<context id="verbatim-env" style-ref="verbatim">
<start extended="true">
/
\\begin\{
(
verbatim\*?|
lstlisting|
alltt
)
\}
/x
</start>
<end>\\end\{\%{1@start}\}</end>
</context>
<context id="verbatim-inline" style-ref="verbatim">
<start>\\(verb\*?|lstinline)(\S)</start>
<end>\%{2@start}</end>
</context>
<context id="include" style-ref="include">
<prefix>\\</prefix>
<keyword>input</keyword>
<keyword>include</keyword>
<keyword>includeonly</keyword>
<keyword>usepackage</keyword>
</context>
<context id="most-used-commands" style-ref="most-used-commands">
<prefix>\\</prefix>
@ -125,6 +67,77 @@
<match>\\[a-zA-Z]+</match>
</context>
<context id="latex">
<include>
<context id="comment" style-ref="comment">
<start>%</start>
<end>$</end>
<include>
<context ref="def:comment:*"/>
</include>
</context>
<context id="verbatim-comment" style-ref="comment">
<start>\\begin\{comment\}</start>
<end>\\end\{comment\}</end>
<include>
<context ref="def:comment:*"/>
</include>
</context>
<context id="math" style-ref="math">
<start>\$\$</start>
<end>\$\$</end>
<include>
<context ref="most-used-commands"/>
<context ref="specials-symbol"/>
<context ref="command"/>
</include>
</context>
<context id="inline-math" style-ref="inline-math">
<start>\$</start>
<end>\$</end>
<include>
<context ref="most-used-commands"/>
<context ref="specials-symbol"/>
<context ref="command"/>
</include>
</context>
<context id="verbatim-env" style-ref="verbatim">
<start extended="true">
/
\\begin\{
(
verbatim\*?|
lstlisting|
alltt
)
\}
/x
</start>
<end>\\end\{\%{1@start}\}</end>
</context>
<context id="verbatim-inline" style-ref="verbatim">
<start>\\(verb\*?|lstinline)(\S)</start>
<end>\%{2@start}</end>
</context>
<context id="include" style-ref="include">
<prefix>\\</prefix>
<keyword>input</keyword>
<keyword>include</keyword>
<keyword>includeonly</keyword>
<keyword>usepackage</keyword>
</context>
<context ref="most-used-commands"/>
<context ref="specials-symbol"/>
<context ref="command"/>
</include>
</context>
</definitions>

View File

@ -140,6 +140,5 @@
</context>
</definitions>
<brackets>&lt;&gt;</brackets>
<block-comment start="&lt;!--" end="-->"/>
</language>