Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mwe2] Use IAppender for creating external style files.
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Apr 4, 2017
1 parent 799f5cc commit 27fc811
Show file tree
Hide file tree
Showing 19 changed files with 1,418 additions and 745 deletions.
404 changes: 207 additions & 197 deletions formatting-styles/gtk/sarl.lang

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion formatting-styles/latex/sarl-beamer-listing.sty
Expand Up @@ -22,7 +22,7 @@
% limitations under the License.
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sarl-beamer-listing}[2017/04/02]
\ProvidesPackage{sarl-beamer-listing}[2017/04/04]
\RequirePackage{algpseudocode}
\RequirePackage{listings}
\RequirePackage{xspace}
Expand Down
2 changes: 1 addition & 1 deletion formatting-styles/latex/sarl-colorized-listing.sty
Expand Up @@ -22,7 +22,7 @@
% limitations under the License.
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sarl-colorized-listing}[2017/04/02]
\ProvidesPackage{sarl-colorized-listing}[2017/04/04]
\RequirePackage{algpseudocode}
\RequirePackage{listings}
\RequirePackage{xspace}
Expand Down
2 changes: 1 addition & 1 deletion formatting-styles/latex/sarl-listing.sty
Expand Up @@ -22,7 +22,7 @@
% limitations under the License.
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sarl-listing}[2017/04/02]
\ProvidesPackage{sarl-listing}[2017/04/04]
\RequirePackage{algpseudocode}
\RequirePackage{listings}
\RequirePackage{xspace}
Expand Down
49 changes: 26 additions & 23 deletions formatting-styles/prettify/lang-sarl.js
@@ -1,27 +1,30 @@
/*
* $Id$
*
* File is automatically generated by the Xtext language generator.
* Do not change it.
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2017 the original authors or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
*
* $Id$
*
* File is automatically generated by the Xtext language generator.
* Do not change it.
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2017 the original authors or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/* Style for SARL 0.6 */

PR['registerLangHandler'](
PR['createSimpleLexer'](
[
Expand Down
2 changes: 1 addition & 1 deletion formatting-styles/source-highlight/sarl.lang
Expand Up @@ -41,7 +41,7 @@ label = '@[$[:alnum:]_.:^]+'
normal = '\^[$[:alnum:]_]+'

# Highlight the type declarations
(keyword,normal,classname) = `(\<(?:agent|behavior|capacity|class|enum|event|interface|skill|space))([[:blank:]]+)([$[:alnum:]_]+)`
(keyword,normal,classname) = `(\<(?:agent|annotation|artifact|behavior|capacity|class|enum|event|interface|skill|space))([[:blank:]]+)([$[:alnum:]_]+)`

keyword = "abstract|agent|annotation|artifact|as|behavior|boolean|break|byte|capacity|case|catch|char|class|def|default|dispatch|do|double|else|enum|event|extends|extension|final|finally|fires|float|for|if|implements|import|instanceof|int|interface|long|native|new|on|override|package|private|protected|public|requires|return|short|skill|space|static|strictfp|super|switch|synchronized|throw|throws|transient|try|typeof|uses|val|var|void|volatile|while|with"

Expand Down
7 changes: 5 additions & 2 deletions main/coreplugins/io.sarl.lang.mwe2/GenerateSARL2.mwe2
Expand Up @@ -63,6 +63,7 @@ var srchighlightToolPath = "${externalToolPath}/source-highlight"
var webjsPath = "${overallRootPath}/main/externalmaven/io.sarl.maven.docs.generator/src/main/resources/org/jnario/doc/js"

var file.extensions = "sarl"
var languageWebsite = "http://www.sarl.io"
var fileEncoding = "UTF-8"
var lineDelimiter = "\n"
var fileHeader = "/*
Expand Down Expand Up @@ -228,10 +229,10 @@ Workflow {
addNativeTypes = true

inheritFromGrammarKeywordAccesss = true

specialKeyword = 'package'
specialKeyword = 'import'

typeDeclarationKeyword = 'agent'
typeDeclarationKeyword = 'behavior'
typeDeclarationKeyword = 'capacity'
Expand All @@ -241,6 +242,8 @@ Workflow {
typeDeclarationKeyword = 'class'
typeDeclarationKeyword = 'interface'
typeDeclarationKeyword = 'enum'
typeDeclarationKeyword = 'annotation'
typeDeclarationKeyword = 'artifact'

colors = auto-inject {
color = auto-inject {
Expand Down
@@ -0,0 +1,89 @@
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2017 the original authors or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.sarl.lang.mwe2.externalspec;

import org.eclipse.xtext.util.Strings;
import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment;
import org.eclipse.xtext.xtext.generator.CodeConfig;

/**
* A {@link AbstractXtextGeneratorFragment} that enables to create the highlighting in
* a C-syntax-based external tool.
*
* @author $Author: sgalland$
* @version $FullVersion$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
* @since 0.6
*/
public abstract class AbstractCsyntaxHighlightingFragment2 extends AbstractExternalHighlightingFragment2<IStyleAppendable> {

@Override
protected IStyleAppendable newStyleAppendable() {
return new CsyntaxAppendable(getCodeConfig(), getLanguageSimpleName(), getLanguageVersion());
}

/** Appendable for c-syntax-based styles.
*
* @author $Author: sgalland$
* @version $FullVersion$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
* @since 0.6
*/
protected static class CsyntaxAppendable extends AbstractAppendable {

/** Constructor.
*
* @param codeConfig the code configuration.
* @param languageName the language name.
* @param languageVersion the language version.
*/
protected CsyntaxAppendable(CodeConfig codeConfig, String languageName, String languageVersion) {
super(codeConfig, languageName, languageVersion);
}

@Override
public void appendComment(String text, Object... parameters) {
final String comment = applyFormat(text, parameters);
appendNl("/* "); //$NON-NLS-1$
for (final String line : comment.split("[\n\r]")) { //$NON-NLS-1$
appendNl(" * " + line.trim()); //$NON-NLS-1$
}
appendNl("*/"); //$NON-NLS-1$
}

@Override
public void appendHeader() {
final String[] header = Strings.emptyIfNull(getCodeConfig().getFileHeader()).split("[\n\r]+"); //$NON-NLS-1$
appendNl("/* "); //$NON-NLS-1$
for (final String headerLine : header) {
appendNl(headerLine.replaceFirst("^\\s*[/]?[*][/]?", " * ")); //$NON-NLS-1$//$NON-NLS-2$
}
appendNl("*/"); //$NON-NLS-1$
appendNl("/* Style for {0} {1} */", getLanguageSimpleName(), getLanguageVersion()); //$NON-NLS-1$
newLine();
}

}

}

0 comments on commit 27fc811

Please sign in to comment.