Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client commands #164

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/language-support/src/antlr-grammar/ConsoleCommandLexer.g4
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
lexer grammar ConsoleCommandLexer;

import CypherLexer;

PARAM : P A R A M S?;

HELP : H E L P;

PLAY: P L A Y;

CLEAR: C L E A R;

HISTORY: H I S T O R Y;

SNAKE: S N A K E;
126 changes: 126 additions & 0 deletions packages/language-support/src/antlr-grammar/ConsoleCommandParser.g4
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
parser grammar ConsoleCommandParser;

import CypherParser;

options { tokenVocab = ConsoleCommandLexer; }

// PLAY: 'play';
// Re use Cypher lexer ??? declreare here or not? ?
// HELP: 'help';

consoleCommand: COLON (helpCmd | playCmd | clearCmd | history | use | snake | paramsCmd | cypherQuery);

paramsCmd: PARAM (LIST | CLEAR | expression)?;

helpCmd: HELP unescapedSymbolicNameString;

playCmd: PLAY unescapedSymbolicNameString;

clearCmd: CLEAR;

history: HISTORY;

use: USE symbolicAliasName;

snake: SNAKE;

// cypher here???
// then prop to the lang support pkg, use client command or not?

cypherQuery: statements





/*
cypherConsoleCommandName ( cypherConsoleCommandParameters )? ;
cypherConsoleCommandName: COLON symbolicNameString (MINUS symbolicNameString)*;

cypherConsoleCommandParameters : cypherConsoleCommandParameter ( cypherConsoleCommandParameter )* ;

cypherConsoleCommandParameter:
*/
// url
// | json
// | arrowExpression
// | mapLiteral
// | keyValueLiteral
// | stringLiteral
// | numberLiteral
// | booleanLiteralRule
// | subCommand
// | commandPath;

// url: uri;

//uri: scheme '://' login? host (':' port)? ('/' path)? urlQuery? frag? ;


// arrowExpression: symbolicNameString '=>' expression;

/*
scheme: string;

host: '/'? (hostname | hostnumber);

hostname: string ('.' string)*;

hostnumber: urlDigits '.' urlDigits '.' urlDigits '.' urlDigits;

port: urlDigits;

path: string ('/' string)*;

user: string;

login: user ':' password '@';

password: string;

frag: ('#' string);

urlQuery: ('?' search);

search: searchparameter ('&' searchparameter)*;

searchparameter: string ('=' (string | urlDigits /* | UrlHex* /))?;

string: symbolicNameString (('+'| '.')? symbolicNameString)*? ;

urlDigits: UNSIGNED_DECIMAL_INTEGER+;

// JSON

/*
json: value;

obj : '{' pair (',' pair )* '}'
| '{' '}'
;

pair : stringLiteral ':' value
;

array : '[' value (',' value )* ']'
| '[' ']'
;

value : stringLiteral
| numberLiteral
| obj
| array
| booleanLiteralRule
| NULL
;


keyValueLiteral : variable ':' ( stringLiteral | numberLiteral | booleanLiteralRule | symbolicNameString ) ;

commandPath : ( '/' ( symbolicNameString | numberLiteral ) )+ '/'? ;


subCommand : ( symbolicNameString ( '-' symbolicNameString )* ) ;

booleanLiteralRule: TRUE | FALSE ;
*/
11 changes: 11 additions & 0 deletions packages/language-support/src/generated-parser/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import { CharStreams, CommonTokenStream } from 'antlr4';
import Lexer from './ConsoleCommandLexer';
import Parser from './ConsoleCommandParser';

const inputStream = CharStreams.fromString(':param 3+3');
const lexer = new Lexer(inputStream);
const tokenStream = new CommonTokenStream(lexer);
const parser = new Parser(tokenStream);

console.log(parser.consoleCommand().getText())