Giter VIP home page Giter VIP logo

cslycli's Introduction

cslycli's People

Contributors

b3b00 avatar olduh29 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

tanzui

cslycli's Issues

token labels

Csly CLI should support lexeme labels as in

[Sugar("(")]
    [LexemeLabel("en","left paranthesis")]
    [LexemeLabel("fr","paranthèse ouvrante")]
    LeftPar,

This could be done using an attribute on token definition (using the same attributes mechanism as for production method names)

@label("en","left paranthesis");
@label("fr","paranthèse ouvrante");
[Sugar] LeftPar: "(";

extension named nodes

allow to name nodes in extension definition

name arriving node with

-> (<NAME>) 'x' -> 

transition to node

-> 'y' @<NAME>

This will need to define transitions on many lines to allow caming back to a named node (looping or branching)

lexer extraction fails on CSLy sample JsonTokenGeneric

lexer extraction fails on https://github.com/b3b00/csly/blob/dev/src/samples/jsonparser/JsonTokenGeneric.cs
probably because tokens define a channel.
furthermore BOOLEAN token defines 2 possible values :

[Lexeme(GenericToken.KeyWord,channel:0, "true", "false")]
        BOOLEAN = 4,

generated lexer spec is

genericLexer JsonTokenGeneric;

[String] STRING;

[Double] DOUBLE;

[Int] INT;

[KeyWord] BOOLEAN : "0";

[Sugar] ACCG : "0";

[Sugar] ACCD : "0";

[Sugar] CROG : "0";

[Sugar] CROD : "0";

[Sugar] COMMA : "0";

[Sugar] COLON : "0";

provide an API

expose a C# API to allow use of spec files from any .net app.

IndentedWhileParser extraction causes compilation error

extracted IndentedWhileParserGeneric produces
grammar spec :


genericLexer IndentedWhileTokenGeneric;

[IndentationAware(true)]
[KeyWord] IF : "IF";
[KeyWord] IF : "if";

[KeyWord] THEN : "THEN";
[KeyWord] THEN : "then";

[KeyWord] ELSE : "ELSE";
[KeyWord] ELSE : "else";

[KeyWord] WHILE : "WHILE";
[KeyWord] WHILE : "while";

[KeyWord] DO : "DO";
[KeyWord] DO : "do";

[KeyWord] SKIP : "SKIP";
[KeyWord] SKIP : "skip";

[KeyWord] TRUE : "TRUE";
[KeyWord] TRUE : "true";

[KeyWord] FALSE : "FALSE";
[KeyWord] FALSE : "false";

[KeyWord] NOT : "NOT";
[KeyWord] NOT : "not";

[KeyWord] AND : "AND";
[KeyWord] AND : "and";

[KeyWord] OR : "OR";
[KeyWord] OR : "or";

[KeyWord] PRINT : "PRINT";
[KeyWord] PRINT : "print";

[KeyWord] RETURN : "RETURN";
[KeyWord] RETURN : "return";

[AlphaNumDashId] IDENTIFIER;

[String] STRING;

[Int] INT;

[Sugar] GREATER : ">";

[Sugar] LESSER : "<";

[Sugar] EQUALS : "==";

[Sugar] DIFFERENT : "!=";

[Sugar] CONCAT : ".";

[Sugar] ASSIGN : ":=";

[Sugar] PLUS : "+";

[Sugar] MINUS : "-";

[Sugar] TIMES : "*";

[Sugar] DIVIDE : "/";

[Sugar] SEMICOLON : ";";

[SingleLineComment] COMMENT : "#";



parser IndentedWhileParserGeneric;

[UseMemoization]
[Right 50] LESSER;
[Right 50] GREATER;
[Right 50] EQUALS;
[Right 50] DIFFERENT;
[Right 10] CONCAT;
program: sequence;
block : INDENT[d] sequence UINDENT[d];
statement : block;
sequence: statement*;
statement: IF[d] IndentedWhileParserGeneric_expressions THEN[d] block (ELSE[d] block)?;
statement: WHILE[d] IndentedWhileParserGeneric_expressions DO[d] block;
statement: IDENTIFIER ASSIGN[d] IndentedWhileParserGeneric_expressions;
statement: SKIP[d];
statement: RETURN[d] IndentedWhileParserGeneric_expressions;
statement: PRINT[d] IndentedWhileParserGeneric_expressions;
primary: INT;
primary: TRUE;
primary: FALSE;
primary: STRING;
primary: IDENTIFIER;
[Operand] operand: primary;
[Right 10] PLUS;
[Right 10] MINUS;
[Right 50] TIMES;
[Right 50] DIVIDE;
[Prefix 100] MINUS;
[Right 10] OR;
[Right 50] AND;
[Prefix 100] NOT;

When compiled an exception is thrown :

non terminal clause INDENT can not be discarded ! 84

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.