Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
rought bnf working - had to re-work lexer to fit in with bnf - so lex…
Browse files Browse the repository at this point in the history
…er needs a little more tweaking now as well
  • Loading branch information
kingsleyh committed Nov 24, 2017
1 parent 78f8d0b commit e44cd03
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/main/java/net/kenro/ji/jin/crystal/parser/Crystal.bnf
Expand Up @@ -196,9 +196,9 @@
LINE_COMMENT = "line_comment"


// IDENT = "regexp:\w+"
// comment = 'regexp:#.*'
// space = 'regexp:\s+'
IDENT = "regexp:\w+"
comment = 'regexp:#.*'
space = 'regexp:\s+'

// number = 'regexp:(\+|\-)?(0b[01_]+|0o[0-7_]+|0x[a-fA-f\d_]+|[\d_]+)(\.[\d_]+)?(e[-+]?[\d_]+)?(_?(i|f|u)(8|16|32|64))?'
// string = 'regexp:("([^\"\\]|\\.)*")'
Expand All @@ -207,9 +207,9 @@
]
}

crystalFile ::= IF expression 'then' compositeStatement ['elsif' expression 'then' compositeStatement] ['else' compositeStatement] 'end'
crystalFile ::= item_*

//private item_ ::= (statements | expressions | primary | function)
private item_ ::= (statements | expressions | primary | function)

compositeStatement ::= (statements | expressions)

Expand Down
42 changes: 33 additions & 9 deletions src/test/resources/gold/parser/current/aaa_intial.cr.psi
@@ -1,10 +1,34 @@
Crystal File
CrystalASTWrapperElement(Program)
CrystalASTWrapperElement(Module)
PsiElement(module)('module')
PsiElement(whitespace)(' ')
CrystalASTWrapperElement(ProgramModule)
CrystalASTWrapperElement(ProperName)
PsiElement(proper name)('Initial')
PsiElement(whitespace)('\n')
PsiElement(end)('end')
CrystalStatementsImpl(STATEMENTS)
CrystalStatementImpl(STATEMENT)
CrystalExpressionImpl(EXPRESSION)
CrystalArgImpl(ARG)
CrystalPrimaryImpl(PRIMARY)
PsiElement(if)('if')
PsiWhiteSpace(' ')
CrystalExpressionImpl(EXPRESSION)
CrystalArgImpl(ARG)
CrystalPrimaryImpl(PRIMARY)
CrystalLiteralImpl(LITERAL)
PsiElement(true)('true')
PsiWhiteSpace(' ')
PsiElement(then)('then')
PsiWhiteSpace('\n ')
CrystalCompositeStatementImpl(COMPOSITE_STATEMENT)
CrystalStatementsImpl(STATEMENTS)
CrystalStatementImpl(STATEMENT)
CrystalExpressionImpl(EXPRESSION)
CrystalArgImpl(ARG)
CrystalLhsImpl(LHS)
CrystalVariableImpl(VARIABLE)
CrystalVarNameImpl(VAR_NAME)
PsiElement(IDENT)('a')
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
CrystalArgImpl(ARG)
CrystalPrimaryImpl(PRIMARY)
CrystalLiteralImpl(LITERAL)
PsiElement(NUMBER)('1')
PsiWhiteSpace('\n')
PsiElement(end)('end')

0 comments on commit e44cd03

Please sign in to comment.