Skip to content

Commit 6079c55

Browse files
committed
Merge branch 'develop'
2 parents 8cb0f6f + ce57851 commit 6079c55

17 files changed

Lines changed: 255 additions & 427 deletions

File tree

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
out
22
node_modules
3-
client/server
4-
.vscode-test
3+
.vscode-test
4+
5+
!i18n/*/*/out/

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.1.12 (May , 2020)
2+
- Rename provider
3+
- Block skip support
4+
- clean up
5+
- while control statement do/end number check (nesting)
6+
17
## 0.1.11 (May 20, 2020)
28
- Text fixes
39
- Directory tree with more than one level

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
Fanuc Macro Executor syntax highlighting, validating and project building
1111

1212
## News
13-
* The build system supports now a source directory tree with more than one level. [Internal build system](#internalbuild)
14-
* Additional compiler selections
13+
- Rename provider
14+
- Block skip support "/"
15+
1516

1617
## Features
1718
* Compiling and linking
@@ -68,23 +69,24 @@ Three levels are supported: `error`, `warning` and `ignore`.
6869
```json
6970
"macro.lint": {
7071
"rules" : {
71-
"duplicateInclude": "error",
72-
"duplicateDeclaration": "error",
73-
"duplicateFunction": "warning",
74-
"duplicateAddress": "ignore",
75-
"duplicateSequence": "warning",
76-
"duplicateLabel": "warning",
77-
"duplicateLabelSequence": "warning",
78-
"unknownSymbol": "error",
79-
"whileLogicOperator": "error",
80-
"doEndNumberTooBig": "error",
81-
"doEndNumberNotEqual": "error",
82-
"nestingTooDeep": "error",
83-
"mixedConditionals": "error",
84-
"tooManyConditionals": "error",
85-
"incompleteParameter": "error",
86-
"includeNotFound": "error",
87-
"assignmentConstant": "warning"
72+
"duplicateInclude": "error",
73+
"duplicateDeclaration": "error",
74+
"duplicateFunction": "warning",
75+
"duplicateAddress": "ignore",
76+
"duplicateSequence": "warning",
77+
"duplicateLabel": "warning",
78+
"duplicateLabelSequence": "warning",
79+
"unknownSymbol": "error",
80+
"whileLogicOperator": "error",
81+
"doEndNumberTooBig": "error",
82+
"doEndNumberNotEqual": "error",
83+
"nestingTooDeep": "error",
84+
"duplicateDoEndNumber": "warning",
85+
"mixedConditionals": "error",
86+
"tooManyConditionals": "error",
87+
"incompleteParameter": "error",
88+
"includeNotFound": "error",
89+
"assignmentConstant": "warning"
8890
}
8991
```
9092

@@ -133,10 +135,10 @@ The following parameters are passed to the external script:
133135
## Internal build system
134136
If `macro.build.makeFile` is empty the internal system is used.
135137
>- The compiler must be available over the system path
136-
>- All `.src` files under the folder` macro.project.sourcePath` and its subfolders will be compiled
138+
>- All `.src` files under the folder `macro.project.sourcePath` and its subfolders will be compiled
137139
>- There are two ways to define a libray path in a link file:
138-
> 1. Absolut: *CNC=C:\lib.mex*
139-
> 2. Relativ: *CNC=..\lnk\lib.mex* (relative to `macro.project.buildPath`)
140+
> 1. absolute: *CNC=C:\lib.mex*
141+
> 2. relative: *CNC=..\lnk\lib.mex* (relative to `macro.project.buildPath`)
140142

141143
### Example
142144

client/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function activate(context: ExtensionContext) {
5050

5151
synchronize: {
5252
// Notify the server about file changes
53-
fileEvents: workspace.createFileSystemWatcher('**/*.{src,def,lnk}')
53+
fileEvents: workspace.createFileSystemWatcher('**/*.{[sS][rR][cC],[dD][eE][fF],[lL][nN][kK]}')
5454
},
5555
diagnosticCollectionName: 'macro',
5656
progressOnInitialization: true,

i18n/chs/server/out/macroLanguageService/services/lintRules.i18n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"rule.nestingTooDeep": "嵌套太深",
1414
"rule.mixedConditionals": "一个IF语句中不可同时使用&&与||运算符",
1515
"rule.tooManyConditionals": "条件过多",
16+
"duplicateDoEndNumber" : "Duplicate DO or END number",
1617
"rule.incompleteParameter": "参数不完整,G代码或M代码需要数值或变量做参数",
1718
"rule.includeNotFound": "预加载文件未找到",
1819
"rule.assignmentConstant": "常数已赋值"

i18n/deu/server/out/macroLanguageService/services/lintRules.i18n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"rule.nestingTooDeep": "Verschachtelung zu tief",
1414
"rule.mixedConditionals": "Vermischte logische operatoren [&&, ||]",
1515
"rule.tooManyConditionals": "Zu viele Bedingungen",
16+
"duplicateDoEndNumber" : "Doppelte DO oder END Nummer",
1617
"rule.incompleteParameter": "Unvollständiger Parameter gefunden. G-Code oder M-Code benötigen möglicherweise einen numerischen Wert oder eine Variable als Parameter",
1718
"rule.includeNotFound": "Datei nicht gefunden",
1819
"rule.assignmentConstant": "Die Zuweisung erfolgt auf eine Konstante"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "macro-executor",
33
"displayName": "Macro Executor Language",
44
"description": "Fanuc Macro-Executor Programming Language",
5-
"version": "0.1.11",
5+
"version": "0.1.12",
66
"author": "iSorp",
77
"publisher": "iSorp",
88
"license": "MIT",

server/src/macroLanguageService/macroLanguageService.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import { MacroCompletion } from './services/macroCompletions';
1212
import { MacroCommand } from './services/macroCommands';
1313

1414
import {
15-
LanguageSettings, LanguageServiceOptions, DocumentContext, DocumentLink,
16-
SymbolInformation, Diagnostic, Position, Hover, Location,
17-
TextDocument, CompletionList, CodeLens, TextDocumentEdit
15+
LanguageSettings, LanguageServiceOptions, DocumentContext,
16+
DocumentLink, SymbolInformation, Diagnostic, Position, Hover,
17+
Location, TextDocument, CompletionList, CodeLens,
18+
TextDocumentEdit, WorkspaceEdit
1819
} from './macroLanguageTypes';
1920

2021

@@ -32,6 +33,7 @@ export interface LanguageService {
3233
findDocumentLinks(document: TextDocument, macrofile: Macrofile, documentContext: DocumentContext): DocumentLink[];
3334
findDocumentSymbols(document: TextDocument, macrofile: Macrofile): SymbolInformation[];
3435
findCodeLenses(document: TextDocument, macrofile: Macrofile): CodeLens[];
36+
doRename(document: TextDocument, position: Position, newName: string, macroFile: Macrofile): WorkspaceEdit;
3537
doRefactorSequences(document: TextDocument, position: Position, macrofile: Macrofile, documentSettings: LanguageSettings) : TextDocumentEdit | null;
3638
doCreateSequences(document: TextDocument, position: Position, macrofile: Macrofile, documentSettings: LanguageSettings) : TextDocumentEdit | null;
3739
}
@@ -48,6 +50,7 @@ function createFacade(parser: Parser, hover: MacroHover, completion: MacroComple
4850
findDocumentLinks: navigation.findDocumentLinks.bind(navigation),
4951
findDocumentSymbols: navigation.findDocumentSymbols.bind(navigation),
5052
findCodeLenses: navigation.findCodeLenses.bind(navigation),
53+
doRename: navigation.doRename.bind(navigation),
5154
doRefactorSequences: command.doRefactorSequences.bind(command),
5255
doCreateSequences: command.doCreateSequences.bind(command)
5356
};

server/src/macroLanguageService/parser/macroNodes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ export enum NodeType {
454454
Parameter,
455455
Code,
456456
SequenceNumber,
457+
BlockSkip
457458
}
458459

459460
export class LnkFile extends Node {

server/src/macroLanguageService/parser/macroParser.ts

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,7 @@ export class Parser {
423423
node.valueType = nodes.ValueType.Numeric;
424424
}
425425
}
426-
else if (this.peekRegExp(TokenType.Symbol, /\w\d+/i)
427-
|| this.peekOneOf([TokenType.Address, TokenType.AddressPartial])
428-
|| this.peek(TokenType.Ampersand)) {
426+
else if (this.peekRegExp(TokenType.Symbol, /\w\d+/i) || this.peek(TokenType.Ampersand)) {
429427

430428
node.valueType = nodes.ValueType.Address;
431429
const statement = this._parseNcStatement();
@@ -503,7 +501,7 @@ export class Parser {
503501
if (type === 'def'){
504502
return this.internalParse(text, this._parseDefFile, this.textProvider);
505503
}
506-
else if (type === 'src'){
504+
else if (type === 'src') {
507505
return this.internalParse(text, this._parseMacroFile, this.textProvider);
508506
}
509507
else if (type === 'lnk'){
@@ -758,13 +756,15 @@ export class Parser {
758756
return null;
759757
}
760758

759+
const blockSkip = this._parseBlockSkip();
760+
761761
// Sequence number and Label may leading a statement
762-
let sequence:nodes.Node | null = null;
763762
const declaration = this.declarations.get(this.token.text);
763+
let sequence:nodes.Node | null = null;
764764
if (!declaration){
765765
sequence = this._parseSequenceNumber();
766766
}
767-
else if (declaration.type === nodes.NodeType.labelDef){
767+
else if (declaration.type === nodes.NodeType.labelDef) {
768768
sequence = this._parseLabel(declaration);
769769
}
770770

@@ -773,18 +773,33 @@ export class Parser {
773773
|| this._parseNcStatement()
774774
|| this.parseString();
775775

776-
// a statement is always a child of an existing sequence number
777-
if (statement) {
778-
if (sequence){
779-
sequence.addChild(statement);
780-
return sequence;
776+
777+
// Form e.g: / N100 G01
778+
if (blockSkip) {
779+
if (statement) {
780+
if (sequence){
781+
sequence.addChild(statement);
782+
}
783+
else {
784+
blockSkip.addChild(statement)
785+
}
781786
}
782-
else {
783-
return statement;
787+
if (sequence) {
788+
blockSkip.addChild(sequence);
789+
}
790+
return blockSkip;
791+
}
792+
// Form e.g: N100 G01
793+
else if (sequence){
794+
if (statement) {
795+
sequence.addChild(statement);
784796
}
785-
} else if (sequence){
786797
return sequence;
787798
}
799+
// Form e.g: G01
800+
else if (statement){
801+
return statement;
802+
}
788803

789804
// Variable and label declaratio within a function
790805
const declaraionType = this._parseVariableDeclaration() || this._parseLabelDeclaration();
@@ -859,6 +874,17 @@ export class Parser {
859874
return this.finish(node);
860875
}
861876

877+
public _parseBlockSkip() : nodes.Node | null {
878+
879+
if (!this.peekDelim('/')) {
880+
return null;
881+
}
882+
883+
const node = this.createNode(nodes.NodeType.BlockSkip);
884+
this.consumeToken();
885+
return this.finish(node);
886+
}
887+
862888
/**
863889
* The NC Parser works as follows:
864890
*
@@ -876,8 +902,6 @@ export class Parser {
876902

877903
if (!this.peekOneOf([
878904
TokenType.Symbol,
879-
TokenType.Address,
880-
TokenType.AddressPartial,
881905
TokenType.Ampersand])) {
882906
return null;
883907
}
@@ -1443,29 +1467,8 @@ export class Parser {
14431467
public _parseAddress() : nodes.Node | null {
14441468
const node = <nodes.Address>this.create(nodes.Address);
14451469

1446-
// e.g: R100.0 [1]; R100.#[1]
1447-
if (this.peek(TokenType.Address) || this.peek(TokenType.AddressPartial)) {
1448-
1449-
if (this.accept(TokenType.Address)){
1450-
if (this.peek(TokenType.Symbol)){
1451-
let expression = this._parseSymbol();
1452-
node.addChild(expression);
1453-
}
1454-
return this.finish(node);
1455-
}
1456-
else if (this.accept(TokenType.AddressPartial)) {
1457-
if (this.peek(TokenType.BracketL) || this.peek(TokenType.Hash) || this.peek(TokenType.Symbol)){
1458-
let expression = this._parseBinaryExpr();
1459-
node.addChild(expression);
1460-
}
1461-
else {
1462-
return this.finish(node, ParseError.TermExpected, [TokenType.BracketL, TokenType.Hash]);
1463-
}
1464-
return this.finish(node);
1465-
}
1466-
}
1467-
// e.g: R100.0 [1]; R100.#[1]
1468-
else if (this.peekRegExp(TokenType.Symbol, /(^[a-z]$)/i)){
1470+
// Address e.g: R[1], R#1, R1.#[1]
1471+
if (this.peekRegExp(TokenType.Symbol, /(^([a-z])(\d*\.)?$)/i)) {
14691472
let mark = this.mark();
14701473
this.consumeToken();
14711474
if (this.peek(TokenType.BracketL) || this.peek(TokenType.Hash)){
@@ -1476,10 +1479,12 @@ export class Parser {
14761479
}
14771480
this.restoreAtMark(mark);
14781481
}
1479-
else if (this.peekRegExp(TokenType.Symbol, /(^[a-z]\d+$)/i)){
1482+
// Address e.g: R100, R100.1
1483+
else if (this.peekRegExp(TokenType.Symbol, /(^([a-z]\d+)(\.\d+)?$)/i)){
14801484
this.consumeToken();
14811485
return this.finish(node);
14821486
}
1487+
14831488
return null;
14841489
}
14851490

@@ -1549,17 +1554,10 @@ export class Parser {
15491554

15501555
public _parseSymbol(referenceTypes?: nodes.ReferenceType[]): nodes.Symbol | null {
15511556

1552-
// TODO if Reference type undefined, try to find type:
1553-
//
1554-
// Adress: R100.0 is fixed
1555-
// Symbol R100 is Address, Variable or NC Code
1556-
// Symbol 100.0 is fixed
1557-
// Symbol 100 is Number or Variable
1558-
15591557
if (!this.peek(TokenType.Symbol)){
15601558
return null;
15611559
}
1562-
1560+
15631561
const node = <nodes.Symbol>this.create(nodes.Symbol);
15641562
if (referenceTypes) {
15651563
node.referenceTypes = referenceTypes;

0 commit comments

Comments
 (0)