Coder Social home page Coder Social logo

apaz-cli / daisho Goto Github PK

View Code? Open in Web Editor NEW
38.0 3.0 2.0 3.01 MB

A high level programming language which compiles to C.

License: GNU General Public License v3.0

Shell 0.83% Python 3.05% C 96.12%
compiler c polymorphic-types programming-language experimental-language

daisho's Issues

Grammar railroad diagram

Using a modified peg/leg from here https://github.com/mingodad/peg to convert the grammar/Grammar.peg in an EBNF understood by https://www.bottlecaps.de/rr/ui to generate a nice railroad diagram (https://en.wikipedia.org/wiki/Syntax_diagram) to help show/understand the syntax.

Command to generate before some minor manual fixes (basically comment out what is not accepted) peg -e syntax.peg .

Copy and paste the EBNF shown bellow at https://www.bottlecaps.de/rr/ui on the tab Edit Grammar then click on the tab View Diagram.

//To be viewd at https://www.bottlecaps.de/rr/ui

CompilationUnit ::=
	 _ TopLevelDeclaration+ _ _NOT_  .

_ ::=
	 ( WS | ML_COMMENT | SL_COMMENT )*

TopLevelDeclaration ::=
	 _
	| GlobalVariableDeclaration
	| FunctionDeclaration
	| ClassDeclaration
	| TraitDeclaration
	| TraitImplementation
	| CTypeDeclaration
	| CFlagDeclaration
	| ImportStatement

GlobalVariableDeclaration ::=
	 "A"

FunctionDeclaration ::=
	 "F"

ClassDeclaration ::=
	 "class" _ STypeIdent _ TraitConstraint? _ "{" _ ClassMember* _ "}" _ ";"?

TraitDeclaration ::=
	 "trait" SIdent ";"

TraitImplementation ::=
	 "impl" _ STypeIdent _ "for" _ STypeIdent _ "where"

CTypeDeclaration ::=
	 "ctype" _ CTypeIdent _ ";"

CFlagDeclaration ::=
	 "cflag" _ StringLiteral _ ";"

ImportStatement ::=
	 ( "import" | "include" ) _ StringLiteral _ ";"

ClassMember ::=
	 _

TraitConstraint ::=
	 ( "impl" _ STypeIdent _ WhereConstraint? )?

STypeIdent ::=
	 [_A-Z] [_a-zA-Z0-9]+

WhereConstraint ::=
	 ( "where" _ STypeIdent _ "impl" _ TraitList )?

TraitList ::=
	 STypeIdent

SIdent ::=
	 ( [_a-zA-Z] | GreekChar ) ( [_a-zA-Z0-9] | GreekChar )+

CTypeIdent ::=
	 [_a-zA-Z] [_a-zA-Z0-9]+ "*"*

StringLiteral ::=
	 SCharFrag+

CTBindDeclaration ::=
	 "tbind" _ ";"

CFBindDeclaration ::=
	 "fbind" _ ";"

Statement ::=
	 ";"
	| Expr
	| BlockStatement
	| IfStatement
	| ElseStatement
	| ForStatement
	| WhileStatement
	| ReturnStatement

Expr ::=
	 "expr"

BlockStatement ::=
	 "{" _ Statement* _ "}"

IfStatement ::=
	 "if"

ElseStatement ::=
	 "else"

ForStatement ::=
	 "for"

WhileStatement ::=
	 "while" _ "(" _ Expr _ "}" _

ReturnStatement ::=
	 _ ( "return" | "ret" ) _ Expr _ ";" _

GreekChar ::=
	 [αβγδεζηθικλμνξοπρσςτυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ]

SType ::=
	 STypeIdent STypePostfix+

STypePostfix ::=
	 "*"
	| "[]"
	| ( "<" SType ">" )

SCharFrag ::=
	 '"' SChar+ '"'

SChar ::=
	 [^"\\\r\n]
	| EscapeSequence

EscapeSequence ::=
	 ( "\\" ['"?abfnrtv\\] )
	| ( "\\x" [0-9A-F]+ )

WS ::=
	 [ \t\r\n]+

ML_COMMENT ::=
	 "/*" .*? "*/"

SL_COMMENT ::=
	 "//" [^\n]*


//Added tokens for railroad generation
_NOT_ ::= '!'
_AND_ ::= '&'

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.