Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
iSorp committed May 26, 2020
2 parents 8cb0f6f + ce57851 commit 6079c55
Show file tree
Hide file tree
Showing 17 changed files with 255 additions and 427 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
out
node_modules
client/server
.vscode-test
.vscode-test

!i18n/*/*/out/
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.1.12 (May , 2020)
- Rename provider
- Block skip support
- clean up
- while control statement do/end number check (nesting)

## 0.1.11 (May 20, 2020)
- Text fixes
- Directory tree with more than one level
Expand Down
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
Fanuc Macro Executor syntax highlighting, validating and project building

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


## Features
* Compiling and linking
Expand Down Expand Up @@ -68,23 +69,24 @@ Three levels are supported: `error`, `warning` and `ignore`.
```json
"macro.lint": {
"rules" : {
"duplicateInclude": "error",
"duplicateDeclaration": "error",
"duplicateFunction": "warning",
"duplicateAddress": "ignore",
"duplicateSequence": "warning",
"duplicateLabel": "warning",
"duplicateLabelSequence": "warning",
"unknownSymbol": "error",
"whileLogicOperator": "error",
"doEndNumberTooBig": "error",
"doEndNumberNotEqual": "error",
"nestingTooDeep": "error",
"mixedConditionals": "error",
"tooManyConditionals": "error",
"incompleteParameter": "error",
"includeNotFound": "error",
"assignmentConstant": "warning"
"duplicateInclude": "error",
"duplicateDeclaration": "error",
"duplicateFunction": "warning",
"duplicateAddress": "ignore",
"duplicateSequence": "warning",
"duplicateLabel": "warning",
"duplicateLabelSequence": "warning",
"unknownSymbol": "error",
"whileLogicOperator": "error",
"doEndNumberTooBig": "error",
"doEndNumberNotEqual": "error",
"nestingTooDeep": "error",
"duplicateDoEndNumber": "warning",
"mixedConditionals": "error",
"tooManyConditionals": "error",
"incompleteParameter": "error",
"includeNotFound": "error",
"assignmentConstant": "warning"
}
```

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

### Example

Expand Down
2 changes: 1 addition & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function activate(context: ExtensionContext) {

synchronize: {
// Notify the server about file changes
fileEvents: workspace.createFileSystemWatcher('**/*.{src,def,lnk}')
fileEvents: workspace.createFileSystemWatcher('**/*.{[sS][rR][cC],[dD][eE][fF],[lL][nN][kK]}')
},
diagnosticCollectionName: 'macro',
progressOnInitialization: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"rule.nestingTooDeep": "嵌套太深",
"rule.mixedConditionals": "一个IF语句中不可同时使用&&与||运算符",
"rule.tooManyConditionals": "条件过多",
"duplicateDoEndNumber" : "Duplicate DO or END number",
"rule.incompleteParameter": "参数不完整,G代码或M代码需要数值或变量做参数",
"rule.includeNotFound": "预加载文件未找到",
"rule.assignmentConstant": "常数已赋值"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"rule.nestingTooDeep": "Verschachtelung zu tief",
"rule.mixedConditionals": "Vermischte logische operatoren [&&, ||]",
"rule.tooManyConditionals": "Zu viele Bedingungen",
"duplicateDoEndNumber" : "Doppelte DO oder END Nummer",
"rule.incompleteParameter": "Unvollständiger Parameter gefunden. G-Code oder M-Code benötigen möglicherweise einen numerischen Wert oder eine Variable als Parameter",
"rule.includeNotFound": "Datei nicht gefunden",
"rule.assignmentConstant": "Die Zuweisung erfolgt auf eine Konstante"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "macro-executor",
"displayName": "Macro Executor Language",
"description": "Fanuc Macro-Executor Programming Language",
"version": "0.1.11",
"version": "0.1.12",
"author": "iSorp",
"publisher": "iSorp",
"license": "MIT",
Expand Down
9 changes: 6 additions & 3 deletions server/src/macroLanguageService/macroLanguageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import { MacroCompletion } from './services/macroCompletions';
import { MacroCommand } from './services/macroCommands';

import {
LanguageSettings, LanguageServiceOptions, DocumentContext, DocumentLink,
SymbolInformation, Diagnostic, Position, Hover, Location,
TextDocument, CompletionList, CodeLens, TextDocumentEdit
LanguageSettings, LanguageServiceOptions, DocumentContext,
DocumentLink, SymbolInformation, Diagnostic, Position, Hover,
Location, TextDocument, CompletionList, CodeLens,
TextDocumentEdit, WorkspaceEdit
} from './macroLanguageTypes';


Expand All @@ -32,6 +33,7 @@ export interface LanguageService {
findDocumentLinks(document: TextDocument, macrofile: Macrofile, documentContext: DocumentContext): DocumentLink[];
findDocumentSymbols(document: TextDocument, macrofile: Macrofile): SymbolInformation[];
findCodeLenses(document: TextDocument, macrofile: Macrofile): CodeLens[];
doRename(document: TextDocument, position: Position, newName: string, macroFile: Macrofile): WorkspaceEdit;
doRefactorSequences(document: TextDocument, position: Position, macrofile: Macrofile, documentSettings: LanguageSettings) : TextDocumentEdit | null;
doCreateSequences(document: TextDocument, position: Position, macrofile: Macrofile, documentSettings: LanguageSettings) : TextDocumentEdit | null;
}
Expand All @@ -48,6 +50,7 @@ function createFacade(parser: Parser, hover: MacroHover, completion: MacroComple
findDocumentLinks: navigation.findDocumentLinks.bind(navigation),
findDocumentSymbols: navigation.findDocumentSymbols.bind(navigation),
findCodeLenses: navigation.findCodeLenses.bind(navigation),
doRename: navigation.doRename.bind(navigation),
doRefactorSequences: command.doRefactorSequences.bind(command),
doCreateSequences: command.doCreateSequences.bind(command)
};
Expand Down
1 change: 1 addition & 0 deletions server/src/macroLanguageService/parser/macroNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export enum NodeType {
Parameter,
Code,
SequenceNumber,
BlockSkip
}

export class LnkFile extends Node {
Expand Down
94 changes: 46 additions & 48 deletions server/src/macroLanguageService/parser/macroParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,7 @@ export class Parser {
node.valueType = nodes.ValueType.Numeric;
}
}
else if (this.peekRegExp(TokenType.Symbol, /\w\d+/i)
|| this.peekOneOf([TokenType.Address, TokenType.AddressPartial])
|| this.peek(TokenType.Ampersand)) {
else if (this.peekRegExp(TokenType.Symbol, /\w\d+/i) || this.peek(TokenType.Ampersand)) {

node.valueType = nodes.ValueType.Address;
const statement = this._parseNcStatement();
Expand Down Expand Up @@ -503,7 +501,7 @@ export class Parser {
if (type === 'def'){
return this.internalParse(text, this._parseDefFile, this.textProvider);
}
else if (type === 'src'){
else if (type === 'src') {
return this.internalParse(text, this._parseMacroFile, this.textProvider);
}
else if (type === 'lnk'){
Expand Down Expand Up @@ -758,13 +756,15 @@ export class Parser {
return null;
}

const blockSkip = this._parseBlockSkip();

// Sequence number and Label may leading a statement
let sequence:nodes.Node | null = null;
const declaration = this.declarations.get(this.token.text);
let sequence:nodes.Node | null = null;
if (!declaration){
sequence = this._parseSequenceNumber();
}
else if (declaration.type === nodes.NodeType.labelDef){
else if (declaration.type === nodes.NodeType.labelDef) {
sequence = this._parseLabel(declaration);
}

Expand All @@ -773,18 +773,33 @@ export class Parser {
|| this._parseNcStatement()
|| this.parseString();

// a statement is always a child of an existing sequence number
if (statement) {
if (sequence){
sequence.addChild(statement);
return sequence;

// Form e.g: / N100 G01
if (blockSkip) {
if (statement) {
if (sequence){
sequence.addChild(statement);
}
else {
blockSkip.addChild(statement)
}
}
else {
return statement;
if (sequence) {
blockSkip.addChild(sequence);
}
return blockSkip;
}
// Form e.g: N100 G01
else if (sequence){
if (statement) {
sequence.addChild(statement);
}
} else if (sequence){
return sequence;
}
// Form e.g: G01
else if (statement){
return statement;
}

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

public _parseBlockSkip() : nodes.Node | null {

if (!this.peekDelim('/')) {
return null;
}

const node = this.createNode(nodes.NodeType.BlockSkip);
this.consumeToken();
return this.finish(node);
}

/**
* The NC Parser works as follows:
*
Expand All @@ -876,8 +902,6 @@ export class Parser {

if (!this.peekOneOf([
TokenType.Symbol,
TokenType.Address,
TokenType.AddressPartial,
TokenType.Ampersand])) {
return null;
}
Expand Down Expand Up @@ -1443,29 +1467,8 @@ export class Parser {
public _parseAddress() : nodes.Node | null {
const node = <nodes.Address>this.create(nodes.Address);

// e.g: R100.0 [1]; R100.#[1]
if (this.peek(TokenType.Address) || this.peek(TokenType.AddressPartial)) {

if (this.accept(TokenType.Address)){
if (this.peek(TokenType.Symbol)){
let expression = this._parseSymbol();
node.addChild(expression);
}
return this.finish(node);
}
else if (this.accept(TokenType.AddressPartial)) {
if (this.peek(TokenType.BracketL) || this.peek(TokenType.Hash) || this.peek(TokenType.Symbol)){
let expression = this._parseBinaryExpr();
node.addChild(expression);
}
else {
return this.finish(node, ParseError.TermExpected, [TokenType.BracketL, TokenType.Hash]);
}
return this.finish(node);
}
}
// e.g: R100.0 [1]; R100.#[1]
else if (this.peekRegExp(TokenType.Symbol, /(^[a-z]$)/i)){
// Address e.g: R[1], R#1, R1.#[1]
if (this.peekRegExp(TokenType.Symbol, /(^([a-z])(\d*\.)?$)/i)) {
let mark = this.mark();
this.consumeToken();
if (this.peek(TokenType.BracketL) || this.peek(TokenType.Hash)){
Expand All @@ -1476,10 +1479,12 @@ export class Parser {
}
this.restoreAtMark(mark);
}
else if (this.peekRegExp(TokenType.Symbol, /(^[a-z]\d+$)/i)){
// Address e.g: R100, R100.1
else if (this.peekRegExp(TokenType.Symbol, /(^([a-z]\d+)(\.\d+)?$)/i)){
this.consumeToken();
return this.finish(node);
}

return null;
}

Expand Down Expand Up @@ -1549,17 +1554,10 @@ export class Parser {

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

// TODO if Reference type undefined, try to find type:
//
// Adress: R100.0 is fixed
// Symbol R100 is Address, Variable or NC Code
// Symbol 100.0 is fixed
// Symbol 100 is Number or Variable

if (!this.peek(TokenType.Symbol)){
return null;
}

const node = <nodes.Symbol>this.create(nodes.Symbol);
if (referenceTypes) {
node.referenceTypes = referenceTypes;
Expand Down
Loading

0 comments on commit 6079c55

Please sign in to comment.