ana's People
ana's Issues
Grammar railroad diagram
Using this online tool https://www.bottlecaps.de/convert/ to convert the grammar.y
in an EBNF understood by https://www.bottlecaps.de/rr/ui and adding the tokens from lexer.l
manually we can have a nice railroad diagram (https://en.wikipedia.org/wiki/Syntax_diagram).
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
.
/* converted on Wed Apr 13, 2022, 12:17 (UTC+02) by bison-to-w3c v0.57 which is Copyright (c) 2011-2022 by Gunther Rademacher <[email protected]> */
program ::= statement*
statement
::= ( assignment_expression | throw_stmt ) ';'
| function_def
| class_def
| trycatch_stmt
| selection_stmt
selection_stmt
::= T_IF '(' assignment_expression ')' '{' if_statements '}' else_if_stmts? else_stmt?
| ( T_WHILE '(' | T_FOR '(' assignment_expression ';' assignment_expression ';' | T_FOREACH '(' T_ID T_IN ) assignment_expression ')' '{' if_statements '}'
else_if_stmts
::= elseif+
elseif ::= T_ELSE_IF '(' assignment_expression ')' '{' if_statements '}'
else_stmt
::= T_ELSE '{' if_statements '}'
if_statements
::= if_statement*
if_statement
::= ( assignment_expression | jump_statement | throw_stmt ) ';'
| trycatch_stmt
| selection_stmt
throw_stmt
::= T_THROW assignment_expression
trycatch_stmt
::= T_TRY '{' stmt_group '}' T_CATCH '(' T_ID ')' '{' stmt_group '}'
stmt_group
::= stmt*
stmt ::= ( assignment_expression | jump_statement | throw_stmt ) ';'
| trycatch_stmt
| selection_stmt
function_statements
::= function_statement*
function_statement
::= ( assignment_expression | jump_statement | throw_stmt ) ';'
| trycatch_stmt
| selection_stmt
jump_statement
::= T_RETURN optional_assignment_expression
| T_BREAK
| T_CONTINUE
optional_assignment_expression
::= assignment_expression?
optional_extends
::= ( ':' T_ID )?
function_def
::= T_FUNCTION T_ID '(' optional_parameter_list ')' '{' function_statements '}'
function_expression
::= T_FUNCTION '(' optional_parameter_list ')' '{' function_statements '}'
class_statement
::= function_def
class_def
::= T_CLASS T_ID optional_extends '{' class_statement* '}'
primary_expression
::= T_ID
| constant
| '(' assignment_expression ')'
| '{' opt_key_vpairs '}'
| '[' optional_argument_list ']'
| function_expression
opt_key_vpairs
::= ( keyvpair ( ',' keyvpair )* )?
keyvpair ::= key ':' assignment_expression
key ::= T_ID
| T_STR_LIT
optional_parameter_list
::= ( function_param ( ',' function_param )* )?
function_param
::= T_VARARG? T_ID
constant ::= T_INT
| T_DOUBLE
| T_STR_LIT
| T_BT
| T_BF
basic_expression
::= logical_and_expression ( T_LO logical_and_expression )*
logical_and_expression
::= inclusive_or_expression ( T_LA inclusive_or_expression )*
inclusive_or_expression
::= exclusive_or_expression ( '|' exclusive_or_expression )*
exclusive_or_expression
::= and_expression ( '^' and_expression )*
and_expression
::= equality_expression ( '&' equality_expression )*
equality_expression
::= relational_expression ( ( T_EQ | T_NEQ | T_IN ) relational_expression )*
relational_expression
::= shift_expression ( ( '<' | '>' | T_LTE | T_GTE ) shift_expression )*
shift_expression
::= additive_expression ( ( T_LS | T_RS ) additive_expression )*
additive_expression
::= multiplicative_expression ( ( '+' | '-' ) multiplicative_expression )*
multiplicative_expression
::= unary_expression ( ( '*' | '/' | '%' ) unary_expression )*
assignment_expression
::= ( unary_expression ( '=' | T_PLUS_EQUAL ) )* basic_expression
unary_expression
::= ( T_DEC | T_INC | '-' | '+' | '!' )* primary_expression ( '[' assignment_expression ']' | '(' optional_argument_list ')' | '.' T_ID | T_INC | T_DEC )*
optional_argument_list
::= ( argument ( ',' argument )* )?
argument ::= assignment_expression
//Tokens
//\("[^"]+"\)\s+{ return \(\S[^;]+\).+
T_FUNCTION ::= "function"
T_FUNCTION ::= "func"
T_CLASS ::= "class"
T_THROW ::= "throw"
T_NEW ::= "new"
T_LTE ::= "<="
T_GTE ::= ">="
T_INC ::= "++"
T_PLUS_EQUAL ::= "+="
T_DEC ::= "--"
T_EQ ::= "=="
T_NEQ ::= "!="
T_LA ::= "&&"
T_LO ::= "||"
T_BT ::= "true"
T_BF ::= "false"
T_TRY ::= "try"
T_CATCH ::= "catch"
T_IF ::= "if"
T_ELSE_IF ::= "else if"
T_ELSE ::= "else"
T_FOR ::= "for"
T_FOREACH ::= "foreach"
T_WHILE ::= "while"
T_CONTINUE ::= "continue"
T_BREAK ::= "break"
T_RETURN ::= "return"
T_IN ::= "in"
T_LS ::= "<<"
T_RS ::= ">>"
T_VARARG ::= "..."
class property not updating value if 'self' keyword is not used
class Buffer
{
function Buffer(value)
{
self.stream = value;
self.position = 0;
}
function advance()
{
return stream[position++];
}
function top()
{
return stream[position];
}
}
buffer = Buffer("Hello World");
buffer.advance();
if(buffer.position == 0)
{
throw "Expected buffer.position to be greater than 0";
}
if GC_TRACK is called upon a builtin method, ensure it's not already tracked
Line 112 in d009b0a
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.