Commit dbe834e8 authored by eckhart's avatar eckhart
Browse files

- MLW: Visual Studio Code Syntaxhighlighting-Unterstützung

- MLW: Kleinere Grammatikänderungen
parent 5e7a1add
......@@ -128,7 +128,7 @@ MAX_DROPOUTS = 3 # type: int
class HistoryRecord:
"""
Stores debugging information about one completed step in the
parsing history.
parsing history.
A parsing step is "completed" when the last one of a nested
sequence of parser-calls returns. The call stack including
......@@ -163,7 +163,7 @@ class HistoryRecord:
def err_msg(self) -> str:
return self.ERROR + ": " + "; ".join(
str(e) for e in (self.node._errors if self.node._errors else
self.node.collect_errors()[:1]))
self.node.collect_errors()[:2]))
@property
def stack(self) -> str:
......@@ -840,7 +840,8 @@ class Grammar:
record.node.pos = 0
record = HistoryRecord(self.call_stack__.copy(), stitches[-1], len(rest))
self.history__.append(record)
self.history_tracking__ = False # TODO: add an explanation here
# stop history tracking when parser returned too early
self.history_tracking__ = False
if stitches:
if rest:
stitches.append(Node(None, rest))
......@@ -871,7 +872,6 @@ class Grammar:
which have been dismissed.
"""
self.rollback__.append((location, func))
# print("push: line %i, col %i" % line_col(self.document__, len(self.document__) - location))
self.last_rb__loc__ = location
......@@ -880,15 +880,13 @@ class Grammar:
Rolls back the variable stacks (`self.variables`) to its
state at an earlier location in the parsed document.
"""
# print("rollback: line %i, col %i" % line_col(self.document__, len(self.document__) - location))
while self.rollback__ and self.rollback__[-1][0] <= location:
loc, rollback_func = self.rollback__.pop()
_, rollback_func = self.rollback__.pop()
# assert not loc > self.last_rb__loc__, \
# "Rollback confusion: line %i, col %i < line %i, col %i" % \
# (*line_col(self.document__, len(self.document__) - loc),
# *line_col(self.document__, len(self.document__) - self.last_rb__loc__))
rollback_func()
# print("rb to: line %i, col %i" % line_col(self.document__, len(self.document__) - loc))
self.last_rb__loc__ == self.rollback__[-1][0] if self.rollback__ \
else (len(self.document__) + 1)
......
......@@ -100,11 +100,11 @@ Gegenstand = EINZEILER
#### BEDEUTUNGS-POSITION #####################################################
BedeutungsPosition = { ZWW "BEDEUTUNG" [LZ] §Bedeutung [U1Bedeutung] }+
U1Bedeutung = { ZWW "U1_BEDEUTUNG" [LZ] §Bedeutung [U2Bedeutung] }+
U2Bedeutung = { ZWW "U2_BEDEUTUNG" [LZ] §Bedeutung [U3Bedeutung] }+
U3Bedeutung = { ZWW "U3_BEDEUTUNG" [LZ] §Bedeutung [U4Bedeutung] }+
U4Bedeutung = { ZWW "U4_BEDEUTUNG" [LZ] §Bedeutung [U5Bedeutung] }+
U5Bedeutung = { ZWW "U5_BEDEUTUNG" [LZ] §UntersteBedeutung }+
U1Bedeutung = { ZWW ("U_BEDEUTUNG" | "UNTERBEDEUTUNG") [LZ] §Bedeutung [U2Bedeutung] }+
U2Bedeutung = { ZWW ("UU_BEDEUTUNG" | "UNTERUNTERBEDEUTUNG") [LZ] §Bedeutung [U3Bedeutung] }+
U3Bedeutung = { ZWW "UUU_BEDEUTUNG" [LZ] §Bedeutung [U4Bedeutung] }+
U4Bedeutung = { ZWW "UUUU_BEDEUTUNG" [LZ] §Bedeutung [U5Bedeutung] }+
U5Bedeutung = { ZWW "UUUUU_BEDEUTUNG" [LZ] §UntersteBedeutung }+
Bedeutung = (Interpretamente | Bedeutungskategorie) [BelegPosition]
UntersteBedeutung = Interpretamente [BelegPosition]
......
......@@ -152,11 +152,11 @@ class MLWGrammar(Grammar):
#### BEDEUTUNGS-POSITION #####################################################
BedeutungsPosition = { ZWW "BEDEUTUNG" [LZ] §Bedeutung [U1Bedeutung] }+
U1Bedeutung = { ZWW "U1_BEDEUTUNG" [LZ] §Bedeutung [U2Bedeutung] }+
U2Bedeutung = { ZWW "U2_BEDEUTUNG" [LZ] §Bedeutung [U3Bedeutung] }+
U3Bedeutung = { ZWW "U3_BEDEUTUNG" [LZ] §Bedeutung [U4Bedeutung] }+
U4Bedeutung = { ZWW "U4_BEDEUTUNG" [LZ] §Bedeutung [U5Bedeutung] }+
U5Bedeutung = { ZWW "U5_BEDEUTUNG" [LZ] §UntersteBedeutung }+
U1Bedeutung = { ZWW ("U_BEDEUTUNG" | "UNTERBEDEUTUNG") [LZ] §Bedeutung [U2Bedeutung] }+
U2Bedeutung = { ZWW ("UU_BEDEUTUNG" | "UNTERUNTERBEDEUTUNG") [LZ] §Bedeutung [U3Bedeutung] }+
U3Bedeutung = { ZWW "UUU_BEDEUTUNG" [LZ] §Bedeutung [U4Bedeutung] }+
U4Bedeutung = { ZWW "UUUU_BEDEUTUNG" [LZ] §Bedeutung [U5Bedeutung] }+
U5Bedeutung = { ZWW "UUUUU_BEDEUTUNG" [LZ] §UntersteBedeutung }+
Bedeutung = (Interpretamente | Bedeutungskategorie) [BelegPosition]
UntersteBedeutung = Interpretamente [BelegPosition]
......@@ -290,7 +290,7 @@ class MLWGrammar(Grammar):
flexion = Forward()
genus = Forward()
wortart = Forward()
source_hash__ = "d6cf6c84b25523a02c115ead270afae4"
source_hash__ = "3791f32280610295f3748a8a0ed0aa4b"
parser_initialization__ = "upon instantiation"
COMMENT__ = r'#.*'
WHITESPACE__ = r'[\t ]*'
......@@ -368,11 +368,11 @@ class MLWGrammar(Grammar):
Bedeutungskategorie = Series(EINZEILER, Token(":"), Option(LZ), mandatory=1)
UntersteBedeutung = Series(Interpretamente, Option(BelegPosition))
Bedeutung = Series(Alternative(Interpretamente, Bedeutungskategorie), Option(BelegPosition))
U5Bedeutung = OneOrMore(Series(ZWW, Token("U5_BEDEUTUNG"), Option(LZ), UntersteBedeutung, mandatory=3))
U4Bedeutung = OneOrMore(Series(ZWW, Token("U4_BEDEUTUNG"), Option(LZ), Bedeutung, Option(U5Bedeutung), mandatory=3))
U3Bedeutung = OneOrMore(Series(ZWW, Token("U3_BEDEUTUNG"), Option(LZ), Bedeutung, Option(U4Bedeutung), mandatory=3))
U2Bedeutung = OneOrMore(Series(ZWW, Token("U2_BEDEUTUNG"), Option(LZ), Bedeutung, Option(U3Bedeutung), mandatory=3))
U1Bedeutung = OneOrMore(Series(ZWW, Token("U1_BEDEUTUNG"), Option(LZ), Bedeutung, Option(U2Bedeutung), mandatory=3))
U5Bedeutung = OneOrMore(Series(ZWW, Token("UUUUU_BEDEUTUNG"), Option(LZ), UntersteBedeutung, mandatory=3))
U4Bedeutung = OneOrMore(Series(ZWW, Token("UUUU_BEDEUTUNG"), Option(LZ), Bedeutung, Option(U5Bedeutung), mandatory=3))
U3Bedeutung = OneOrMore(Series(ZWW, Token("UUU_BEDEUTUNG"), Option(LZ), Bedeutung, Option(U4Bedeutung), mandatory=3))
U2Bedeutung = OneOrMore(Series(ZWW, Alternative(Token("UU_BEDEUTUNG"), Token("UNTERUNTERBEDEUTUNG")), Option(LZ), Bedeutung, Option(U3Bedeutung), mandatory=3))
U1Bedeutung = OneOrMore(Series(ZWW, Alternative(Token("U_BEDEUTUNG"), Token("UNTERBEDEUTUNG")), Option(LZ), Bedeutung, Option(U2Bedeutung), mandatory=3))
BedeutungsPosition = OneOrMore(Series(ZWW, Token("BEDEUTUNG"), Option(LZ), Bedeutung, Option(U1Bedeutung), mandatory=3))
Gegenstand = Synonym(EINZEILER)
Variante = Series(NegativeLookahead(KATEGORIENZEILE), Gegenstand, DPP, Belege)
......
.vscode/**
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
# Change Log
All notable changes to the "mlwcolors" extension will be documented in this file.
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## [Unreleased]
- Initial release
# README
## This is the README for your extension "mlwcolors"
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
* Split the editor (`Cmd+\` on OSX or `Ctrl+\` on Windows and Linux)
* Toggle preview (`Shift+CMD+V` on OSX or `Shift+Ctrl+V` on Windows and Linux)
* Press `Ctrl+Space` (Windows, Linux) or `Cmd+Space` (OSX) to see a list of Markdown snippets
### For more information
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
**Enjoy!**
\ No newline at end of file
{
"name": "mlwcolors",
"displayName": "MLWColors",
"description": "Mittellateinisches Wörterbuch Farben für Syntaxhervorhebung",
"version": "0.0.1",
"publisher": "jecki",
"engines": {
"vscode": "^1.18.0"
},
"categories": [
"Themes"
],
"contributes": {
"themes": [
{
"label": "MLWColors",
"uiTheme": "vs",
"path": "./themes/MLWColors-color-theme.json"
}
]
}
}
\ No newline at end of file
{
"$schema": "vscode://schemas/color-theme",
"name": "MLWColors",
"include": "./light_vs.json",
"tokenColors": [
{
"scope": "keyword.secondary.mlw",
"settings": {
"foreground": "#a000ff"
}
}
]
}
{
"$schema": "vscode://schemas/color-theme",
"name": "Light Default Colors",
"colors": {
"editor.background": "#FFFFFF",
"editor.foreground": "#000000",
"editor.inactiveSelectionBackground": "#E5EBF1",
"editorIndentGuide.background": "#D3D3D3",
"editor.selectionHighlightBackground": "#ADD6FF4D",
"editorSuggestWidget.background": "#F3F3F3",
"activityBarBadge.background": "#007ACC",
"sideBarTitle.foreground": "#6F6F6F"
}
}
\ No newline at end of file
{
"$schema": "vscode://schemas/color-theme",
"name": "Light (Visual Studio)",
"include": "./light_defaults.json",
"tokenColors": [
{
"scope": ["meta.embedded", "source.groovy.embedded"],
"settings": {
"foreground": "#000000ff",
"background":"#ffffffff"
}
},
{
"scope": "emphasis",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "strong",
"settings": {
"fontStyle": "bold"
}
},
{
"scope": "meta.diff.header",
"settings": {
"foreground": "#000080"
}
},
{
"scope": "comment",
"settings": {
"foreground": "#008000"
}
},
{
"scope": "constant.language",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": [
"constant.numeric"
],
"settings": {
"foreground": "#09885a"
}
},
{
"scope": "constant.regexp",
"settings": {
"foreground": "#811f3f"
}
},
{
"name": "css tags in selectors, xml tags",
"scope": "entity.name.tag",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "entity.name.selector",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "entity.other.attribute-name",
"settings": {
"foreground": "#ff0000"
}
},
{
"scope": [
"entity.other.attribute-name.class.css",
"entity.other.attribute-name.class.mixin.css",
"entity.other.attribute-name.id.css",
"entity.other.attribute-name.parent-selector.css",
"entity.other.attribute-name.pseudo-class.css",
"entity.other.attribute-name.pseudo-element.css",
"source.css.less entity.other.attribute-name.id",
"entity.other.attribute-name.attribute.scss",
"entity.other.attribute-name.scss"
],
"settings": {
"foreground": "#800000"
}
},
{
"scope": "invalid",
"settings": {
"foreground": "#cd3131"
}
},
{
"scope": "markup.underline",
"settings": {
"fontStyle": "underline"
}
},
{
"scope": "markup.bold",
"settings": {
"fontStyle": "bold",
"foreground": "#000080"
}
},
{
"scope": "markup.heading",
"settings": {
"fontStyle": "bold",
"foreground": "#800000"
}
},
{
"scope": "markup.italic",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "markup.inserted",
"settings": {
"foreground": "#09885a"
}
},
{
"scope": "markup.deleted",
"settings": {
"foreground": "#a31515"
}
},
{
"scope": "markup.changed",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": [
"beginning.punctuation.definition.quote.markdown",
"beginning.punctuation.definition.list.markdown"
],
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "markup.inline.raw",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "meta.selector",
"settings": {
"foreground": "#800000"
}
},
{
"name": "brackets of XML/HTML tags",
"scope": "punctuation.definition.tag",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "meta.preprocessor",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "meta.preprocessor.string",
"settings": {
"foreground": "#a31515"
}
},
{
"scope": "meta.preprocessor.numeric",
"settings": {
"foreground": "#09885a"
}
},
{
"scope": "meta.structure.dictionary.key.python",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "storage",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "storage.type",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "storage.modifier",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "string",
"settings": {
"foreground": "#a31515"
}
},
{
"scope": [
"string.comment.buffered.block.jade",
"string.quoted.jade",
"string.interpolated.jade",
"string.unquoted.plain.in.yaml",
"string.unquoted.plain.out.yaml",
"string.unquoted.block.yaml",
"string.quoted.single.yaml",
"string.quoted.double.xml",
"string.quoted.single.xml",
"string.unquoted.cdata.xml",
"string.quoted.double.html",
"string.quoted.single.html",
"string.unquoted.html",
"string.quoted.single.handlebars",
"string.quoted.double.handlebars"
],
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "string.regexp",
"settings": {
"foreground": "#811f3f"
}
},
{
"name": "String interpolation",
"scope": [
"punctuation.definition.template-expression.begin",
"punctuation.definition.template-expression.end",
"punctuation.section.embedded"
],
"settings": {
"foreground": "#0000ff"
}
},
{
"name": "Reset JavaScript string interpolation expression",
"scope": [
"meta.template.expression"
],
"settings": {
"foreground": "#000000"
}
},
{
"scope": [
"support.constant.property-value",
"support.constant.font-name",
"support.constant.media-type",
"support.constant.media",
"constant.other.color.rgb-value",
"constant.other.rgb-value",
"support.constant.color"
],
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": [
"support.type.vendored.property-name",
"support.type.property-name",
"variable.css",
"variable.scss",
"variable.other.less",
"source.coffee.embedded"
],
"settings": {
"foreground": "#ff0000"
}
},
{
"scope": "support.type.property-name.json",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "keyword",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "keyword.control",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "keyword.operator",
"settings": {
"foreground": "#000000"
}
},
{
"scope": [
"keyword.operator.new",
"keyword.operator.expression",
"keyword.operator.cast",
"keyword.operator.sizeof",
"keyword.operator.logical.python"
],
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "keyword.other.unit",
"settings": {
"foreground": "#09885a"
}
},
{
"scope": [
"punctuation.section.embedded.begin.php",
"punctuation.section.embedded.end.php"
],
"settings": {
"foreground": "#800000"
}
},
{
"scope": "support.function.git-rebase",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "constant.sha.git-rebase",
"settings": {
"foreground": "#09885a"
}
},
{
"name": "coloring of the Java import and package identifiers",
"scope": [
"storage.modifier.import.java",
"variable.language.wildcard.java",
"storage.modifier.package.java"
],
"settings": {
"foreground": "#000000"
}
},
{
"name": "this.self",
"scope": "variable.language",
"settings": {
"foreground": "#0000ff"
}
}
]
}
\ No newline at end of file
# Welcome to your VS Code Extension
## What's in the folder
* This folder contains all of the files necessary for your color theme extension.
* `package.json` - this is the manifest file that defines the location of the theme file.
and specifies the base theme of the theme.
* `themes/MLWColors-color-theme.json` - the color theme definition file.
## Get up and running straight away
* Press `F5` to open a new window with your extension loaded.
* Open `File > Preferences > Color Themes` and pick your color theme.
* Open a file that has a language associated. The languages' configured grammar will tokenize the text and assign 'scopes' to the tokens. To examine these scopes, invoke the `Inspect TM Scopes` command from the Commmand Palette (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) .
## Make changes
* You can relaunch the extension from the debug toolbar after making changes to the files listed above.
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
* When editing workbench colors, it's easiest to test the colors in the settings under `workbench.colorCustomizations` and `workbench.tokenColorCustomizations`. When done, run the `Generate Color Theme From Current Settings` command to generate an updated content for the color theme definition file.
## Adopt your theme to Visual Studio Code
* The token colorization is done based on standard TextMate themes. Colors are matched against one or more scopes.
To learn more about scopes and how they're used, check out the [theme](https://code.visualstudio.com/docs/extensions/themes-snippets-colorizers#_adding-a-new-color-theme) documentation.
## Install your extension