소스 검색

Add while statements

pull/1/head
Max Brunsfeld 11 년 전
부모
커밋
11ce0da541
2개의 변경된 파일22개의 추가작업 그리고 0개의 파일을 삭제
  1. +6
    -0
      grammar.coffee
  2. +16
    -0
      grammar_test/statements.txt

+ 6
- 0
grammar.coffee 파일 보기

@ -72,6 +72,7 @@ module.exports = grammar
@return_statement,
@if_statement,
@for_statement,
@while_statement,
@expression_statement,
@statement_block),
@ -99,6 +100,11 @@ module.exports = grammar
")",
@statement)
while_statement: -> seq(
keyword("while"),
"(", @expression, ")",
@statement)
type: -> seq(
optional(keyword("const")),
choice(

+ 16
- 0
grammar_test/statements.txt 파일 보기

@ -77,3 +77,19 @@ int main() {
(function_call (identifier))
(function_call (identifier))
(expression_statement (identifier)))))
============================================
While loops
============================================
int main() {
while (x)
printf("hi");
}
---
(function_declaration (identifier) (identifier) (formal_parameters)
(statement_block
(while_statement (identifier)
(expression_statement (function_call (identifier) (string))))))

불러오는 중...
취소
저장